Files
ZYZ/game-server/app/servers/role/handler/heroHandler.ts
2020-12-08 19:36:02 +08:00

32 lines
1002 B
TypeScript

import {Application, BackendSession, createTcpMailBox, ChannelService} from 'pinus';
import { handleCost } from '../../../services/rewardService';
import { resResult } from '../../../pubUtils/util';
import { STATUS } from '../../../consts/statusCode';
export default function(app: Application) {
return new HeroHandler(app);
}
export class HeroHandler {
constructor(private app: Application) {
}
private channelService: ChannelService = this.app.get('channelService');
public async test(msg: { id: number, count: number}, session: BackendSession) {
let roleId: string = session.get('roleId');
let roleName: string = session.get('roleName');
let sid: string = session.get('sid');
let {id, count} = msg;
let result = await handleCost(this.channelService, roleId, sid, [{id, count}] );
if(!result) {
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
}
return resResult(STATUS.SUCCESS);
}
}