添加一个物品消耗通用方法
This commit is contained in:
@@ -646,7 +646,7 @@ export class ComBattleHandler {
|
||||
// 战斗胜利队长扣减藏宝图
|
||||
if (result && teamStatus.capId != 'robot') {
|
||||
let res = await ItemModel.decreaseItems(teamStatus.capId, [{id: teamStatus.blueprtId, count: 1}]);
|
||||
if (!res) return resResult(STATUS.COM_BATTLE_BLUEPRT_NOT_ENOUGH);
|
||||
if (res.hasError) return resResult(STATUS.COM_BATTLE_BLUEPRT_NOT_ENOUGH);
|
||||
}
|
||||
channel.pushMessage('onTeamComplete', {teamCode, result});
|
||||
this.teamMap.delete(teamCode);
|
||||
@@ -810,7 +810,7 @@ export class ComBattleHandler {
|
||||
});
|
||||
// 消耗藏宝图和寻宝币
|
||||
const rec = await ItemModel.decreaseItems(roleId, original);
|
||||
if(!rec) {
|
||||
if(rec.hasError) {
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user