Add achievement packet

This commit is contained in:
Bill 2021-08-22 00:53:13 -04:00
parent 458a74b5a7
commit bff0151301
9 changed files with 150 additions and 1 deletions

View File

@ -1,5 +1,5 @@
import { IMessageConfiguration } from '../../core/communication/messages/IMessageConfiguration'; import { IMessageConfiguration } from '../../core/communication/messages/IMessageConfiguration';
import { ApproveNameMessageComposer, BadgeReceivedEvent, BonusRareInfoMessageEvent, CatalogApproveNameResultEvent, ChangeUserNameResultMessageEvent, FurnitureGuildInfoComposer, GetBonusRareInfoMessageComposer, MysteryBoxKeysEvent, PetExperienceEvent, PetMountComposer, PetSupplementComposer, RemoveAllRightsMessageComposer, RemoveOwnRoomRightsRoomMessageComposer, RemovePetSaddleComposer, RoomUnitGiveHandItemPetComposer, SellablePetPalettesEvent, TogglePetBreedingComposer, TogglePetRidingComposer, UnseenResetCategoryComposer, UnseenResetItemsComposer, UsePetProductComposer } from './messages'; import { AchievementNotificationMessageEvent, ApproveNameMessageComposer, BadgeReceivedEvent, BonusRareInfoMessageEvent, CatalogApproveNameResultEvent, ChangeUserNameResultMessageEvent, FurnitureGuildInfoComposer, GetBonusRareInfoMessageComposer, MysteryBoxKeysEvent, PetExperienceEvent, PetMountComposer, PetSupplementComposer, RemoveAllRightsMessageComposer, RemoveOwnRoomRightsRoomMessageComposer, RemovePetSaddleComposer, RoomUnitGiveHandItemPetComposer, SellablePetPalettesEvent, TogglePetBreedingComposer, TogglePetRidingComposer, UnseenResetCategoryComposer, UnseenResetItemsComposer, UsePetProductComposer } from './messages';
import { AvailabilityStatusMessageEvent } from './messages/incoming/availability/AvailabilityStatusMessageEvent'; import { AvailabilityStatusMessageEvent } from './messages/incoming/availability/AvailabilityStatusMessageEvent';
import { CameraPublishStatusMessageEvent } from './messages/incoming/camera/CameraPublishStatusMessageEvent'; import { CameraPublishStatusMessageEvent } from './messages/incoming/camera/CameraPublishStatusMessageEvent';
import { CameraPurchaseOKMessageEvent } from './messages/incoming/camera/CameraPurchaseOKMessageEvent'; import { CameraPurchaseOKMessageEvent } from './messages/incoming/camera/CameraPurchaseOKMessageEvent';
@ -601,6 +601,7 @@ export class NitroMessages implements IMessageConfiguration
this._events.set(IncomingHeader.USER_RESPECT, RespectReceivedEvent); this._events.set(IncomingHeader.USER_RESPECT, RespectReceivedEvent);
this._events.set(IncomingHeader.UNSEEN_ITEMS, UnseenItemsEvent); this._events.set(IncomingHeader.UNSEEN_ITEMS, UnseenItemsEvent);
this._events.set(IncomingHeader.HOTEL_WILL_SHUTDOWN, HotelWillShutdownEvent); this._events.set(IncomingHeader.HOTEL_WILL_SHUTDOWN, HotelWillShutdownEvent);
this._events.set(IncomingHeader.ACHIEVEMENT_NOTIFICATION, AchievementNotificationMessageEvent);
// ROOM // ROOM

View File

@ -271,4 +271,5 @@ export class IncomingHeader
public static COMPETITION_STATUS = 133; public static COMPETITION_STATUS = 133;
public static INIT_CAMERA = 3878; public static INIT_CAMERA = 3878;
public static THUMBNAIL_STATUS = 3595; public static THUMBNAIL_STATUS = 3595;
public static ACHIEVEMENT_NOTIFICATION = 806;
} }

View File

@ -0,0 +1,93 @@
import { IMessageDataWrapper } from '../../../../../core';
export class AchievementLevelUpData
{
private _type: number;
private _level: number;
private _points: number;
private _levelRewardPoints: number;
private _levelRewardPointType: number;
private _bonusPoints: number;
private _badgeId: number;
private _badgeCode: string = '';
private _removedBadgeCode: string = '';
private _achievementID: number;
private _category: string;
private _showDialogToUser: boolean;
constructor(wrapper: IMessageDataWrapper)
{
this._type = wrapper.readInt();
this._level = wrapper.readInt();
this._badgeId = wrapper.readInt();
this._badgeCode = wrapper.readString();
this._points = wrapper.readInt();
this._levelRewardPoints = wrapper.readInt();
this._levelRewardPointType = wrapper.readInt();
this._bonusPoints = wrapper.readInt();
this._achievementID = wrapper.readInt();
this._removedBadgeCode = wrapper.readString();
this._category = wrapper.readString();
this._showDialogToUser = wrapper.readBoolean();
}
public get type(): number
{
return this._type;
}
public get level(): number
{
return this._level;
}
public get points(): number
{
return this._points;
}
public get levelRewardPoints(): number
{
return this._levelRewardPoints;
}
public get levelRewardPointType(): number
{
return this._levelRewardPointType;
}
public get bonusPoints(): number
{
return this._bonusPoints;
}
public get badgeId(): number
{
return this._badgeId;
}
public get badgeCode(): string
{
return this._badgeCode;
}
public get removedBadgeCode(): string
{
return this._removedBadgeCode;
}
public get achievementID(): number
{
return this._achievementID;
}
public get category(): string
{
return this._category;
}
public get showDialogToUser(): boolean
{
return this._showDialogToUser;
}
}

View File

@ -0,0 +1,16 @@
import { IMessageEvent } from '../../../../../core/communication/messages/IMessageEvent';
import { MessageEvent } from '../../../../../core/communication/messages/MessageEvent';
import { AchievementNotificationMessageParser } from '../../parser';
export class AchievementNotificationMessageEvent extends MessageEvent implements IMessageEvent
{
constructor(callBack: Function)
{
super(callBack, AchievementNotificationMessageParser);
}
public getParser(): AchievementNotificationMessageParser
{
return this.parser as AchievementNotificationMessageParser;
}
}

View File

@ -1,3 +1,5 @@
export * from './AchievementLevelUpData';
export * from './AchievementNotificationMessageEvent';
export * from './BotErrorEvent'; export * from './BotErrorEvent';
export * from './HabboBroadcastMessageEvent'; export * from './HabboBroadcastMessageEvent';
export * from './HotelWillShutdownEvent'; export * from './HotelWillShutdownEvent';

View File

@ -0,0 +1,29 @@
import { IMessageDataWrapper } from '../../../../../core/communication/messages/IMessageDataWrapper';
import { IMessageParser } from '../../../../../core/communication/messages/IMessageParser';
import { AchievementLevelUpData } from '../../incoming';
export class AchievementNotificationMessageParser implements IMessageParser
{
private _data: AchievementLevelUpData;
public flush(): boolean
{
this._data = null;
return true;
}
public parse(wrapper: IMessageDataWrapper): boolean
{
if(!wrapper) return false;
this._data = new AchievementLevelUpData(wrapper);
return true;
}
public get data(): AchievementLevelUpData
{
return this._data;
}
}

View File

@ -1,3 +1,4 @@
export * from './AchievementNotificationMessageParser';
export * from './BotErrorEventParser'; export * from './BotErrorEventParser';
export * from './HabboBroadcastMessageParser'; export * from './HabboBroadcastMessageParser';
export * from './HotelWillShutdownParser'; export * from './HotelWillShutdownParser';

View File

@ -3,6 +3,7 @@ export interface INitroLocalizationManager extends INitroManager
{ {
getRomanNumeral(number: number): string; getRomanNumeral(number: number): string;
getBadgeBaseAndLevel(badgeName: string): string; getBadgeBaseAndLevel(badgeName: string): string;
hasValue(key: string): boolean;
getValue(key: string, doParams?: boolean): string; getValue(key: string, doParams?: boolean): string;
getValueWithParameter(key: string, parameter: string, replacement: string): string; getValueWithParameter(key: string, parameter: string, replacement: string): string;
getValueWithParameters(key: string, parameters: string[], replacements: string[]): string; getValueWithParameters(key: string, parameters: string[], replacements: string[]): string;

View File

@ -67,6 +67,11 @@ export class NitroLocalizationManager extends NitroManager implements INitroLoca
return badge.getBadgeId; return badge.getBadgeId;
} }
public hasValue(key: string): boolean
{
return this._definitions.has(key);
}
public getValue(key: string, doParams: boolean = true): string public getValue(key: string, doParams: boolean = true): string
{ {
if(key.startsWith('${')) key = key.substr(2, (key.length - 3)); if(key.startsWith('${')) key = key.substr(2, (key.length - 3));