关卡:星级结算
This commit is contained in:
@@ -12,7 +12,7 @@ import { addItems } from '../../../services/rewardService';
|
||||
import { getAp, setAp } from '../../../services/actionPointService';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { checkBattleHeroes, roleLevelup } from '../../../services/normalBattleService';
|
||||
import { calculateWarStar, checkBattleHeroes, roleLevelup } from '../../../services/normalBattleService';
|
||||
import { checkActivityTask, checkTask, checkTaskInBattleEnd } from '../../../services/taskService';
|
||||
import { gameData } from '../../../pubUtils/data';
|
||||
import * as dicParam from '../../../pubUtils/dicParam';
|
||||
@@ -177,9 +177,9 @@ export class ExpeditionBattleHandler {
|
||||
* 战斗结算
|
||||
* 结算战斗奖励,更新远征状态
|
||||
*/
|
||||
async battleEnd(msg: { expeditionCode: string, expeditionId: number, battleCode: string, battleId: number, isSuccess: boolean, heroes: Array<{ dataId: number, hp: number, ap: number }>, enemies: Array<{ dataId: number, hp: number, ap: number }>, star: number }, session: BackendSession) {
|
||||
async battleEnd(msg: { expeditionCode: string, expeditionId: number, battleCode: string, battleId: number, isSuccess: boolean, heroes: Array<{ dataId: number, hp: number, ap: number }>, enemies: Array<{ dataId: number, hp: number, ap: number }>, star: number, stars: number[] }, session: BackendSession) {
|
||||
|
||||
const { expeditionCode, battleCode, battleId, expeditionId, isSuccess, heroes = [], star, enemies } = msg;
|
||||
const { expeditionCode, battleCode, battleId, expeditionId, isSuccess, heroes = [], star, stars = [], enemies } = msg;
|
||||
let roleId = session.get('roleId');
|
||||
let roleName = session.get('roleName');
|
||||
const serverId = session.get('serverId');
|
||||
@@ -228,16 +228,24 @@ export class ExpeditionBattleHandler {
|
||||
}, true);
|
||||
// 更新点数
|
||||
role = await RoleModel.increaseExpeditionPoint(roleId, isSuccess ? dicParam.EXPEDITION_CONST.EXPEDITION_CONST_POINTS : 0);
|
||||
let { expeditionPoint = 0 } = role;
|
||||
let { expeditionPoint = 0, warStar = [] } = role;
|
||||
|
||||
// 关卡奖励
|
||||
let warReward = new WarReward(roleId, roleName, sid, battleId, isSuccess);
|
||||
let reward = await warReward.saveReward(1);
|
||||
|
||||
let actordata = await roleLevelup(KING_EXP_RATIO_TYPE.BATTLE, roleId, isSuccess ? warInfo.kingExp : 0, session);// 主公升级经验
|
||||
|
||||
let curWarStar = warStar.find(cur => cur.id == battleId);
|
||||
let { newWarStars, newStar } = calculateWarStar(warStar, battleId, stars);
|
||||
|
||||
if (isSuccess) {
|
||||
// 更新下一关状态
|
||||
await ExpeditionWarRecordModel.updateStatus(expeditionCode, expeditionId + 1, EXPEDITION_WAR_RECORD_STATUS.WAITING);
|
||||
|
||||
if (!curWarStar || newStar > curWarStar.star) {
|
||||
await RoleModel.updateRoleInfo(roleId, { warStar: newWarStars });
|
||||
}
|
||||
}
|
||||
await checkTaskInBattleEnd(serverId, roleId, sid, battleId, dbHeroes, star);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user