全局:加载json方法全部改为最新

This commit is contained in:
luying
2021-05-06 20:25:05 +08:00
parent 2ef00e8179
commit 0315269387
36 changed files with 401 additions and 920 deletions
@@ -1,6 +1,5 @@
import { Application, BackendSession } from 'pinus';
import { DailyRecordModel } from '../../../db/DailyRecord';
import { getGamedata } from '../../../pubUtils/gamedata';
import { GOLD_COST_RATIO } from '../../../consts';
import { STATUS } from '../../../consts/statusCode';
import { resResult, calculateNum } from '../../../pubUtils/util';
@@ -8,6 +7,7 @@ import { RoleModel } from '../../../db/Role';
import { getDailyNum } from '../../../services/dailyBattleService';
import { handleCost } from '../../../services/rewardService';
import { getGoldObject } from '../../../pubUtils/itemUtils';
import { gameData } from '../../../pubUtils/data';
export default function(app: Application) {
return new DailyBattleHandler(app);
@@ -22,36 +22,34 @@ export class DailyBattleHandler {
let roleId = session.get('roleId');
let {warStar} = await RoleModel.findByRoleId(roleId);
let dicDaily = getGamedata('dic_zyz_daily');
let dicDailyWar = getGamedata('dic_zyz_gk_daily');
let dicDaily = gameData.daily;
let result = new Array();
for(let {dailyType: type, name, timesPerDay, timesCanBuy } of dicDaily) {
let refreshResult = await DailyRecordModel.refreshRecord(roleId, type);
let wars = new Array();
for(let {war_id, dailyType, cost, gk_name, previousGk } of dicDailyWar) {
if(dailyType == type) {
let status = 0, star = 0;
let curBattle = warStar.find(cur => cur.id == war_id);
if(curBattle) {
status = 2;
star = curBattle.star;
} else {
if (previousGk) {
let preBattleRecord = warStar.find(cur => cur.id == previousGk);
if(preBattleRecord) {
status = 1;
} else {
status = 0;
}
} else {
let wars: {battleId: number, cost: number, star: number, status: number, name: string}[] = new Array();
let dicDailyWar = gameData.dailyWarByType.get(type);
for(let {war_id, cost, gk_name, previousGk } of dicDailyWar) {
let status = 0, star = 0;
let curBattle = warStar.find(cur => cur.id == war_id);
if(curBattle) {
status = 2;
star = curBattle.star;
} else {
if (previousGk) {
let preBattleRecord = warStar.find(cur => cur.id == previousGk);
if(preBattleRecord) {
status = 1;
} else {
status = 0;
}
} else {
status = 1;
}
wars.push({
battleId: war_id, cost, star, status, name: gk_name
});
}
wars.push({
battleId: war_id, cost, star, status, name: gk_name
});
}
let checkDailyResult = await getDailyNum(refreshResult, timesPerDay, timesCanBuy);
result.push({
@@ -70,8 +68,7 @@ export class DailyBattleHandler {
const roleId = session.get('roleId');
const sid = session.get('sid');
const dicDaily = getGamedata('dic_zyz_daily');
const curDaily = dicDaily.find(cur => cur.dailyType == type);
const curDaily = gameData.daily.find(cur => cur.dailyType == type);
if(!curDaily) return resResult(STATUS.DAILY_TYPE_NOT_FOUND);
let { timesPerDay, timesCanBuy } = curDaily;
let { buyCount = 0 } = await DailyRecordModel.refreshRecord(roleId, type);