寻宝:修改匹配后的channel处理;掉落中增加字段;修改伤害计算
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* @Author: 梁桐川
|
||||
* @Date: 2020-11-30 15:05:48
|
||||
* @Last Modified by: 梁桐川
|
||||
* @Last Modified time: 2020-12-02 13:08:30
|
||||
* @Last Modified time: 2020-12-02 17:33:14
|
||||
*/
|
||||
import { COM_BATTLE_ASSIST_TIME, COM_BATTLE_ROBOT_ROUND_LMT, COM_BATTLE_ROBOT_HURT_RATIO, COM_BATTLE_ROBOT_HURT_CH_RATIO, COM_TEAM_STATUS } from './../../../consts/consts';
|
||||
import { IT_TYPE, GOLD_COST_RATIO, CURRENCY_BY_TYPE, CURRENCY_TYPE, COM_BATTLE_CAP_TIME, COM_BATTLE_TIME_LMT, COM_BATTLE_CAP_START_TIME, COM_BATTLE_ASSIST_REWARD_RATIO } from './../../../consts/consts';
|
||||
@@ -18,7 +18,7 @@ import { ItemModel } from '../../../db/Item';
|
||||
import { handleFixedReward, handleReward } from '../../../services/rewardService';
|
||||
import { checkRoleInQueue, getTeamSearchByQuality, rmRoleFromQueue, setTeamSearchReq } from '../../../services/redisService';
|
||||
import { transBossHpArr } from '../../../services/battleService';
|
||||
import { getRandBlueprtId, getRandComBtlRobots, checkComBattleResult, clearComBtlTimer } from '../../../services/comBattleService';
|
||||
import { getRandBlueprtId, getRandComBtlRobots, checkComBattleResult, clearComBtlTimer, getRealReward } from '../../../services/comBattleService';
|
||||
import { setAp } from '../../../services/actionPointService';
|
||||
import { roleLevelup } from '../../../services/normalBattleService';
|
||||
|
||||
@@ -140,10 +140,8 @@ export class ComBattleHandler {
|
||||
let channelService = this.app.get('channelService');
|
||||
let channel = channelService.getChannel(teamCode, true);
|
||||
let users = channel.getMembers();
|
||||
for (let roleId of roleIds) {
|
||||
if (users.indexOf(roleId) === -1) {
|
||||
channel.add(roleId, sid);
|
||||
}
|
||||
if (users.indexOf(roleId) === -1) {
|
||||
channel.add(roleId, sid);
|
||||
}
|
||||
let uids = [];
|
||||
uids.push({roleId, sid});
|
||||
@@ -151,6 +149,10 @@ export class ComBattleHandler {
|
||||
for (let teammate of teammates) {
|
||||
let { roleId, sid } = teammate;
|
||||
uids.push({uid: roleId, sid});
|
||||
let users = channel.getMembers();
|
||||
if (users.indexOf(roleId) === -1) {
|
||||
channel.add(roleId, sid);
|
||||
}
|
||||
}
|
||||
channelService.pushMessageByUids('onTeamJoin', {teamInfo: comTeam}, uids);
|
||||
}
|
||||
@@ -204,7 +206,7 @@ export class ComBattleHandler {
|
||||
}
|
||||
}
|
||||
|
||||
const team = await ComBattleTeamModel.getOneTeamByQualityAndSt(qualityArr, COM_TEAM_STATUS.DEFAULT, topFiveCe);
|
||||
const team = await ComBattleTeamModel.getOtherTeamByQualityAndSt(roleId, qualityArr, COM_TEAM_STATUS.DEFAULT, topFiveCe);
|
||||
// TODO: 有匹配的队伍还需要重新 joinTeam 加入,有失败可能,体验不好,需优化
|
||||
if (team && team.roleIds.length < 3 && team.status === COM_TEAM_STATUS.DEFAULT && team.roleIds.indexOf(roleId) === -1) {
|
||||
return resResult(STATUS.SUCCESS, {teamCode: team.teamCode});
|
||||
@@ -292,16 +294,16 @@ export class ComBattleHandler {
|
||||
return resResult(STATUS.COM_BATTLE_JOIN_ERR);
|
||||
}
|
||||
|
||||
// 推送加入信息给其他玩家
|
||||
// 推送队伍信息给所有玩家
|
||||
let channelService = this.app.get('channelService');
|
||||
let channel = channelService.getChannel(teamCode, false);
|
||||
teamStatus.roleIds.push(roleId);
|
||||
teamStatus.roleStatus.push(roleStatus);
|
||||
channel.pushMessage('onTeamJoin', {teamInfo: teamStatus});
|
||||
let users = channel.getMembers();
|
||||
if (users.indexOf(roleId) === -1) {
|
||||
channel.add(roleId, sid);
|
||||
}
|
||||
channel.pushMessage('onTeamJoin', {teamInfo: teamStatus});
|
||||
|
||||
if (teamStatus.roleIds && teamStatus.roleIds.length === 3) {
|
||||
let thiz = this;
|
||||
@@ -504,7 +506,7 @@ export class ComBattleHandler {
|
||||
if (teamStatus.status === COM_TEAM_STATUS.FIGHTING) {
|
||||
let channelService = thiz.app.get('channelService');
|
||||
let channel = channelService.getChannel(teamCode, false);
|
||||
let team = await ComBattleTeamModel.syncTeamData({teamCode, status: COM_TEAM_STATUS.LOOSE, roleStatus: teamStatus.roleStatus});
|
||||
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});
|
||||
}
|
||||
@@ -561,7 +563,7 @@ export class ComBattleHandler {
|
||||
if (boss.curHp >= eachHurtHp) {
|
||||
robotTotalHurt += eachHurtHp;
|
||||
boss.curHp -= eachHurtHp;
|
||||
} else { // 丢弃溢出的伤害
|
||||
} else if (boss.curHp > 0) { // 丢弃溢出的伤害
|
||||
robotTotalHurt += boss.curHp;
|
||||
boss.curHp = 0;
|
||||
}
|
||||
@@ -586,7 +588,15 @@ export class ComBattleHandler {
|
||||
let battleSt = checkComBattleResult(teamStatus);
|
||||
if (battleSt === COM_TEAM_STATUS.WIN || battleSt === COM_TEAM_STATUS.LOOSE) {
|
||||
let result = battleSt === COM_TEAM_STATUS.WIN;
|
||||
let team = await ComBattleTeamModel.syncTeamData({teamCode, status: battleSt, roleStatus: teamStatus.roleStatus});
|
||||
if (result) {
|
||||
teamStatus.bossHpArr.forEach(bs => {
|
||||
bs.curHp = 0;
|
||||
});
|
||||
teamStatus.roleStatus.forEach(st => {
|
||||
st.fixReward = getRealReward(teamStatus.blueprtId, st);
|
||||
});
|
||||
}
|
||||
let team = await ComBattleTeamModel.syncTeamData({teamCode, status: battleSt, roleStatus: teamStatus.roleStatus, bossHpArr: teamStatus.bossHpArr});
|
||||
if (!team) return resResult(STATUS.COM_BATTLE_RESULT_ERR);
|
||||
|
||||
// 战斗胜利扣减藏宝图
|
||||
@@ -641,14 +651,15 @@ export class ComBattleHandler {
|
||||
let { teamCode } = msg;
|
||||
let team = await ComBattleTeamModel.getTeamByCode(teamCode);
|
||||
if (!team || team.status !== COM_TEAM_STATUS.WIN) return resResult(STATUS.COM_BATTLE_REWARD_ERR);
|
||||
let { roleStatus, blueprtId, status, bossHpArr } = team;
|
||||
let roleSt: RoleStatus = null;
|
||||
team.roleStatus.forEach(st => {
|
||||
roleStatus.forEach(st => {
|
||||
if (st && st.roleId === roleId) {
|
||||
roleSt = st;
|
||||
}
|
||||
});
|
||||
if (roleSt.gotReward) return resResult(STATUS.COM_BATTLE_REWARDED);
|
||||
let warInfo = getWarById(getWarIdByBlueprtId(team.blueprtId));
|
||||
let warInfo = getWarById(getWarIdByBlueprtId(blueprtId));
|
||||
if (!warInfo) return resResult(STATUS.BATTLE_MISS_INFO);
|
||||
|
||||
if(!warInfo.hasOwnProperty('cost')) {
|
||||
@@ -660,19 +671,12 @@ export class ComBattleHandler {
|
||||
if(!apJson) {
|
||||
return resResult(STATUS.BATTLE_ACTION_POINT_LACK);
|
||||
}
|
||||
let fixRewardStr = warInfo['fixReward'];
|
||||
if (!roleSt.isCap) {
|
||||
if (roleSt.isFrd) {
|
||||
fixRewardStr = '&';
|
||||
} else {
|
||||
fixRewardStr = ratioReward(fixRewardStr, COM_BATTLE_ASSIST_REWARD_RATIO);
|
||||
}
|
||||
}
|
||||
|
||||
await ComBattleTeamModel.updateRewardSt(roleId, true);
|
||||
const goods = await handleFixedReward(roleId, roleName, fixRewardStr, 1);
|
||||
const goods = await handleFixedReward(roleId, roleName, roleSt.fixReward, 1);
|
||||
let actordata = await roleLevelup(roleId, warInfo.kingExp, this.app, session);// 主公升级经验
|
||||
|
||||
return resResult(STATUS.SUCCESS, { ...goods, ...actordata });
|
||||
return resResult(STATUS.SUCCESS, { ...goods, ...actordata, teamInfo: {status, roleStatus, bossHpArr} });
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user