#9 - PetLevelUpdateEvent added

This commit is contained in:
oobjectt 2022-12-23 19:56:29 +01:00
parent c9307102f6
commit 097dc60bef
8 changed files with 86 additions and 7 deletions

View File

@ -8,12 +8,12 @@ export class RoomSessionPetLevelUpdateEvent extends RoomSessionEvent
private _petId: number; private _petId: number;
private _level: number; private _level: number;
constructor(k: IRoomSession, _arg_2: number, _arg_3: number) constructor(session: IRoomSession, petId: number, level: number)
{ {
super(RoomSessionPetLevelUpdateEvent.PET_LEVEL_UPDATE, k); super(RoomSessionPetLevelUpdateEvent.PET_LEVEL_UPDATE, session);
this._petId = _arg_2; this._petId = petId;
this._level = _arg_3; this._level = level;
} }
public get petId(): number public get petId(): number

File diff suppressed because one or more lines are too long

View File

@ -120,6 +120,7 @@ export class IncomingHeader
public static PET_FIGURE_UPDATE = 1924; public static PET_FIGURE_UPDATE = 1924;
public static PET_INFO = 2901; public static PET_INFO = 2901;
public static PET_TRAINING_PANEL = 1164; public static PET_TRAINING_PANEL = 1164;
public static PET_LEVEL_UPDATE = 2824;
public static RECYCLER_PRIZES = 3164; public static RECYCLER_PRIZES = 3164;
public static ROOM_BAN_LIST = 1869; public static ROOM_BAN_LIST = 1869;
public static ROOM_BAN_REMOVE = 3429; public static ROOM_BAN_REMOVE = 3429;

View File

@ -0,0 +1,16 @@
import { IMessageEvent } from '../../../../../api';
import { MessageEvent } from '../../../../../events';
import { PetLevelUpdateMessageParser } from '../../parser';
export class PetLevelUpdateMessageEvent extends MessageEvent implements IMessageEvent
{
constructor(callBack: Function)
{
super(callBack, PetLevelUpdateMessageParser);
}
public getParser(): PetLevelUpdateMessageParser
{
return this.parser as PetLevelUpdateMessageParser;
}
}

View File

@ -1 +1,2 @@
export * from './PetLevelUpdateMessageEvent';
export * from './PetTrainingPanelMessageEvent'; export * from './PetTrainingPanelMessageEvent';

View File

@ -0,0 +1,41 @@
import { IMessageDataWrapper, IMessageParser } from '../../../../../api';
export class PetLevelUpdateMessageParser implements IMessageParser
{
private _roomIndex: number;
private _petId: number;
private _level: number;
flush(): boolean
{
this._roomIndex = -1;
this._petId = -1;
this._level = -1;
return true;
}
parse(wrapper: IMessageDataWrapper): boolean
{
this._roomIndex = wrapper.readInt();
this._petId = wrapper.readInt();
this._level = wrapper.readInt();
return true;
}
public get roomIndex(): number
{
return this._roomIndex;
}
public get petId(): number
{
return this._petId;
}
public get level(): number
{
return this._level;
}
}

View File

@ -1 +1,2 @@
export * from './PetLevelUpdateMessageParser';
export * from './PetTrainingMessageParser'; export * from './PetTrainingMessageParser';

View File

@ -1,6 +1,6 @@
import { IConnection, IRoomHandlerListener, IRoomUserData } from '../../../api'; import { IConnection, IRoomHandlerListener, IRoomUserData } from '../../../api';
import { RoomSessionDanceEvent, RoomSessionDoorbellEvent, RoomSessionErrorMessageEvent, RoomSessionFavoriteGroupUpdateEvent, RoomSessionFriendRequestEvent, RoomSessionPetFigureUpdateEvent, RoomSessionPetInfoUpdateEvent, RoomSessionPetStatusUpdateEvent, RoomSessionUserBadgesEvent, RoomSessionUserDataUpdateEvent, RoomSessionUserFigureUpdateEvent } from '../../../events'; import { RoomSessionDanceEvent, RoomSessionDoorbellEvent, RoomSessionErrorMessageEvent, RoomSessionFavoriteGroupUpdateEvent, RoomSessionFriendRequestEvent, RoomSessionPetFigureUpdateEvent, RoomSessionPetInfoUpdateEvent, RoomSessionPetLevelUpdateEvent, RoomSessionPetStatusUpdateEvent, RoomSessionUserBadgesEvent, RoomSessionUserDataUpdateEvent, RoomSessionUserFigureUpdateEvent } from '../../../events';
import { BotErrorEvent, DoorbellMessageEvent, FavoriteMembershipUpdateMessageEvent, NewFriendRequestEvent, PetFigureUpdateEvent, PetInfoEvent, PetPlacingErrorEvent, PetStatusUpdateEvent, RoomUnitDanceEvent, RoomUnitEvent, RoomUnitInfoEvent, RoomUnitRemoveEvent, UserCurrentBadgesEvent, UserNameChangeMessageEvent } from '../../communication'; import { BotErrorEvent, DoorbellMessageEvent, FavoriteMembershipUpdateMessageEvent, NewFriendRequestEvent, PetFigureUpdateEvent, PetInfoEvent, PetLevelUpdateMessageEvent, PetPlacingErrorEvent, PetStatusUpdateEvent, RoomUnitDanceEvent, RoomUnitEvent, RoomUnitInfoEvent, RoomUnitRemoveEvent, UserCurrentBadgesEvent, UserNameChangeMessageEvent } from '../../communication';
import { RoomPetData } from '../RoomPetData'; import { RoomPetData } from '../RoomPetData';
import { RoomUserData } from '../RoomUserData'; import { RoomUserData } from '../RoomUserData';
import { BaseHandler } from './BaseHandler'; import { BaseHandler } from './BaseHandler';
@ -21,6 +21,7 @@ export class RoomUsersHandler extends BaseHandler
connection.addMessageEvent(new NewFriendRequestEvent(this.onNewFriendRequestEvent.bind(this))); connection.addMessageEvent(new NewFriendRequestEvent(this.onNewFriendRequestEvent.bind(this)));
connection.addMessageEvent(new PetInfoEvent(this.onPetInfoEvent.bind(this))); connection.addMessageEvent(new PetInfoEvent(this.onPetInfoEvent.bind(this)));
connection.addMessageEvent(new PetStatusUpdateEvent(this.onPetStatusUpdateEvent.bind(this))); connection.addMessageEvent(new PetStatusUpdateEvent(this.onPetStatusUpdateEvent.bind(this)));
connection.addMessageEvent(new PetLevelUpdateMessageEvent(this.onPetLevelUpdateMessageEvent.bind(this)));
connection.addMessageEvent(new PetFigureUpdateEvent(this.onPetFigureUpdateEvent.bind(this))); connection.addMessageEvent(new PetFigureUpdateEvent(this.onPetFigureUpdateEvent.bind(this)));
connection.addMessageEvent(new PetPlacingErrorEvent(this.onPetPlacingError.bind(this))); connection.addMessageEvent(new PetPlacingErrorEvent(this.onPetPlacingError.bind(this)));
connection.addMessageEvent(new BotErrorEvent(this.onBotError.bind(this))); connection.addMessageEvent(new BotErrorEvent(this.onBotError.bind(this)));
@ -254,6 +255,23 @@ export class RoomUsersHandler extends BaseHandler
this.listener.events.dispatchEvent(new RoomSessionPetStatusUpdateEvent(session, parser.petId, parser.canBreed, parser.canHarvest, parser.canRevive, parser.hasBreedingPermission)); this.listener.events.dispatchEvent(new RoomSessionPetStatusUpdateEvent(session, parser.petId, parser.canBreed, parser.canHarvest, parser.canRevive, parser.hasBreedingPermission));
} }
private onPetLevelUpdateMessageEvent(event: PetLevelUpdateMessageEvent): void
{
if(!this.listener) return;
const parser = event.getParser();
if(!parser) return;
const session = this.listener.getSession(this.roomId);
if(!session) return;
session.userDataManager.updatePetLevel(parser.roomIndex, parser.level);
this.listener.events.dispatchEvent(new RoomSessionPetLevelUpdateEvent(session, parser.petId, parser.level));
}
private onPetFigureUpdateEvent(event: PetFigureUpdateEvent): void private onPetFigureUpdateEvent(event: PetFigureUpdateEvent): void
{ {
if(!this.listener) return; if(!this.listener) return;