Skip to content

Commit

Permalink
billsonnn#28 - BotSkillListUpdateEvent added
Browse files Browse the repository at this point in the history
  • Loading branch information
oobjectt committed Dec 25, 2022
1 parent 26741b7 commit 1ae87a5
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 1 deletion.
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 @@ -277,6 +277,7 @@ export class IncomingHeader
public static REDEEM_VOUCHER_OK = 3336;
public static IN_CLIENT_LINK = 2023;
public static BOT_COMMAND_CONFIGURATION = 1618;
public static BOT_SKILL_LIST_UPDATE = 69;
public static HAND_ITEM_RECEIVED = 354;
public static PET_PLACING_ERROR = 2913;
public static BOT_ERROR = 639;
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 { BotSkillListUpdateParser } from '../../../parser';

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

public getParser(): BotSkillListUpdateParser
{
return this.parser as BotSkillListUpdateParser;
}
}
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './BotCommandConfigurationEvent';
export * from './BotSkillListUpdateEvent';
23 changes: 23 additions & 0 deletions src/nitro/communication/messages/parser/room/bots/BotSkillData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { IMessageDataWrapper } from '../../../../../../api';

export class BotSkillData
{
private _id: number;
private _data: string;

constructor(wrapper: IMessageDataWrapper)
{
this._id = wrapper.readInt();
this._data = wrapper.readString();
}

public get id(): number
{
return this._id;
}

public get data(): string
{
return this._data;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { IMessageDataWrapper, IMessageParser } from '../../../../../../api';
import { BotSkillData } from './BotSkillData';

export class BotSkillListUpdateParser implements IMessageParser
{
private _botId: number;
private _skillList: BotSkillData[];

public flush(): boolean
{
this._botId = -1;
this._skillList = [];

return true;
}

public parse(wrapper: IMessageDataWrapper): boolean
{
if(!wrapper) return false;

this._botId = wrapper.readInt();

let totalSkills = wrapper.readInt();

while(totalSkills > 0)
{
this._skillList.push(new BotSkillData(wrapper));

totalSkills--;
}

return true;
}

public get botId(): number
{
return this._botId;
}

public get skillList(): BotSkillData[]
{
return this._skillList;
}
}
2 changes: 2 additions & 0 deletions src/nitro/communication/messages/parser/room/bots/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export * from './BotCommandConfigurationParser';
export * from './BotSkillData';
export * from './BotSkillListUpdateParser';

0 comments on commit 1ae87a5

Please sign in to comment.