Merge branch 'statusCode' of gitlab.trgame.cn:zyztech/zyz_server
Conflicts: game-server/app/servers/battle/handler/eventBattleHandler.ts
This commit is contained in:
@@ -8,6 +8,8 @@ import { RoleModel } from './../db/Role';
|
||||
import { getHeroInfoById, getJobInfoById, getTowerDataByLv } from "../pubUtils/gamedata"
|
||||
import { decodeArrayStr, shouldRefresh } from '../pubUtils/util';
|
||||
import { handleFixedReward } from './rewardService';
|
||||
import { resResult } from '../pubUtils/util';
|
||||
import { STATUS } from '../consts/statusCode';
|
||||
|
||||
export async function checkTowerWar(roleId: string, battleId: number, heroes: Array<number>) {
|
||||
const battleIdStr = `${battleId}`;
|
||||
@@ -15,22 +17,22 @@ export async function checkTowerWar(roleId: string, battleId: number, heroes: Ar
|
||||
const towerInfo = getTowerDataByLv(towerLv);
|
||||
if (!towerInfo) {
|
||||
console.error(`天梯层数异常,lv ${towerLv} by ${roleId}`);
|
||||
return { status: -1, msg: '天梯层数异常' };
|
||||
return { status: -1, resResult: resResult(STATUS.TOWER_INFO_NOT_FOUND) };
|
||||
}
|
||||
const warIds = decodeArrayStr(towerInfo.warIds) || [];
|
||||
if (warIds.indexOf(battleIdStr) === -1) {
|
||||
return { status: -1, msg: '战斗 Id 异常' };
|
||||
return { status: -1, resResult: resResult(STATUS.TOWER_WRONG_BATTLE_ID) };
|
||||
}
|
||||
|
||||
let { heroes: recHeroes = [], warStatus = [] } = await TowerRecordModel.getRecordByLv(roleId, towerLv);
|
||||
for (let hid of heroes) {
|
||||
if (recHeroes.indexOf(hid) !== -1) {
|
||||
return { status: -1, msg: '使用了重复的武将' };
|
||||
return { status: -1, resResult: resResult(STATUS.TOWER_DUPLICATE_HERO) };
|
||||
}
|
||||
}
|
||||
const curWarStatus = warStatus.find(elem => elem.warId == battleId);
|
||||
if (curWarStatus.status) {
|
||||
return {status: -1, msg: '天梯关卡不能重复挑战'};
|
||||
return { status: -1, resResult: resResult(STATUS.TOWER_DUPLICATE_CHALLENGE) };
|
||||
}
|
||||
|
||||
return { status: 0, data: {
|
||||
@@ -42,13 +44,13 @@ export async function towerBattleEnd(channelService: ChannelService, sid: string
|
||||
if (succeed) {
|
||||
let battleRec = await BattleRecordModel.getBattleRecordByCode(battleCode);
|
||||
if (battleRec.battleId != battleId) {
|
||||
return { status: -1, msg: '战斗数据错误' };
|
||||
return { status: -1, resResult: resResult(STATUS.BATTLE_ID_NOT_MATCH) };
|
||||
}
|
||||
let { towerLv, roleName } = await RoleModel.findByRoleId(roleId);
|
||||
let { warStatus, heroes: recHeroes } = await TowerRecordModel.getRecordByLv(roleId, towerLv);
|
||||
for (let hid of heroes) {
|
||||
if (recHeroes.indexOf(hid) !== -1) {
|
||||
return { status: -1, msg: '使用了重复的武将' };
|
||||
return { status: -1, resResult: resResult(STATUS.TOWER_DUPLICATE_CHALLENGE) };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,21 +4,23 @@
|
||||
|
||||
import { DailyRecordModel } from '../db/DailyRecord';
|
||||
import { getGamedata } from '../pubUtils/gamedata';
|
||||
import { resResult } from '../pubUtils/util';
|
||||
import { STATUS } from '../consts/statusCode';
|
||||
|
||||
// 检查每日本次数checkBattle使用
|
||||
export async function checkDaily(roleId: string, battleId: number, inc: number) {
|
||||
let dicDaily = getGamedata('dic_zyz_daily');
|
||||
let dicDailyWar = getGamedata('dic_zyz_gk_daily');
|
||||
let dailyWar = dicDailyWar.find(cur => cur.war_id == battleId);
|
||||
if(!dailyWar) return { status: -1, msg: '未找到该关卡' };
|
||||
if(!dailyWar) return { status: -1, resResult: resResult(STATUS.DAILY_WAR_NOT_FOUND) };
|
||||
let type = dailyWar.dailyType;
|
||||
|
||||
let curDaily = dicDaily.find(cur => cur.dailyType == type);
|
||||
if(!curDaily) return { status: -1, msg: '未找到该类型' };
|
||||
if(!curDaily) return { status: -1, resResult: resResult(STATUS.DAILY_TYPE_NOT_FOUND) };
|
||||
let dailyRecord = await DailyRecordModel.refreshRecord(roleId, type);
|
||||
let { count } = dailyRecord;
|
||||
if(count + inc > curDaily.sum ) {
|
||||
return { status: -1, msg: '次数不足' }
|
||||
return { status: -1, resResult: resResult(STATUS.DAILY_TIMES_LACK) }
|
||||
}
|
||||
return {status: 1, type, count, sum: curDaily.sum};
|
||||
}
|
||||
@@ -28,11 +30,11 @@ export async function checkDailyAndIncrease(roleId: string, battleId: number, in
|
||||
let dicDaily = getGamedata('dic_zyz_daily');
|
||||
let dicDailyWar = getGamedata('dic_zyz_gk_daily');
|
||||
let dailyWar = dicDailyWar.find(cur => cur.war_id == battleId);
|
||||
if(!dailyWar) return { status: -1, msg: '未找到该关卡' };
|
||||
if(!dailyWar) return { status: -1, resResult: resResult(STATUS.DAILY_WAR_NOT_FOUND) };
|
||||
let type = dailyWar.dailyType;
|
||||
|
||||
let curDaily = dicDaily.find(cur => cur.dailyType == type);
|
||||
if(!curDaily) return { status: -1, msg: '未找到该类型' };
|
||||
if(!curDaily) return { status: -1, resResult: resResult(STATUS.DAILY_TYPE_NOT_FOUND) };
|
||||
|
||||
let dailyRecord: any;
|
||||
if(isRef) {
|
||||
@@ -42,7 +44,7 @@ export async function checkDailyAndIncrease(roleId: string, battleId: number, in
|
||||
}
|
||||
let { count } = dailyRecord;
|
||||
if(count + inc > curDaily.sum ) {
|
||||
return { status: -1, msg: '次数不足' }
|
||||
return { status: -1, resResult: resResult(STATUS.DAILY_TIMES_LACK) }
|
||||
}
|
||||
let result = await DailyRecordModel.increseDailyCount(roleId, type, inc);
|
||||
return {status: 1, type, count: result.count, sum: curDaily.sum};
|
||||
|
||||
Reference in New Issue
Block a user