import GameClientPacket from "./GameClientPacket" ; export default abstract class AbstractMessagePacket extends GameClientPacket { static readonly TYPE_SYSTEM_STRING : number = 13 ; static readonly TYPE_PLAYER_NAME : number = 12 ; static readonly TYPE_DOOR_NAME : number = 11 ; static readonly TYPE_INSTANCE_NAME : number = 10 ; static readonly TYPE_ELEMENT_NAME : number = 9 ; static readonly TYPE_ZONE_NAME : number = 7 ; static readonly TYPE_LONG_NUMBER : number = 6 ; static readonly TYPE_CASTLE_NAME : number = 5 ; static readonly TYPE_SKILL_NAME : number = 4 ; static readonly TYPE_ITEM_NAME : number = 3 ; static readonly TYPE_NPC_NAME : number = 2 ; static readonly TYPE_INT_NUMBER : number = 1 ; static readonly TYPE_TEXT : number = 0 ; messageId ! : number ; messageParams = new Array < any > ( ) ; readMe ( ) { this . messageId = this . readD ( ) ; const _paramsLength = this . readD ( ) ; for ( let i = 0 ; i < _paramsLength ; i ++ ) { const _paramType = this . readD ( ) ; switch ( _paramType ) { case AbstractMessagePacket . TYPE_TEXT : case AbstractMessagePacket . TYPE_PLAYER_NAME : this . messageParams . push ( this . readS ( ) ) ; break ; case AbstractMessagePacket . TYPE_LONG_NUMBER : this . messageParams . push ( this . readQ ( ) ) ; break ; case AbstractMessagePacket . TYPE_ITEM_NAME : case AbstractMessagePacket . TYPE_CASTLE_NAME : case AbstractMessagePacket . TYPE_INT_NUMBER : case AbstractMessagePacket . TYPE_NPC_NAME : case AbstractMessagePacket . TYPE_ELEMENT_NAME : case AbstractMessagePacket . TYPE_SYSTEM_STRING : case AbstractMessagePacket . TYPE_INSTANCE_NAME : case AbstractMessagePacket . TYPE_DOOR_NAME : this . messageParams . push ( this . readD ( ) ) ; break ; case AbstractMessagePacket . TYPE_SKILL_NAME : this . messageParams . push ( [ this . readD ( ) , this . readD ( ) ] ) ; break ; case AbstractMessagePacket . TYPE_ZONE_NAME : this . messageParams . push ( [ this . readD ( ) , this . readD ( ) , this . readD ( ) ] ) ; break ; default : this . logger . warn ( "Unknown message packet type: " + _paramType . toString ( 16 ) ) ; return ; } } } }