Files
rougelike-demo/client/assets/scripts/App/Msg/Pair/MoveMessagePair.ts

23 lines
725 B
TypeScript
Raw Normal View History

import { MsgReqMove } from '../../../Shared/protocols/MsgReqMove';
import { MsgResMove } from '../../../Shared/protocols/MsgResMove';
import { MessagePair } from '../MessagePairBase';
/**
*
*/
export class MoveMessagePair extends MessagePair<MsgReqMove, MsgResMove> {
readonly requestName = 'ReqMove';
readonly responseName = 'ResMove';
isValidRequest(msg: any): msg is MsgReqMove {
return msg &&
typeof msg.x === 'number' &&
typeof msg.y === 'number';
}
isValidResponse(msg: any): msg is MsgResMove {
return msg &&
typeof msg.success === 'boolean' &&
typeof msg.message === 'string';
}
}