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';
    }
}