修改天梯接口问题,天梯和挂机已测试
This commit is contained in:
@@ -52,7 +52,7 @@ export class NormalBattleHandler {
|
||||
}
|
||||
dailyNum = { type: checkResult.type, count: checkResult.count, sum: checkResult.sum };
|
||||
} else if (warInfo.warType == WAR_TYPE.TOWER) {
|
||||
let checkResult = await checkTowerWar(roleId, battleId);
|
||||
let checkResult = await checkTowerWar(roleId, battleId, heroes);
|
||||
if(checkResult.status) {
|
||||
return {code: 202, data: checkResult.msg}
|
||||
}
|
||||
@@ -138,6 +138,7 @@ export class NormalBattleHandler {
|
||||
let towerRec = null;
|
||||
let towerBonus = null;
|
||||
let towerStatus = null;
|
||||
let towerReward = null;
|
||||
if(warInfo.warType == WAR_TYPE.DAILY) {
|
||||
let checkResult = await checkDailyAndIncrease(roleId, battleId, 1, false);
|
||||
if(checkResult.status == -1) {
|
||||
@@ -155,6 +156,7 @@ export class NormalBattleHandler {
|
||||
towerRec = towerEndResult.data.newRec;
|
||||
towerBonus = towerEndResult.data.bonusReward;
|
||||
towerStatus = towerEndResult.data.towerStatus;
|
||||
towerReward = towerEndResult.data.towerReward;
|
||||
}
|
||||
|
||||
let warReward = new WarReward(roleId, roleName, battleId, isSuccess);
|
||||
@@ -204,7 +206,7 @@ export class NormalBattleHandler {
|
||||
code: 200,
|
||||
data: {
|
||||
battleCode, battleId, status, towerStatus,
|
||||
goods: reward, towerBonus,
|
||||
goods: reward, towerBonus, towerReward,
|
||||
apJson,
|
||||
dailyNum
|
||||
}
|
||||
|
||||
@@ -28,9 +28,13 @@ export class TowerBattleHandler {
|
||||
await RoleModel.towerLvUp(roleId);
|
||||
}
|
||||
let towerRec = await TowerRecordModel.getRecordByLv(roleId, towerLv);
|
||||
console.log(roleId, towerLv, towerRec);
|
||||
if (!towerRec) {
|
||||
// await TowerRecordModel.createRecord({roleId, lv: towerLv, warStatus: []});
|
||||
const towerInfo = getTowerDataByLv(towerLv);
|
||||
const { warIds } = towerInfo;
|
||||
const sts = decodeArrayStr(warIds).map(id => {
|
||||
return {warId: parseInt(id), status: false};
|
||||
});
|
||||
await TowerRecordModel.createRecord({roleId, lv: towerLv, warStatus: sts});
|
||||
return { code: 201, data: '天梯记录异常' };
|
||||
}
|
||||
const data = {
|
||||
|
||||
@@ -8,7 +8,7 @@ import { getTowerDataByLv } from "../util/gamedata"
|
||||
import { decodeArrayStr } from '../util/util';
|
||||
import { handleFixedReward } from './rewardService';
|
||||
|
||||
export async function checkTowerWar(roleId: string, battleId: number) {
|
||||
export async function checkTowerWar(roleId: string, battleId: number, heroes: Array<number>) {
|
||||
const battleIdStr = `${battleId}`;
|
||||
let { towerLv } = await RoleModel.findByRoleId(roleId);
|
||||
const towerInfo = getTowerDataByLv(towerLv);
|
||||
@@ -16,19 +16,24 @@ export async function checkTowerWar(roleId: string, battleId: number) {
|
||||
console.error(`天梯层数异常,lv ${towerLv} by ${roleId}`);
|
||||
return { status: -1, msg: '天梯层数异常' };
|
||||
}
|
||||
const warArray = decodeArrayStr(towerInfo.warArray) || [];
|
||||
if (warArray.indexOf(battleIdStr) === -1) {
|
||||
const warIds = decodeArrayStr(towerInfo.warIds) || [];
|
||||
if (warIds.indexOf(battleIdStr) === -1) {
|
||||
return { status: -1, msg: '战斗 Id 异常' };
|
||||
}
|
||||
|
||||
let { heroes = [], warStatus = [] } = await TowerRecordModel.getRecordByLv(roleId, towerLv);
|
||||
let { heroes: recHeroes = [], warStatus = [] } = await TowerRecordModel.getRecordByLv(roleId, towerLv);
|
||||
for (let hid of heroes) {
|
||||
if (recHeroes.indexOf(hid) !== -1) {
|
||||
return { status: -1, msg: '使用了重复的武将' };
|
||||
}
|
||||
}
|
||||
const curWarStatus = warStatus.find(elem => elem.warId == battleId);
|
||||
if (curWarStatus.status) {
|
||||
return {status: -1, msg: '天梯关卡不能重复挑战'};
|
||||
}
|
||||
|
||||
return { status: 0, data: {
|
||||
heroes, warStatus: curWarStatus
|
||||
heroes: recHeroes, warStatus: curWarStatus
|
||||
}};
|
||||
}
|
||||
|
||||
@@ -54,20 +59,24 @@ export async function towerBattleEnd(channelService: ChannelService, sid: string
|
||||
})
|
||||
let newRec = await TowerRecordModel.updateRecord(roleId, towerLv, battleCode, battleId, heroes, inc);
|
||||
let bonusReward = null;
|
||||
let towerReward = null;
|
||||
if (inc === 1) {
|
||||
await RoleModel.towerLvUp(roleId);
|
||||
const nextTowerInfo = getTowerDataByLv(towerLv + 1);
|
||||
if (nextTowerInfo) {
|
||||
const { wars } = nextTowerInfo;
|
||||
const sts = wars.map(id => {
|
||||
return {warId: id, status: false};
|
||||
const { warIds } = nextTowerInfo;
|
||||
const sts = decodeArrayStr(warIds).map(id => {
|
||||
return {warId: parseInt(id), status: false};
|
||||
});
|
||||
await TowerRecordModel.createRecord({roleId, lv: towerLv + 1, warStatus: sts});
|
||||
}
|
||||
const { bonus } = getTowerDataByLv(towerLv);
|
||||
const { bonus, fixReward } = getTowerDataByLv(towerLv);
|
||||
if (bonus) {
|
||||
bonusReward = await handleFixedReward(roleId, roleName, bonus, 1);
|
||||
}
|
||||
if (fixReward) {
|
||||
towerReward = await handleFixedReward(roleId, roleName, fixReward, 1);
|
||||
}
|
||||
if (towerLv + 1 >= HANG_UP_CONSTS.ENABLE_LV) {
|
||||
await startHangUp(roleId, roleName);
|
||||
channelService.pushMessageByUids('hangUpEnable', {code: 200, data: {enable: true}}, [{uid: roleId, sid}]);
|
||||
@@ -77,7 +86,7 @@ export async function towerBattleEnd(channelService: ChannelService, sid: string
|
||||
status: 0,
|
||||
data: {
|
||||
newRec,
|
||||
bonusReward,
|
||||
bonusReward, towerReward,
|
||||
towerStatus: !!inc
|
||||
}
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@ export async function handleFixedReward(roleId: string, roleName: string, reward
|
||||
for(let goods of rewards) {
|
||||
let goodInfo = getGoodById(goods.gid);
|
||||
if(goodInfo.goodType == GOOD_TYPE.EQUIP) { // 装备
|
||||
let result = await rewardWeapons(roleId, roleName, goodInfo, {id: goods.gid, cnt: goods.count });
|
||||
let result = await rewardWeapons(roleId, roleName, goodInfo, {id: goods.gid, cnt: goods.count * multi });
|
||||
for(let obj of result) {
|
||||
returnGoods.push({dropType: goods.type, ...obj})
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ function parseTowerData() {
|
||||
const towerFile = 'dic_zyz_tower';
|
||||
const towerData = gamedata['jsons'][towerFile] || [];
|
||||
towerData.forEach(elem => {
|
||||
if (elem.towerFloor) {
|
||||
towerInfos.set(elem.towerFloor, elem);
|
||||
if (elem.lv) {
|
||||
towerInfos.set(elem.lv, elem);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user