forked from billsonnn/nitro-renderer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
billsonnn#28 - BotSkillListUpdateEvent added
- Loading branch information
Showing
7 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/nitro/communication/messages/incoming/room/bots/BotSkillListUpdateEvent.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
23
src/nitro/communication/messages/parser/room/bots/BotSkillData.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/nitro/communication/messages/parser/room/bots/BotSkillListUpdateParser.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export * from './BotCommandConfigurationParser'; | ||
export * from './BotSkillData'; | ||
export * from './BotSkillListUpdateParser'; |