寻宝:扣减藏宝图推送;倒计时解散或加入队伍的判断条件
This commit is contained in:
@@ -14,7 +14,7 @@ import { Application, BackendSession } from 'pinus';
|
||||
import { resResult, getRandomByLen, calculateNum, getRandValue, ratioReward, reduceCe, getRandValueByMinMax } from '../../../pubUtils/util';
|
||||
import { RoleStatus } from '../../../db/ComBattleTeam';
|
||||
import { ItemModel } from '../../../db/Item';
|
||||
import { handleFixedReward, addItems, handleCost } from '../../../services/rewardService';
|
||||
import { handleFixedReward, addItems, handleCost, decreaseItems } from '../../../services/rewardService';
|
||||
import { checkRoleInQueue, getTeamSearchByQuality, rmRoleFromQueue, setTeamSearchReq } from '../../../services/redisService';
|
||||
import { transBossHpArr } from '../../../services/battleService';
|
||||
import { getRandBlueprtId, getRandComBtlRobots, checkComBattleResult, clearComBtlTimer, getRealReward, getAssistTimesByQuality, getFrd, updateRobotHurt, updateRobotHurtByTime, comBtlLvInvalid, clearRobotHurtTimer, setDismissTimer, dismissTeam } from '../../../services/comBattleService';
|
||||
@@ -173,14 +173,16 @@ export class ComBattleHandler {
|
||||
for(let robotIdx = 0; robotIdx < robotCnt; robotIdx++) {
|
||||
const joinTime = getRandValueByMinMax(COM_BTL_CONST.MIN_CAP_TIME, COM_BTL_CONST.MAX_CAP_TIME, 0);
|
||||
setTimeout(async () => {
|
||||
let { robotStArr, robotIdArr } = getRandComBtlRobots(topFiveCe, teamStatus.ceLimit, lv, 1);
|
||||
teamStatus.roleIds = teamStatus.roleIds.concat(robotIdArr);
|
||||
teamStatus.roleStatus = teamStatus.roleStatus.concat(robotStArr);
|
||||
for (let st of robotStArr) {
|
||||
await ComBattleTeamModel.addRole(teamCode, st);
|
||||
if (teamStatus.status === COM_TEAM_STATUS.DEFAULT && teamStatus.roleIds.length < 3) {
|
||||
let { robotStArr, robotIdArr } = getRandComBtlRobots(topFiveCe, teamStatus.ceLimit, lv, 1);
|
||||
teamStatus.roleIds = teamStatus.roleIds.concat(robotIdArr);
|
||||
teamStatus.roleStatus = teamStatus.roleStatus.concat(robotStArr);
|
||||
for (let st of robotStArr) {
|
||||
await ComBattleTeamModel.addRole(teamCode, st);
|
||||
}
|
||||
channel.pushMessage('onTeamJoin', resResult(STATUS.SUCCESS, {teamInfo: teamStatus}));
|
||||
setDismissTimer(teamStatus, thiz.teamMap, roleId, thiz.teamDisTimer, thiz.app);
|
||||
}
|
||||
channel.pushMessage('onTeamJoin', resResult(STATUS.SUCCESS, {teamInfo: teamStatus}));
|
||||
setDismissTimer(teamStatus, thiz.teamMap, roleId, thiz.teamDisTimer, thiz.app);
|
||||
}, joinTime);
|
||||
}
|
||||
}
|
||||
@@ -476,22 +478,6 @@ export class ComBattleHandler {
|
||||
let teamStatus = this.teamMap.get(teamCode);
|
||||
let result = await dismissTeam(teamStatus, this.teamMap, roleId, this.teamDisTimer, this.app);
|
||||
return result;
|
||||
|
||||
if (!teamStatus || !teamStatus.roleIds || teamStatus.roleIds.indexOf(roleId) === -1) return resResult(STATUS.COM_BATTLE_TEAM_INVALID);
|
||||
if (roleId !== teamStatus.capId) return resResult(STATUS.COM_BATTLE_CAP_ONLY);
|
||||
|
||||
let team = await ComBattleTeamModel.removeTeam(teamCode);
|
||||
if (!team) return resResult(STATUS.COM_BATTLE_DISSMISS_ERR);
|
||||
|
||||
let rmSt = this.teamMap.delete(teamCode);
|
||||
if (!rmSt) return resResult(STATUS.COM_BATTLE_DISSMISS_ERR);
|
||||
|
||||
let channelService = this.app.get('channelService');
|
||||
let channel = channelService.getChannel(teamCode, false);
|
||||
channel.pushMessage('onTeamDismiss', resResult(STATUS.SUCCESS, {teamCode}));
|
||||
channel.destroy();
|
||||
clearComBtlTimer(teamCode, this.teamDisTimer); // 队伍解散停止解散计时
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -549,6 +535,7 @@ export class ComBattleHandler {
|
||||
*/
|
||||
async action(msg: {teamCode: string, bossHurts: Array<{dataId: number, hurtHp: number}>, killed: Array<number>, curRnd: number}, session: BackendSession) {
|
||||
let roleId = session.get('roleId');
|
||||
let sid = session.get('sid');
|
||||
let { teamCode, killed, bossHurts, curRnd } = msg;
|
||||
let teamStatus = this.teamMap.get(teamCode);
|
||||
if (!teamStatus || !teamStatus.roleIds || teamStatus.roleIds.indexOf(roleId) === -1) return resResult(STATUS.COM_BATTLE_TEAM_INVALID);
|
||||
@@ -616,8 +603,8 @@ export class ComBattleHandler {
|
||||
|
||||
// 战斗胜利队长扣减藏宝图
|
||||
if (result && teamStatus.capId != 'robot') {
|
||||
let res = await ItemModel.decreaseItems(teamStatus.capId, [{id: teamStatus.blueprtId, count: 1}]);
|
||||
if (res.hasError) return resResult(STATUS.COM_BATTLE_BLUEPRT_NOT_ENOUGH);
|
||||
let res = await decreaseItems(teamStatus.capId, sid, [{id: teamStatus.blueprtId, count: 1}]);
|
||||
if (res === true) return resResult(STATUS.COM_BATTLE_BLUEPRT_NOT_ENOUGH);
|
||||
}
|
||||
channel.pushMessage('onTeamComplete', resResult(STATUS.SUCCESS, {teamCode, result}));
|
||||
this.teamMap.delete(teamCode);
|
||||
|
||||
Reference in New Issue
Block a user