后台:json上传
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// 军团建筑物
|
||||
import {readJsonFile, parseGoodStr, parseNumberList, decodeArrayListStr} from '../util'
|
||||
import {readFileAndParse, parseGoodStr, parseNumberList, decodeArrayListStr} from '../util'
|
||||
import { FILENAME } from '../../consts'
|
||||
import { RewardInter } from '../interface';
|
||||
const _ = require('lodash');
|
||||
@@ -146,11 +146,6 @@ export interface DicStoreBase {
|
||||
readonly storeGoods: {id: number, count: number, num: number}[];
|
||||
}
|
||||
|
||||
const DicStoreKeys: KeysEnum<DicStoreBase> = {
|
||||
id: true,
|
||||
level: true,
|
||||
storeGoods: true
|
||||
};
|
||||
|
||||
export const dicStructureConsume = new Map<number, Map<number, number>>(); // 升级消耗 structureId => level => consume
|
||||
export const dicCenterBase = new Map<number, DicCentreBase>(); // 中军大帐
|
||||
@@ -163,96 +158,97 @@ export const dicWishPoolBase = new Map<number, DicWishPoolBase>(); // 许愿池
|
||||
export const dicStoreBase = new Map<number, DicWishPoolBase>(); // 许愿池
|
||||
export let maxMemberCnt = 0; // 满配最大人数
|
||||
|
||||
// 中军大帐
|
||||
const strCenter = readJsonFile(FILENAME.DIC_GUILD_STRUCTURE_CENTER);
|
||||
let arrCenter = JSON.parse(strCenter);
|
||||
arrCenter.forEach(o => {
|
||||
setStructureConsume(o);
|
||||
if(o.peopleNum > maxMemberCnt) maxMemberCnt = o.peopleNum;
|
||||
dicCenterBase.set(o.level, _.pick(o, Object.keys(DicCenterKeys)));
|
||||
});
|
||||
arrCenter = undefined;
|
||||
export function loadStructure() {
|
||||
|
||||
// 炼器堂
|
||||
const strEquip = readJsonFile(FILENAME.DIC_GUILD_EQUIP_PRODUCE_BASE);
|
||||
let arrEquip = JSON.parse(strEquip);
|
||||
arrEquip.forEach(o => {
|
||||
setStructureConsume(o);
|
||||
o.qualityProduce = parseNumberList(o.qualityProduce);
|
||||
dicEquipPriduceBase.set(o.level, _.pick(o, Object.keys(DicEquipProduceKeys)));
|
||||
});
|
||||
arrEquip = undefined;
|
||||
|
||||
// 演武台
|
||||
const strBoss = readJsonFile(FILENAME.DIC_GUILD_BOSS_BASE);
|
||||
let arrBoss = JSON.parse(strBoss);
|
||||
arrBoss.forEach(o => {
|
||||
setStructureConsume(o);
|
||||
o.reward = parseGoodStr(o.reward);
|
||||
o.wars = o.warIdHP.split('|').map((warStrs)=> {
|
||||
if (!warStrs) {
|
||||
return;
|
||||
}
|
||||
let warArr = warStrs.split('&');
|
||||
return { warId: parseInt(warArr[0]), bossHp: parseInt(warArr[1])}
|
||||
const DicStoreKeys: KeysEnum<DicStoreBase> = {
|
||||
id: true,
|
||||
level: true,
|
||||
storeGoods: true
|
||||
};
|
||||
// 中军大帐
|
||||
let arrCenter = readFileAndParse(FILENAME.DIC_GUILD_STRUCTURE_CENTER);
|
||||
arrCenter.forEach(o => {
|
||||
setStructureConsume(o);
|
||||
if(o.peopleNum > maxMemberCnt) maxMemberCnt = o.peopleNum;
|
||||
dicCenterBase.set(o.level, _.pick(o, Object.keys(DicCenterKeys)));
|
||||
});
|
||||
dicBossBase.set(o.level, _.pick(o, Object.keys(DicBossKeys)));
|
||||
dicBossBaseByBossLv.set(o.bossLevel, _.pick(o, Object.keys(DicBossKeys)));
|
||||
});
|
||||
arrBoss = undefined;
|
||||
arrCenter = undefined;
|
||||
|
||||
// 练兵场
|
||||
const strTrain = readJsonFile(FILENAME.DIC_GUILD_TRAIN_BASE);
|
||||
let arrTrain = JSON.parse(strTrain);
|
||||
arrTrain.forEach(o => {
|
||||
setStructureConsume(o);
|
||||
dicTrainBase.set(o.level, _.pick(o, Object.keys(DicTrainKeys)));
|
||||
});
|
||||
arrTrain = undefined;
|
||||
|
||||
// 捐献所
|
||||
const strDonate = readJsonFile(FILENAME.DIC_GUILD_DONATE_BASE);
|
||||
let arrDonate = JSON.parse(strDonate);
|
||||
arrDonate.forEach(o => {
|
||||
setStructureConsume(o);
|
||||
o.donateReward = parseDonateReward(o.donatevalue, o.honourReward, o.fundReward);
|
||||
dicDonateBase.set(o.level, _.pick(o, Object.keys(DicDonateKeys)));
|
||||
});
|
||||
arrDonate = undefined;
|
||||
|
||||
// 许愿池
|
||||
const strWishPool = readJsonFile(FILENAME.DIC_GUILD_WISH_POOL_BASE);
|
||||
let arrWishPool = JSON.parse(strWishPool);
|
||||
arrWishPool.forEach(o => {
|
||||
setStructureConsume(o);
|
||||
o.wishGoodsEquips = o.wishgoodsEquip.split('|').map(wishGoodsEquip=>{
|
||||
let wishGoodsEquips = wishGoodsEquip.split('&');
|
||||
return {quality: parseInt(wishGoodsEquips[0]), count: parseInt(wishGoodsEquips[1])};
|
||||
// 炼器堂
|
||||
let arrEquip = readFileAndParse(FILENAME.DIC_GUILD_EQUIP_PRODUCE_BASE);
|
||||
arrEquip.forEach(o => {
|
||||
setStructureConsume(o);
|
||||
o.qualityProduce = parseNumberList(o.qualityProduce);
|
||||
dicEquipPriduceBase.set(o.level, _.pick(o, Object.keys(DicEquipProduceKeys)));
|
||||
});
|
||||
o.wishGoodsHeros = o.wishgoodsHero.split('|').map(wishGoodsHero=>{
|
||||
let wishGoodsHeros = wishGoodsHero.split('&');
|
||||
return {quality: parseInt(wishGoodsHeros[0]), count: parseInt(wishGoodsHeros[1])};
|
||||
arrEquip = undefined;
|
||||
|
||||
// 演武台
|
||||
let arrBoss = readFileAndParse(FILENAME.DIC_GUILD_BOSS_BASE);
|
||||
arrBoss.forEach(o => {
|
||||
setStructureConsume(o);
|
||||
o.reward = parseGoodStr(o.reward);
|
||||
o.wars = o.warIdHP.split('|').map((warStrs)=> {
|
||||
if (!warStrs) {
|
||||
return;
|
||||
}
|
||||
let warArr = warStrs.split('&');
|
||||
return { warId: parseInt(warArr[0]), bossHp: parseInt(warArr[1])}
|
||||
});
|
||||
dicBossBase.set(o.level, _.pick(o, Object.keys(DicBossKeys)));
|
||||
dicBossBaseByBossLv.set(o.bossLevel, _.pick(o, Object.keys(DicBossKeys)));
|
||||
});
|
||||
dicWishPoolBase.set(o.level, _.pick(o, Object.keys(DicWishPoolKeys)));
|
||||
});
|
||||
arrWishPool = undefined;
|
||||
arrBoss = undefined;
|
||||
|
||||
// 商店
|
||||
const strStore = readJsonFile(FILENAME.DIC_GUILD_STORE_BASE);
|
||||
let arrStore = JSON.parse(strStore);
|
||||
arrStore.forEach(o => {
|
||||
setStructureConsume(o);
|
||||
o.storeGoods = parseStoreGoods(o.storeGoods);
|
||||
dicStoreBase.set(o.level, _.pick(o, Object.keys(DicStoreKeys)));
|
||||
});
|
||||
arrStore = undefined;
|
||||
// 练兵场
|
||||
let arrTrain = readFileAndParse(FILENAME.DIC_GUILD_TRAIN_BASE);
|
||||
arrTrain.forEach(o => {
|
||||
setStructureConsume(o);
|
||||
dicTrainBase.set(o.level, _.pick(o, Object.keys(DicTrainKeys)));
|
||||
});
|
||||
arrTrain = undefined;
|
||||
|
||||
// 升级消耗
|
||||
function setStructureConsume(o) {
|
||||
let map = dicStructureConsume.get(o.structureId);
|
||||
if(!map) map = new Map<number, number>();
|
||||
map.set(o.level, o.consume);
|
||||
dicStructureConsume.set(o.structureId, map);
|
||||
// 捐献所
|
||||
let arrDonate = readFileAndParse(FILENAME.DIC_GUILD_DONATE_BASE);
|
||||
arrDonate.forEach(o => {
|
||||
setStructureConsume(o);
|
||||
o.donateReward = parseDonateReward(o.donatevalue, o.honourReward, o.fundReward);
|
||||
dicDonateBase.set(o.level, _.pick(o, Object.keys(DicDonateKeys)));
|
||||
});
|
||||
arrDonate = undefined;
|
||||
|
||||
// 许愿池
|
||||
let arrWishPool = readFileAndParse(FILENAME.DIC_GUILD_WISH_POOL_BASE);
|
||||
arrWishPool.forEach(o => {
|
||||
setStructureConsume(o);
|
||||
o.wishGoodsEquips = o.wishgoodsEquip.split('|').map(wishGoodsEquip=>{
|
||||
let wishGoodsEquips = wishGoodsEquip.split('&');
|
||||
return {quality: parseInt(wishGoodsEquips[0]), count: parseInt(wishGoodsEquips[1])};
|
||||
});
|
||||
o.wishGoodsHeros = o.wishgoodsHero.split('|').map(wishGoodsHero=>{
|
||||
let wishGoodsHeros = wishGoodsHero.split('&');
|
||||
return {quality: parseInt(wishGoodsHeros[0]), count: parseInt(wishGoodsHeros[1])};
|
||||
});
|
||||
dicWishPoolBase.set(o.level, _.pick(o, Object.keys(DicWishPoolKeys)));
|
||||
});
|
||||
arrWishPool = undefined;
|
||||
|
||||
// 商店
|
||||
let arrStore = readFileAndParse(FILENAME.DIC_GUILD_STORE_BASE);
|
||||
arrStore.forEach(o => {
|
||||
setStructureConsume(o);
|
||||
o.storeGoods = parseStoreGoods(o.storeGoods);
|
||||
dicStoreBase.set(o.level, _.pick(o, Object.keys(DicStoreKeys)));
|
||||
});
|
||||
arrStore = undefined;
|
||||
|
||||
// 升级消耗
|
||||
function setStructureConsume(o) {
|
||||
let map = dicStructureConsume.get(o.structureId);
|
||||
if(!map) map = new Map<number, number>();
|
||||
map.set(o.level, o.consume);
|
||||
dicStructureConsume.set(o.structureId, map);
|
||||
}
|
||||
}
|
||||
|
||||
// {"type": number, "count": number}
|
||||
|
||||
Reference in New Issue
Block a user