关卡:星级记录

This commit is contained in:
luying
2021-11-03 11:22:55 +08:00
parent 8afe9150f2
commit 158ded6501
6 changed files with 51 additions and 38 deletions
@@ -12,7 +12,7 @@ import { STATUS } from '../../../consts/statusCode';
import { resResult } from '../../../pubUtils/util';
import { RoleModel } from '../../../db/Role';
import { RScriptRecordModel } from '../../../db/RScriptRecord';
import { updateWarStar, checkBattleHeroes, roleLevelup, getBattleList } from '../../../services/normalBattleService';
import { checkBattleHeroes, roleLevelup, getBattleList, calculateWarStar } from '../../../services/normalBattleService';
import { checkDungeonNum, checkDungeonAndIncrease, saveDungeonFirst } from '../../../services/dungeonService';
// import { switchOnFunc } from '../../../services/funcSwitchService';
import { gameData } from '../../../pubUtils/data';
@@ -123,8 +123,8 @@ export class NormalBattleHandler {
}
// 关卡结算,记录使用的武将,获得奖励
async battleEnd(msg: { battleCode: string, battleId: number, isSuccess: boolean, star: number, heroes: Array<any>, activityId: number, pageIndex: number }, session: BackendSession) {
const { battleCode, battleId, isSuccess, heroes = [], star, activityId, pageIndex } = msg;
async battleEnd(msg: { battleCode: string, battleId: number, isSuccess: boolean, stars: number[], heroes: Array<any>, activityId: number, pageIndex: number }, session: BackendSession) {
const { battleCode, battleId, isSuccess, heroes = [], stars = [], activityId, pageIndex } = msg;
let roleId = session.get('roleId');
let roleName = session.get('roleName');
let sid = session.get('sid');
@@ -169,7 +169,7 @@ export class NormalBattleHandler {
let dungeonNum = {};
if (warInfo.warType == WAR_TYPE.DAILY) {
let checkResult = await checkDailyAndIncrease(roleId, [{ id: battleId, star, warType: warInfo.warType }, ...warStar], battleId, 1, false);
let checkResult = await checkDailyAndIncrease(roleId, warStar, battleId, 1, false, stars);
if (checkResult.status == -1) {
return checkResult.resResult;
}
@@ -228,6 +228,8 @@ export class NormalBattleHandler {
skipReward = !isFirst;
}
}
let curWarStar = warStar.find(cur => cur.id == battleId);
let { newWarStars, newStar } = calculateWarStar(warStar, battleId, stars);
if (isSuccess) { // 挑战胜利
// 是否首通
@@ -239,11 +241,13 @@ export class NormalBattleHandler {
pushVestigeFirstMsg(roleId, roleName, serverId, warInfo.warType, warInfo.war_id);
}
// 是否首次3星
if (star == 3 && (!condition1 || condition1.star != 3)) {
if (newStar == 3 && (!condition1 || condition1.star != 3)) {
warReward.setCondition(1, true);
}
await updateWarStar(roleId, battleId, warInfo.warType, star);
if (newStar > (curWarStar?.star||0)) {
await RoleModel.updateRoleInfo(roleId, { warStar: newWarStars });
}
}
let reward = null;
@@ -252,13 +256,13 @@ export class NormalBattleHandler {
}
const updateResult = await BattleRecordModel.updateBattleRecordByCode(battleCode, {
$set: { status: isSuccess ? 1 : 2, star, record: { heroes } }
$set: { status: isSuccess ? 1 : 2, star: newStar, stars, record: { heroes } }
}, true);
let { status } = updateResult;
let actordata = await roleLevelup(KING_EXP_RATIO_TYPE.BATTLE, roleId, isSuccess ? warInfo.kingExp : 0, session);// 主公升级经验
await checkTaskInBattleEnd(serverId, roleId, sid, battleId, dbHeroes, star);
await checkTaskInBattleEnd(serverId, roleId, sid, battleId, dbHeroes, newStar);
// 返回值:
// towerStatus: false-本层未通过, true-本层已通过
return resResult(STATUS.SUCCESS, {