#9 - TalentLevelUpEvent addd

This commit is contained in:
oobjectt 2022-12-24 15:30:19 +01:00
parent 26741b78a7
commit 9c139b442b
8 changed files with 114 additions and 3 deletions

File diff suppressed because one or more lines are too long

View File

@ -361,6 +361,7 @@ export class IncomingHeader
public static BADGE_POINT_LIMITS = 2501;
public static BADGE_REQUEST_FULFILLED = 2998;
public static HELPER_TALENT_TRACK = 3406;
public static TALENT_TRACK_LEVEL_UP = 638;
public static USER_BANNED = 1683;
public static BOT_RECEIVED = 3684;
public static PET_LEVEL_NOTIFICATION = 859;

View File

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

View File

@ -1 +1,2 @@
export * from './TalentLevelUpEvent';
export * from './TalentTrackMessageEvent';

View File

@ -0,0 +1,74 @@
import { TalentTrackRewardPerk, TalentTrackRewardProduct } from '.';
import { IMessageDataWrapper, IMessageParser } from '../../../../../api';
export class TalentLevelUpMessageParser implements IMessageParser
{
private _talentTrackName: string;
private _level: number;
private _rewardPerks: TalentTrackRewardPerk[];
private _rewardProducts: TalentTrackRewardProduct[];
public flush(): boolean
{
this._talentTrackName = null;
this._level = -1;
this._rewardPerks = [];
this._rewardProducts = [];
return true;
}
public parse(wrapper: IMessageDataWrapper): boolean
{
if(!wrapper) return false;
let totalRewards = 0;
this._talentTrackName = wrapper.readString();
this._level = wrapper.readInt();
const totalRewardsPerks = wrapper.readInt();
while(totalRewards < totalRewardsPerks)
{
this._rewardPerks.push(new TalentTrackRewardPerk(wrapper));
totalRewards++;
}
const totalRewardsProducts = wrapper.readInt();
if(totalRewards < totalRewardsProducts)
{
for(let i = 0; i < totalRewardsProducts; i++)
{
const name = wrapper.readString();
const vipDays = wrapper.readInt();
this._rewardProducts.push(new TalentTrackRewardProduct(name, vipDays));
totalRewards++;
}
}
return true;
}
public get talentTrackName(): string
{
return this._talentTrackName;
}
public get level(): number
{
return this._level;
}
public get rewardPerks(): TalentTrackRewardPerk[]
{
return this._rewardPerks;
}
public get rewardProducts(): TalentTrackRewardProduct[]
{
return this._rewardProducts;
}
}

View File

@ -0,0 +1,16 @@
import { IMessageDataWrapper } from '../../../../../api';
export class TalentTrackRewardPerk
{
private _perkId: number;
constructor(wrapper: IMessageDataWrapper)
{
this._perkId = wrapper.readInt();
}
public get perkId(): number
{
return this._perkId;
}
}

View File

@ -3,10 +3,10 @@ export class TalentTrackRewardProduct
private _productCode: string;
private _vipDays: number;
constructor(name: string, unknownInt: number)
constructor(name: string, vipDays: number)
{
this._productCode = name;
this._vipDays = unknownInt;
this._vipDays = vipDays;
}
public get productCode(): string

View File

@ -1,4 +1,6 @@
export * from './TalentLevelUpMessageParser';
export * from './TalentTrackLevel';
export * from './TalentTrackParser';
export * from './TalentTrackRewardPerk';
export * from './TalentTrackRewardProduct';
export * from './TalentTrackTask';