mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2025-01-18 14:36:26 +01:00
Perk event and parser
This commit is contained in:
parent
d3458229fd
commit
536d978435
@ -29,6 +29,7 @@ export * from './moderation';
|
||||
export * from './mysterybox';
|
||||
export * from './navigator';
|
||||
export * from './notifications';
|
||||
export * from './perk';
|
||||
export * from './poll';
|
||||
export * from './quest';
|
||||
export * from './room';
|
||||
|
@ -0,0 +1,16 @@
|
||||
import { IMessageEvent } from '../../../../../core/communication/messages/IMessageEvent';
|
||||
import { MessageEvent } from '../../../../../core/communication/messages/MessageEvent';
|
||||
import { PerkAllowancesMessageParser } from './../../parser/perk/PerkAllowancesMessageParser';
|
||||
|
||||
export class PerkAllowancesMessageEvent extends MessageEvent implements IMessageEvent
|
||||
{
|
||||
constructor(callBack: Function)
|
||||
{
|
||||
super(callBack, PerkAllowancesMessageParser);
|
||||
}
|
||||
|
||||
public getParser(): PerkAllowancesMessageParser
|
||||
{
|
||||
return this.parser as PerkAllowancesMessageParser;
|
||||
}
|
||||
}
|
1
src/nitro/communication/messages/incoming/perk/index.ts
Normal file
1
src/nitro/communication/messages/incoming/perk/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './PerkAllowancesMessageEvent';
|
@ -21,6 +21,7 @@ export * from './moderation';
|
||||
export * from './mysterybox';
|
||||
export * from './navigator';
|
||||
export * from './notifications';
|
||||
export * from './perk';
|
||||
export * from './poll';
|
||||
export * from './quest';
|
||||
export * from './room';
|
||||
|
@ -0,0 +1,36 @@
|
||||
import { IMessageDataWrapper, IMessageParser } from '../../../../../core';
|
||||
import { PerkData } from './common/PerkData';
|
||||
|
||||
export class PerkAllowancesMessageParser implements IMessageParser
|
||||
{
|
||||
private _perks: PerkData[];
|
||||
|
||||
public flush(): boolean
|
||||
{
|
||||
this._perks = [];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public parse(wrapper: IMessageDataWrapper): boolean
|
||||
{
|
||||
if(!wrapper) return false;
|
||||
|
||||
this._perks = [];
|
||||
|
||||
const size: number = wrapper.readInt();
|
||||
|
||||
for(let i = 0; i < size; i++) this._perks.push(new PerkData(
|
||||
wrapper.readString(),
|
||||
wrapper.readBoolean(),
|
||||
wrapper.readString()
|
||||
));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public get perks(): PerkData[]
|
||||
{
|
||||
return this._perks;
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
export class PerkData
|
||||
{
|
||||
private _code: string;
|
||||
private _isAllowed: boolean;
|
||||
private _errorMessage: string;
|
||||
|
||||
constructor(code: string, isAllowed: boolean, errorMessage: string)
|
||||
{
|
||||
this._code = code;
|
||||
this._isAllowed = isAllowed;
|
||||
this._errorMessage = errorMessage;
|
||||
}
|
||||
|
||||
public get code(): string
|
||||
{
|
||||
return this._code;
|
||||
}
|
||||
|
||||
public get isAllowed(): boolean
|
||||
{
|
||||
return this._isAllowed;
|
||||
}
|
||||
|
||||
public get errorMessage(): string
|
||||
{
|
||||
return this._errorMessage;
|
||||
}
|
||||
}
|
1
src/nitro/communication/messages/parser/perk/index.ts
Normal file
1
src/nitro/communication/messages/parser/perk/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './PerkAllowancesMessageParser';
|
@ -1,16 +0,0 @@
|
||||
import { IMessageDataWrapper, IMessageParser } from '../../../../../../core';
|
||||
|
||||
export class UserPerksParser implements IMessageParser
|
||||
{
|
||||
public flush(): boolean
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public parse(wrapper: IMessageDataWrapper): boolean
|
||||
{
|
||||
if(!wrapper) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,2 +1 @@
|
||||
export * from './UserPerksParser';
|
||||
export * from './UserPermissionsParser';
|
||||
|
Loading…
Reference in New Issue
Block a user