Skip to content

Commit

Permalink
billsonnn#9 - NestBreedingSuccessEvent adde
Browse files Browse the repository at this point in the history
  • Loading branch information
oobjectt committed Dec 24, 2022
1 parent 473f3ab commit a94d59a
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/events/session/RoomSessionNestBreedingSuccessEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ export class RoomSessionNestBreedingSuccessEvent extends RoomSessionEvent
private _rarityCategory: number;
private _petId: number;

constructor(k: IRoomSession, _arg_2: number, _arg_3: number)
constructor(session: IRoomSession, petId: number, rarityCategory: number)
{
super(RoomSessionNestBreedingSuccessEvent.NEST_BREEDING_SUCCESS, k);
super(RoomSessionNestBreedingSuccessEvent.NEST_BREEDING_SUCCESS, session);

this._petId = _arg_2;
this._rarityCategory = _arg_3;
this._petId = petId;
this._rarityCategory = rarityCategory;
}

public get rarityCategory(): number
Expand Down
3 changes: 2 additions & 1 deletion src/nitro/communication/NitroMessages.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export class IncomingHeader
public static PET_SCRATCH_FAILED = 1130;
public static PET_OPEN_PACKAGE_REQUESTED = 2380;
public static PET_OPEN_PACKAGE_RESULT = 546;
public static PET_NEST_BREEDING_SUCCESS = 2527;
public static RECYCLER_PRIZES = 3164;
public static ROOM_BAN_LIST = 1869;
public static ROOM_BAN_REMOVE = 3429;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { IMessageEvent } from '../../../../../../api';
import { MessageEvent } from '../../../../../../events';
import { NestBreedingSuccessParser } from '../../../parser';

export class NestBreedingSuccessEvent extends MessageEvent implements IMessageEvent
{
constructor(callBack: Function)
{
super(callBack, NestBreedingSuccessParser);
}

public getParser(): NestBreedingSuccessParser
{
return this.parser as NestBreedingSuccessParser;
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './NestBreedingSuccessEvent';
export * from './PetAddedToInventoryEvent';
export * from './PetInventoryEvent';
export * from './PetReceivedMessageEvent';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ export class NestBreedingSuccessParser implements IMessageParser
return true;
}

public parse(k: IMessageDataWrapper): boolean
public parse(wrapper: IMessageDataWrapper): boolean
{
this._petId = k.readInt();
this._rarityCategory = k.readInt();
this._petId = wrapper.readInt();
this._rarityCategory = wrapper.readInt();

return true;
}
Expand Down
20 changes: 18 additions & 2 deletions src/nitro/session/handler/RoomUsersHandler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IConnection, IRoomHandlerListener, IRoomUserData } from '../../../api';
import { RoomSessionDanceEvent, RoomSessionDoorbellEvent, RoomSessionErrorMessageEvent, RoomSessionFavoriteGroupUpdateEvent, RoomSessionFriendRequestEvent, RoomSessionPetFigureUpdateEvent, RoomSessionPetInfoUpdateEvent, RoomSessionPetLevelUpdateEvent, RoomSessionPetStatusUpdateEvent, RoomSessionUserBadgesEvent, RoomSessionUserDataUpdateEvent, RoomSessionUserFigureUpdateEvent } from '../../../events';
import { BotErrorEvent, DoorbellMessageEvent, FavoriteMembershipUpdateMessageEvent, NewFriendRequestEvent, PetFigureUpdateEvent, PetInfoEvent, PetLevelUpdateMessageEvent, PetPlacingErrorEvent, PetStatusUpdateEvent, RoomUnitDanceEvent, RoomUnitEvent, RoomUnitInfoEvent, RoomUnitRemoveEvent, UserCurrentBadgesEvent, UserNameChangeMessageEvent } from '../../communication';
import { RoomSessionDanceEvent, RoomSessionDoorbellEvent, RoomSessionErrorMessageEvent, RoomSessionFavoriteGroupUpdateEvent, RoomSessionFriendRequestEvent, RoomSessionNestBreedingSuccessEvent, RoomSessionPetFigureUpdateEvent, RoomSessionPetInfoUpdateEvent, RoomSessionPetLevelUpdateEvent, RoomSessionPetStatusUpdateEvent, RoomSessionUserBadgesEvent, RoomSessionUserDataUpdateEvent, RoomSessionUserFigureUpdateEvent } from '../../../events';
import { BotErrorEvent, DoorbellMessageEvent, FavoriteMembershipUpdateMessageEvent, NestBreedingSuccessEvent, NewFriendRequestEvent, PetFigureUpdateEvent, PetInfoEvent, PetLevelUpdateMessageEvent, PetPlacingErrorEvent, PetStatusUpdateEvent, RoomUnitDanceEvent, RoomUnitEvent, RoomUnitInfoEvent, RoomUnitRemoveEvent, UserCurrentBadgesEvent, UserNameChangeMessageEvent } from '../../communication';
import { RoomPetData } from '../RoomPetData';
import { RoomUserData } from '../RoomUserData';
import { BaseHandler } from './BaseHandler';
Expand All @@ -22,6 +22,7 @@ export class RoomUsersHandler extends BaseHandler
connection.addMessageEvent(new PetInfoEvent(this.onPetInfoEvent.bind(this)));
connection.addMessageEvent(new PetStatusUpdateEvent(this.onPetStatusUpdateEvent.bind(this)));
connection.addMessageEvent(new PetLevelUpdateMessageEvent(this.onPetLevelUpdateMessageEvent.bind(this)));
connection.addMessageEvent(new NestBreedingSuccessEvent(this.onNestBreedingSuccessEvent.bind(this)));
connection.addMessageEvent(new PetFigureUpdateEvent(this.onPetFigureUpdateEvent.bind(this)));
connection.addMessageEvent(new PetPlacingErrorEvent(this.onPetPlacingError.bind(this)));
connection.addMessageEvent(new BotErrorEvent(this.onBotError.bind(this)));
Expand Down Expand Up @@ -272,6 +273,21 @@ export class RoomUsersHandler extends BaseHandler
this.listener.events.dispatchEvent(new RoomSessionPetLevelUpdateEvent(session, parser.petId, parser.level));
}

private onNestBreedingSuccessEvent(event: NestBreedingSuccessEvent): void
{
if(!this.listener) return;

const parser = event.getParser();

if(!parser) return;

const session = this.listener.getSession(this.roomId);

if(!session) return;

this.listener.events.dispatchEvent(new RoomSessionNestBreedingSuccessEvent(session, parser.petId, parser.rarityCategory));
}

private onPetFigureUpdateEvent(event: PetFigureUpdateEvent): void
{
if(!this.listener) return;
Expand Down

0 comments on commit a94d59a

Please sign in to comment.