镇念塔:重复发放奖励

This commit is contained in:
luying
2022-08-31 12:08:57 +08:00
parent 61a3f201e0
commit 7e0ffc3273
3 changed files with 11 additions and 5 deletions
@@ -214,6 +214,9 @@ export class NormalBattleHandler {
return towerEndResult.resResult; return towerEndResult.resResult;
} }
towerStatus = towerEndResult.data.towerStatus; towerStatus = towerEndResult.data.towerStatus;
console.log('##### towerReward', JSON.stringify(towerEndResult.data.towerReward));
if (towerEndResult.data.towerReward) if (towerEndResult.data.towerReward)
warReward.setFixReward(towerEndResult.data.towerReward) warReward.setFixReward(towerEndResult.data.towerReward)
} }
+2 -2
View File
@@ -233,7 +233,7 @@ export async function towerBattleEnd(sid: string, roleId: string, serverId: numb
inc = wars.length == dicTower.warArray.length? 1: 0; inc = wars.length == dicTower.warArray.length? 1: 0;
} }
let newRec = await TowerRecordModel.updateRecord(roleId, towerLv, battleCode, battleId, heroes, inc); let newRec = await TowerRecordModel.updateRecord(roleId, towerLv, battleCode, battleId, heroes, inc);
let towerReward: RewardInter[] = null; let towerReward: RewardInter[] = [];
if (inc === 1) { if (inc === 1) {
let role = await RoleModel.towerLvUp(roleId); let role = await RoleModel.towerLvUp(roleId);
// 更新redis // 更新redis
@@ -242,7 +242,7 @@ export async function towerBattleEnd(sid: string, roleId: string, serverId: numb
await createNewTowerRecord(roleId, role.towerLv); await createNewTowerRecord(roleId, role.towerLv);
const { reward } = gameData.tower.get(role.towerLv - 1); const { reward } = gameData.tower.get(role.towerLv - 1);
if (reward) towerReward = reward; if (reward) towerReward = [...reward];
await checkAndStartHungUp(roleId, roleName, role.towerLv); await checkAndStartHungUp(roleId, roleName, role.towerLv);
// 任务 // 任务
await checkTask(serverId, roleId, sid, TASK_TYPE.BATTLE_TOWER_LV, { towerLv: role.towerLv - 1 }); await checkTask(serverId, roleId, sid, TASK_TYPE.BATTLE_TOWER_LV, { towerLv: role.towerLv - 1 });
+6 -3
View File
@@ -37,9 +37,9 @@ export class WarReward {
this.battleId = battleId; this.battleId = battleId;
this.warInfo = gameData.war.get(battleId); this.warInfo = gameData.war.get(battleId);
let { fixReward, conditionReward, randomReward } = this.warInfo; let { fixReward, conditionReward, randomReward } = this.warInfo;
this.fixReward = fixReward; this.setFixReward(fixReward);
this.conditionReward = conditionReward; this.setConditionReward(conditionReward);
this.randomReward = randomReward; this.setRandomReward(randomReward);
} }
this.condition = new Map(); this.condition = new Map();
@@ -53,6 +53,7 @@ export class WarReward {
public setFixReward(reward: RewardInter[]) { public setFixReward(reward: RewardInter[]) {
for(let r of reward) { for(let r of reward) {
console.log('#####setFixReward', JSON.stringify(r));
this.fixReward.push(r); this.fixReward.push(r);
} }
} }
@@ -83,6 +84,7 @@ export class WarReward {
if(!this.fixReward) return if(!this.fixReward) return
for(let i = 0; i < num; i++) { for(let i = 0; i < num; i++) {
for(let obj of this.fixReward) { for(let obj of this.fixReward) {
console.log('##### handleFixReward', JSON.stringify(obj));
this.rewards.push({type: BATTLE_REWARD_TYPE.FIX_REWARD, times: i +1, ...obj, count: obj.count }); this.rewards.push({type: BATTLE_REWARD_TYPE.FIX_REWARD, times: i +1, ...obj, count: obj.count });
} }
} }
@@ -156,6 +158,7 @@ export class WarReward {
if(combine) { if(combine) {
rewards = combineItems(rewards); rewards = combineItems(rewards);
} }
console.log('##### saveReward', JSON.stringify(rewards))
await addItems(this.roleId, this.roleName, this.sid, rewards, getReasonByWarType(this.warInfo.warType)); await addItems(this.roleId, this.roleName, this.sid, rewards, getReasonByWarType(this.warInfo.warType));
return rewards; return rewards;
} }