Skip to content

Commit

Permalink
#9 - PetBreedingEvent added (#14)
Browse files Browse the repository at this point in the history
* #9 - PetBreedingEvent added
  • Loading branch information
oobjectt authored Dec 24, 2022
1 parent 473f3ab commit 4687bfa
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/events/session/RoomSessionPetBreedingEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ export class RoomSessionPetBreedingEvent extends RoomSessionEvent
private _ownPetId: number;
private _otherPetId: number;

constructor(k: IRoomSession, _arg_2: number, _arg_3: number, _arg_4: number)
constructor(session: IRoomSession, state: number, ownPetId: number, otherPetId: number)
{
super(RoomSessionPetBreedingEvent.PET_BREEDING, k);
super(RoomSessionPetBreedingEvent.PET_BREEDING, session);

this._state = _arg_2;
this._ownPetId = _arg_3;
this._otherPetId = _arg_4;
this._state = state;
this._ownPetId = ownPetId;
this._otherPetId = otherPetId;
}

public get state(): 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_BREEDING = 1746;
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 { PetBreedingMessageParser } from './../../../parser';

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

public getParser(): PetBreedingMessageParser
{
return this.parser as PetBreedingMessageParser;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './PetBreedingMessageEvent';
1 change: 1 addition & 0 deletions src/nitro/communication/messages/incoming/pet/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './breeding';
export * from './OpenPetPackageRequestedMessageEvent';
export * from './OpenPetPackageResultMessageEvent';
export * from './PetLevelUpdateMessageEvent';
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, RoomSessionPetBreedingEvent, RoomSessionPetFigureUpdateEvent, RoomSessionPetInfoUpdateEvent, RoomSessionPetLevelUpdateEvent, RoomSessionPetStatusUpdateEvent, RoomSessionUserBadgesEvent, RoomSessionUserDataUpdateEvent, RoomSessionUserFigureUpdateEvent } from '../../../events';
import { BotErrorEvent, DoorbellMessageEvent, FavoriteMembershipUpdateMessageEvent, NewFriendRequestEvent, PetBreedingMessageEvent, 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 @@ -21,6 +21,7 @@ export class RoomUsersHandler extends BaseHandler
connection.addMessageEvent(new NewFriendRequestEvent(this.onNewFriendRequestEvent.bind(this)));
connection.addMessageEvent(new PetInfoEvent(this.onPetInfoEvent.bind(this)));
connection.addMessageEvent(new PetStatusUpdateEvent(this.onPetStatusUpdateEvent.bind(this)));
connection.addMessageEvent(new PetBreedingMessageEvent(this.onPetBreedingMessageEvent.bind(this)));
connection.addMessageEvent(new PetLevelUpdateMessageEvent(this.onPetLevelUpdateMessageEvent.bind(this)));
connection.addMessageEvent(new PetFigureUpdateEvent(this.onPetFigureUpdateEvent.bind(this)));
connection.addMessageEvent(new PetPlacingErrorEvent(this.onPetPlacingError.bind(this)));
Expand Down Expand Up @@ -255,6 +256,21 @@ export class RoomUsersHandler extends BaseHandler
this.listener.events.dispatchEvent(new RoomSessionPetStatusUpdateEvent(session, parser.petId, parser.canBreed, parser.canHarvest, parser.canRevive, parser.hasBreedingPermission));
}

private onPetBreedingMessageEvent(event: PetBreedingMessageEvent): 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 RoomSessionPetBreedingEvent(session, parser.state, parser.ownPetId, parser.otherPetId));
}

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

0 comments on commit 4687bfa

Please sign in to comment.