Recycler | Packets

This commit is contained in:
object 2023-11-22 23:55:32 +01:00
parent 81cfd5c56f
commit 90981f2116
10 changed files with 200 additions and 1 deletions

File diff suppressed because one or more lines are too long

View File

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

View File

@ -1,2 +1,3 @@
export * from './RecyclerFinishedMessageEvent'; export * from './RecyclerFinishedMessageEvent';
export * from './RecyclerPrizesMessageEvent';
export * from './RecyclerStatusMessageEvent'; export * from './RecyclerStatusMessageEvent';

View File

@ -0,0 +1,21 @@
import { IMessageComposer } from '../../../../../api';
export class GetRecyclerPrizesMessageComposer implements IMessageComposer<ConstructorParameters<typeof GetRecyclerPrizesMessageComposer>>
{
private _data: ConstructorParameters<typeof GetRecyclerPrizesMessageComposer>;
constructor()
{
this._data = [];
}
public getMessageArray()
{
return this._data;
}
public dispose(): void
{
return;
}
}

View File

@ -1,2 +1,3 @@
export * from './GetRecyclerPrizesMessageComposer';
export * from './GetRecyclerStatusMessageComposer'; export * from './GetRecyclerStatusMessageComposer';
export * from './RecycleItemsMessageComposer'; export * from './RecycleItemsMessageComposer';

View File

@ -0,0 +1,39 @@
import { PrizeMessageData } from '.';
import { IMessageDataWrapper } from '../../../../../api';
export class PrizeLevelMessageData
{
private _prizeLevelId: number;
private _probabilityDenominator: number;
private _prizes: PrizeMessageData[];
constructor(wrapper: IMessageDataWrapper)
{
this._prizeLevelId = wrapper.readInt();
this._probabilityDenominator = wrapper.readInt();
this._prizes = [];
let totalPrizes: number = wrapper.readInt();
while(totalPrizes > 0)
{
this._prizes.push(new PrizeMessageData(wrapper));
totalPrizes--;
}
}
public get prizeLevelId(): number
{
return this._prizeLevelId;
}
public get probabilityDenominator(): number
{
return this._probabilityDenominator;
}
public get prizes(): PrizeMessageData[]
{
return this._prizes;
}
}

View File

@ -0,0 +1,59 @@
import { PrizeMessageSubProduct } from '.';
import { IMessageDataWrapper } from '../../../../../api';
export class PrizeMessageData
{
private _productConfigurationSize: number = 1;
private _productCode: string;
private _subProducts: PrizeMessageSubProduct[];
private _productItemType: string;
private _productItemTypeId: number;
constructor(wrapper: IMessageDataWrapper)
{
let totalPrizes: number = wrapper.readInt();
this._subProducts = [];
this._productCode = wrapper.readString();
this._productConfigurationSize = wrapper.readInt();
if(!this.hasProductConfigurationSize)
{
this._productItemType = wrapper.readString();
this._productItemTypeId = wrapper.readInt();
}
else
{
while(totalPrizes < this._productConfigurationSize)
{
this._subProducts.push(new PrizeMessageSubProduct(wrapper));
totalPrizes++;
}
}
}
public get productItemType(): string
{
return this._productItemType;
}
public get productItemTypeId(): number
{
return this._productItemTypeId;
}
public get hasProductConfigurationSize(): boolean
{
return this._productConfigurationSize > 1;
}
public get subProducts(): PrizeMessageSubProduct[]
{
return this._subProducts;
}
public get productCode(): string
{
return this._productCode;
}
}

View File

@ -0,0 +1,23 @@
import { IMessageDataWrapper } from '../../../../../api';
export class PrizeMessageSubProduct
{
private _productItemType: string;
private _productItemTypeId: number;
constructor(wrapper: IMessageDataWrapper)
{
this._productItemType = wrapper.readString();
this._productItemTypeId = wrapper.readInt();
}
public get productItemType(): string
{
return this._productItemType;
}
public get productItemTypeId(): number
{
return this._productItemTypeId;
}
}

View File

@ -0,0 +1,33 @@
import { PrizeLevelMessageData } from '.';
import { IMessageDataWrapper, IMessageParser } from '../../../../../api';
export class RecyclerPrizesMessageParser implements IMessageParser
{
private _prizeLevels: PrizeLevelMessageData[];
public flush(): boolean
{
return true;
}
public parse(wrapper: IMessageDataWrapper): boolean
{
if(!wrapper) return false;
let totalPrizeLevels: number = wrapper.readInt();
this._prizeLevels = [];
while(totalPrizeLevels > 0)
{
this._prizeLevels.push(new PrizeLevelMessageData(wrapper));
totalPrizeLevels--;
}
return true;
}
public get prizeLevels(): PrizeLevelMessageData[]
{
return this._prizeLevels;
}
}

View File

@ -1,2 +1,6 @@
export * from './PrizeLevelMessageData';
export * from './PrizeMessageData';
export * from './PrizeMessageSubProduct';
export * from './RecyclerFinishedMessageParser'; export * from './RecyclerFinishedMessageParser';
export * from './RecyclerPrizesMessageParser';
export * from './RecyclerStatusMessageParser'; export * from './RecyclerStatusMessageParser';