From 97a4c1068c45ce1594b69775857663a32fa51b6b Mon Sep 17 00:00:00 2001 From: liangtongchuan Date: Thu, 3 Dec 2020 21:37:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BB=E5=AE=9D=EF=BC=9A=E8=B8=A2=E6=8E=89?= =?UTF-8?q?=E4=BA=BA=E4=B9=8B=E5=90=8E=E5=86=8D=E8=A1=A5=E5=85=85=E6=9C=BA?= =?UTF-8?q?=E5=99=A8=E4=BA=BA=E7=9A=84=E9=80=BB=E8=BE=91=EF=BC=9B=E4=BF=AE?= =?UTF-8?q?=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../battle/handler/comBattleHandler.ts | 47 ++++++++++++++++--- 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/game-server/app/servers/battle/handler/comBattleHandler.ts b/game-server/app/servers/battle/handler/comBattleHandler.ts index c4067ba26..97890399e 100644 --- a/game-server/app/servers/battle/handler/comBattleHandler.ts +++ b/game-server/app/servers/battle/handler/comBattleHandler.ts @@ -2,7 +2,7 @@ * @Author: 梁桐川 * @Date: 2020-11-30 15:05:48 * @Last Modified by: 梁桐川 - * @Last Modified time: 2020-12-03 16:50:27 + * @Last Modified time: 2020-12-03 21:36:00 */ import { IT_TYPE, GOLD_COST_RATIO, CURRENCY_BY_TYPE, CURRENCY_TYPE, COM_TEAM_STATUS, COM_BTL_CONST } from './../../../consts/consts'; import { getGoodById, getBossHpByBlueprtId, getComBtlSetByQuality, getBlueprtComposeByQuality, getBluePrtByQuality, getWarById, getWarIdByBlueprtId } from '../../../pubUtils/gamedata'; @@ -440,6 +440,34 @@ export class ComBattleHandler { } channel.pushMessage('onLeaveTeam', {teamCode, roleId: roleIdToRm}); clearComBtlTimer(teamCode, this.teamDisTimer); // 移除队员停止解散计时 + let thiz = this; + setTimeout(async () => { + let team = thiz.teamMap.get(teamCode); + if (team && team.roleIds && team.status === COM_TEAM_STATUS.DEFAULT && team.roleIds.length < 3) { + let roleSt: RoleStatus; + for (let st of team.roleStatus) { + if (st.roleId === roleId) { + roleSt = st; + } + } + if (!roleSt) return; + let { topFiveCe, lv } = roleSt; + let { robotStArr, robotIdArr } = getRandComBtlRobots(topFiveCe, lv, 3 - team.roleIds.length); + team.roleIds = team.roleIds.concat(robotIdArr); + team.roleStatus = team.roleStatus.concat(robotStArr); + for (let st of robotStArr) { + await ComBattleTeamModel.addRole(teamCode, st); + } + channel.pushMessage('onTeamJoin', {teamInfo: team}); + } + // TODO: 代码抽象 + if (team && team.roleIds && team.roleIds.length === 3) { + let timer = setTimeout(async () => { + thiz.dismiss({teamCode}, session); + }, COM_BTL_CONST.CAP_START_TIME); + thiz.teamDisTimer.set(teamCode, timer); + } + }, COM_BTL_CONST.ASSIST_TIME); return resResult(STATUS.SUCCESS); } @@ -505,6 +533,7 @@ export class ComBattleHandler { let team = await ComBattleTeamModel.syncTeamData({teamCode, status: COM_TEAM_STATUS.LOOSE, roleStatus: teamStatus.roleStatus, bossHpArr: teamStatus.bossHpArr}); if (!team) return resResult(STATUS.COM_BATTLE_RESULT_ERR); channel.pushMessage('onTeamComplete', {teamCode, result: false}); + thiz.teamMap.delete(teamCode); } }, COM_BTL_CONST.BTL_TIME_LMT); return resResult(STATUS.SUCCESS); @@ -524,7 +553,7 @@ export class ComBattleHandler { if (!teamStatus || !teamStatus.roleIds || teamStatus.roleIds.indexOf(roleId) === -1) return resResult(STATUS.COM_BATTLE_TEAM_INVALID); if (teamStatus.status !== COM_TEAM_STATUS.FIGHTING) return resResult(STATUS.COM_BATTLE_NOT_START); for (let st of teamStatus.roleStatus) { - if (!st.heroes || st.heroes.length === 0) { + if (st.roleId === roleId && (!st.heroes || st.heroes.length === 0)) { return resResult(STATUS.COM_BATTLE_HEROES_ERR); } } @@ -586,6 +615,7 @@ export class ComBattleHandler { channel.pushMessage('onTeammateAct', {teamCode, bossCurHp: teamStatus.bossCurHp, bossHpArr: teamStatus.bossHpArr, roleStatus}); // 判断战斗是否结束 let battleSt = checkComBattleResult(teamStatus); + teamStatus.status = battleSt; if (battleSt === COM_TEAM_STATUS.WIN || battleSt === COM_TEAM_STATUS.LOOSE) { let result = battleSt === COM_TEAM_STATUS.WIN; if (result) { @@ -599,12 +629,13 @@ export class ComBattleHandler { let team = await ComBattleTeamModel.syncTeamData({teamCode, status: battleSt, roleStatus: teamStatus.roleStatus, bossHpArr: teamStatus.bossHpArr}); if (!team) return resResult(STATUS.COM_BATTLE_RESULT_ERR); - // 战斗胜利扣减藏宝图 + // 战斗胜利队长扣减藏宝图 if (result) { let res = await ItemModel.decreaseItems(teamStatus.capId, [{id: teamStatus.blueprtId, count: 1}]); if (!res) return resResult(STATUS.COM_BATTLE_BLUEPRT_NOT_ENOUGH); } channel.pushMessage('onTeamComplete', {teamCode, result}); + this.teamMap.delete(teamCode); } return resResult(STATUS.SUCCESS); } @@ -681,9 +712,13 @@ export class ComBattleHandler { async getComBtlStatus(msg: {teamCode: string}, session: BackendSession) { let { teamCode } = msg; - let team = await ComBattleTeamModel.getTeamByCode(teamCode); - let { roleStatus, status, bossHpArr } = team; - + let roleStatus, status, bossHpArr; + let memTeam = this.teamMap.get(teamCode); + if (memTeam) { + ({ roleStatus, status, bossHpArr } = memTeam); + } else { + ({ roleStatus, status, bossHpArr } = await ComBattleTeamModel.getTeamByCode(teamCode)); + } return resResult(STATUS.SUCCESS, { teamInfo: {status, teamCode, roleStatus, bossHpArr} }); }