import { PolusBuffer } from "../../../../util/polusBuffer" ; import { PacketHandler } from "../../../packet" ; import { StateByte , StateByteInterface , } from "../../../packetElements/stateByte" ; export interface VotingCompletePacket { StatesLength ? : number ; States : StateByteInterface [ ] ; ExiledPlayerPlayerID : number ; IsTie : boolean ; } export const VotingComplete = { parse ( packet ) { let data = { StatesLength : packet . readVarInt ( ) , States : [ ] , ExiledPlayerPlayerID : 0 , IsTie : false , } ; data . States = new Array ( data . StatesLength ) ; for ( let i = 0 ; i < data . States . length ; i ++ ) { data . States [ i ] = StateByte . parse ( packet . readU8 ( ) ) ; } data . ExiledPlayerPlayerID = packet . readU8 ( ) ; data . IsTie = packet . readBoolean ( ) ; return data ; } , serialize ( packet ) { let buf = new PolusBuffer ( ) ; buf . writeVarInt ( packet . States . length ) ; for ( var i = 0 ; i < packet . States . length ; i ++ ) { buf . writeU8 ( StateByte . serialize ( packet . States [ i ] ) ) ; } buf . writeU8 ( packet . ExiledPlayerPlayerID ) ; buf . writeBoolean ( packet . IsTie ) ; return buf ; } , } ;