寻宝:踢掉人之后再补充机器人的逻辑;修复bug
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
* @Author: 梁桐川
|
* @Author: 梁桐川
|
||||||
* @Date: 2020-11-30 15:05:48
|
* @Date: 2020-11-30 15:05:48
|
||||||
* @Last Modified by: 梁桐川
|
* @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 { 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';
|
import { getGoodById, getBossHpByBlueprtId, getComBtlSetByQuality, getBlueprtComposeByQuality, getBluePrtByQuality, getWarById, getWarIdByBlueprtId } from '../../../pubUtils/gamedata';
|
||||||
@@ -440,6 +440,34 @@ export class ComBattleHandler {
|
|||||||
}
|
}
|
||||||
channel.pushMessage('onLeaveTeam', {teamCode, roleId: roleIdToRm});
|
channel.pushMessage('onLeaveTeam', {teamCode, roleId: roleIdToRm});
|
||||||
clearComBtlTimer(teamCode, this.teamDisTimer); // 移除队员停止解散计时
|
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);
|
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});
|
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);
|
if (!team) return resResult(STATUS.COM_BATTLE_RESULT_ERR);
|
||||||
channel.pushMessage('onTeamComplete', {teamCode, result: false});
|
channel.pushMessage('onTeamComplete', {teamCode, result: false});
|
||||||
|
thiz.teamMap.delete(teamCode);
|
||||||
}
|
}
|
||||||
}, COM_BTL_CONST.BTL_TIME_LMT);
|
}, COM_BTL_CONST.BTL_TIME_LMT);
|
||||||
return resResult(STATUS.SUCCESS);
|
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 || !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);
|
if (teamStatus.status !== COM_TEAM_STATUS.FIGHTING) return resResult(STATUS.COM_BATTLE_NOT_START);
|
||||||
for (let st of teamStatus.roleStatus) {
|
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);
|
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});
|
channel.pushMessage('onTeammateAct', {teamCode, bossCurHp: teamStatus.bossCurHp, bossHpArr: teamStatus.bossHpArr, roleStatus});
|
||||||
// 判断战斗是否结束
|
// 判断战斗是否结束
|
||||||
let battleSt = checkComBattleResult(teamStatus);
|
let battleSt = checkComBattleResult(teamStatus);
|
||||||
|
teamStatus.status = battleSt;
|
||||||
if (battleSt === COM_TEAM_STATUS.WIN || battleSt === COM_TEAM_STATUS.LOOSE) {
|
if (battleSt === COM_TEAM_STATUS.WIN || battleSt === COM_TEAM_STATUS.LOOSE) {
|
||||||
let result = battleSt === COM_TEAM_STATUS.WIN;
|
let result = battleSt === COM_TEAM_STATUS.WIN;
|
||||||
if (result) {
|
if (result) {
|
||||||
@@ -599,12 +629,13 @@ export class ComBattleHandler {
|
|||||||
let team = await ComBattleTeamModel.syncTeamData({teamCode, status: battleSt, roleStatus: teamStatus.roleStatus, bossHpArr: teamStatus.bossHpArr});
|
let team = await ComBattleTeamModel.syncTeamData({teamCode, status: battleSt, roleStatus: teamStatus.roleStatus, bossHpArr: teamStatus.bossHpArr});
|
||||||
if (!team) return resResult(STATUS.COM_BATTLE_RESULT_ERR);
|
if (!team) return resResult(STATUS.COM_BATTLE_RESULT_ERR);
|
||||||
|
|
||||||
// 战斗胜利扣减藏宝图
|
// 战斗胜利队长扣减藏宝图
|
||||||
if (result) {
|
if (result) {
|
||||||
let res = await ItemModel.decreaseItems(teamStatus.capId, [{id: teamStatus.blueprtId, count: 1}]);
|
let res = await ItemModel.decreaseItems(teamStatus.capId, [{id: teamStatus.blueprtId, count: 1}]);
|
||||||
if (!res) return resResult(STATUS.COM_BATTLE_BLUEPRT_NOT_ENOUGH);
|
if (!res) return resResult(STATUS.COM_BATTLE_BLUEPRT_NOT_ENOUGH);
|
||||||
}
|
}
|
||||||
channel.pushMessage('onTeamComplete', {teamCode, result});
|
channel.pushMessage('onTeamComplete', {teamCode, result});
|
||||||
|
this.teamMap.delete(teamCode);
|
||||||
}
|
}
|
||||||
return resResult(STATUS.SUCCESS);
|
return resResult(STATUS.SUCCESS);
|
||||||
}
|
}
|
||||||
@@ -681,9 +712,13 @@ export class ComBattleHandler {
|
|||||||
|
|
||||||
async getComBtlStatus(msg: {teamCode: string}, session: BackendSession) {
|
async getComBtlStatus(msg: {teamCode: string}, session: BackendSession) {
|
||||||
let { teamCode } = msg;
|
let { teamCode } = msg;
|
||||||
let team = await ComBattleTeamModel.getTeamByCode(teamCode);
|
let roleStatus, status, bossHpArr;
|
||||||
let { roleStatus, status, bossHpArr } = team;
|
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} });
|
return resResult(STATUS.SUCCESS, { teamInfo: {status, teamCode, roleStatus, bossHpArr} });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user