新武将:关卡

This commit is contained in:
luying
2022-08-01 19:55:11 +08:00
parent 30ab30c97d
commit e2dd6852af
5 changed files with 51 additions and 61 deletions

View File

@@ -141,15 +141,14 @@ export class NormalBattleHandler {
}
// 关卡结算,记录使用的武将,获得奖励
async battleEnd(msg: { battleCode: string, battleId: number, isSuccess: boolean, stars: number[], heroes: number[], activityId: number, pageIndex: number }, session: BackendSession) {
const { battleCode, battleId, isSuccess, heroes = [], stars = [], activityId, pageIndex } = msg;
async battleEnd(msg: { battleCode: string, battleId: number, isSuccess: boolean, stars: number[], heroes: number[], activityId: number }, session: BackendSession) {
const { battleCode, battleId, isSuccess, heroes = [], stars = [], activityId } = msg;
let roleId = session.get('roleId');
let roleName = session.get('roleName');
let sid = session.get('sid');
let ip = session.get('ip');
let serverId = session.get('serverId');
let skipReward = false;//是否跳过奖励结算
let warInfo = gameData.war.get(battleId);
if (!warInfo) {
return resResult(STATUS.BATTLE_MISS_INFO);
@@ -158,6 +157,7 @@ export class NormalBattleHandler {
if (warInfo.warType == WAR_TYPE.COM_BATTLE) {
return resResult(STATUS.BATTLE_END_WRONG_TYPE);
}
console.log('####### warInfo.warType', warInfo.warType)
const BattleRecord = await BattleRecordModel.getBattleRecordByCode(battleCode, true);
if (!BattleRecord || BattleRecord.status != 0) {
@@ -180,13 +180,16 @@ export class NormalBattleHandler {
}
let { warStar } = role;
let isFirst = warStar.findIndex(cur => cur.id == battleId) == -1;
let curWarStar = warStar.find(cur => cur.id == battleId);
let { newWarStars, newStar } = calculateWarStar(warStar, battleId, stars);
let warReward = new WarReward(roleId, roleName, sid, battleId, isSuccess);
let dailyNum = {};
let towerStatus = null;
let dungeonNum = {};
if(warInfo.warType == WAR_TYPE.NORMAL || warInfo.warType == WAR_TYPE.MAIN_ELITE) {
let isFirst = warStar.findIndex(cur => cur.id == battleId) == -1;
if(!isFirst) {
let checkResult = await checkWarCountAndInc(battleId, isSuccess?1:0, role, false);
if (checkResult.code != 0) {
@@ -252,22 +255,19 @@ export class NormalBattleHandler {
await challengeDailyGK(serverId, roleId, activityId, battleId)
}
} else if (warInfo.warType == WAR_TYPE.ACT_NEW_HERO_GK) {
console.log('##### warInfo.warType', warInfo.warType, isSuccess)
if (isSuccess) {
let isFirst = await challengeNewHeroGK(serverId, roleId, activityId, pageIndex, battleId)
skipReward = !isFirst;
isFirst = await challengeNewHeroGK(serverId, roleId, activityId, battleId)
}
} else if (warInfo.warType == WAR_TYPE.ACT_TREASURE_HUNT) {
if(isSuccess) {
await treasureHuntChallengeConsume(serverId, roleId, sid);
}
}
let curWarStar = warStar.find(cur => cur.id == battleId);
let { newWarStars, newStar } = calculateWarStar(warStar, battleId, stars);
if (isSuccess) { // 挑战胜利
// 是否首通
let condition1 = warStar.find(cur => cur.id == battleId);
if (!condition1) {
if (!isFirst) {
// await switchOnFunc(roleId, FUNC_OPT_TYPE.BATTLE_END, battleId, session);
warReward.setCondition(0, true);
reportTAEvent(roleId, TA_EVENT.GK_FIRST_PASS, { war_id: battleId, war_type: getWarTypeName(warInfo.warType), pass_time: Date.now(), pass_duration: nowSeconds() - getSeconds(createdAt), hero_list: dbHeroes });
@@ -275,7 +275,7 @@ export class NormalBattleHandler {
pushVestigeFirstMsg(roleId, roleName, serverId, warInfo.warType, warInfo.war_id);
}
// 是否首次3星
if (newStar == 3 && (!condition1 || condition1.star != 3)) {
if (newStar == 3 && (!isFirst || curWarStar.star != 3)) {
warReward.setCondition(1, true);
}
@@ -284,10 +284,7 @@ export class NormalBattleHandler {
}
}
let reward = null;
if (!skipReward) {
reward = await warReward.saveReward(1);
}
let reward = await warReward.saveReward(1);
const updateResult = await BattleRecordModel.updateBattleRecordByCode(battleCode, {
$set: { status: isSuccess ? 1 : 2, star: newStar, stars, record: { heroes } }