✨ feat(gvg): 农庄
This commit is contained in:
@@ -22,6 +22,8 @@ export interface DicGVGItem {
|
||||
reward: RewardInter[];
|
||||
// 消耗后可获得的这张表里的奖励
|
||||
leagueReward: RewardInter[];
|
||||
// 成熟时间
|
||||
ripeTime: number;
|
||||
}
|
||||
|
||||
export const dicGVGItem = new Map<number, DicGVGItem>();
|
||||
|
||||
34
shared/pubUtils/dictionary/DicGVGLeagueLv.ts
Normal file
34
shared/pubUtils/dictionary/DicGVGLeagueLv.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
// GVG道具
|
||||
import { FILENAME } from '../../consts'
|
||||
import { RewardInter } from '../interface';
|
||||
import { parseGoodStr, readFileAndParse } from '../util'
|
||||
|
||||
export interface DicGVGLeagueLv {
|
||||
// 等级
|
||||
lv: number;
|
||||
// 粮食
|
||||
food: number;
|
||||
// 矿产
|
||||
mineral: number;
|
||||
// 木材
|
||||
wood: number;
|
||||
// 消耗后可获得的奖励
|
||||
reward: RewardInter[];
|
||||
}
|
||||
|
||||
export const dicGVGLeagueLv = new Map<number, DicGVGLeagueLv>();
|
||||
export function loadGVGLeagueLv() {
|
||||
dicGVGLeagueLv.clear();
|
||||
|
||||
let arr = readFileAndParse(FILENAME.DIC_GVG_LEAGUE_LV);
|
||||
let food = 0, mineral = 0, wood = 0;
|
||||
arr.forEach(o => {
|
||||
food += o.food;
|
||||
mineral += o.mineral;
|
||||
wood += o.wood;
|
||||
dicGVGLeagueLv.set(o.lv, {
|
||||
lv: o.lv, reward: parseGoodStr(o.reward), food, mineral, wood,
|
||||
});
|
||||
});
|
||||
arr = undefined;
|
||||
}
|
||||
74
shared/pubUtils/dictionary/DicGVGResourceBase.ts
Normal file
74
shared/pubUtils/dictionary/DicGVGResourceBase.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
// GVG千机阁
|
||||
import { FILENAME } from '../../consts';
|
||||
import { decodeArrayListStr, parseNumberList, readFileAndParse } from '../util';
|
||||
const _ = require('lodash');
|
||||
|
||||
export interface DicGVGResourceBase {
|
||||
// 唯一id
|
||||
id: number;
|
||||
// 名称
|
||||
name: string
|
||||
// 农庄等级
|
||||
lv: number;
|
||||
// 类型 1-农田 2-矿场 3-木堆
|
||||
type: number;
|
||||
// 限制类型
|
||||
limitType: number;
|
||||
// 限制参数
|
||||
limitParams: number[];
|
||||
// 农田产量加成
|
||||
fieldAdd: number;
|
||||
// 矿山铁矿的含铁量
|
||||
mineralValue: { type: number, output: number, count: number }[];
|
||||
// 单木框产量
|
||||
woodOutput: number;
|
||||
// 总数
|
||||
sum: number;
|
||||
}
|
||||
|
||||
type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
||||
const DicGVGResourceBaseKeys: KeysEnum<DicGVGResourceBase> = {
|
||||
id: true, name: true, lv: true, type: true, limitType: true, limitParams: true, fieldAdd: true, mineralValue: true, woodOutput: true, sum: true
|
||||
}
|
||||
export const dicGVGResourceBase = new Map<number, DicGVGResourceBase>(); // id => DicGVGResourceBase
|
||||
export const dicGVGResourceBaseByType = new Map<number, number[]>(); // type => [id]
|
||||
export const dicGVGResourceBaseByLv = new Map<string, number>(); // type + lv => [id]
|
||||
export function loadGVGResourceBase() {
|
||||
dicGVGResourceBase.clear();
|
||||
dicGVGResourceBaseByType.clear();
|
||||
dicGVGResourceBaseByLv.clear();
|
||||
|
||||
let arr = readFileAndParse(FILENAME.DIC_GVG_RESOURCE_BASE);
|
||||
arr.forEach(o => {
|
||||
o.limitParams = parseNumberList(o.limitParams);
|
||||
if(o.type == 1) { // 农田
|
||||
o.fieldAdd = parseFloat(o.value.split('&')[1]);
|
||||
if(isNaN(o.fieldAdd)) throw new Error('data table format wrong');
|
||||
} else if (o.type == 2) { // 矿山
|
||||
o.mineralValue = parseMineralValue(o.value);
|
||||
} else if (o.type == 3) {
|
||||
o.woodOutput = parseFloat(o.value.split('&')[1]);
|
||||
if(isNaN(o.woodOutput)) throw new Error('data table format wrong');
|
||||
}
|
||||
dicGVGResourceBase.set(o.id, _.pick(o, Object.keys(DicGVGResourceBaseKeys)));
|
||||
dicGVGResourceBaseByLv.set(`${o.type}_${o.lv}`, o.id);
|
||||
if(!dicGVGResourceBaseByType.has(o.type)) {
|
||||
dicGVGResourceBaseByType.set(o.type, []);
|
||||
}
|
||||
dicGVGResourceBaseByType.get(o.type)?.push(o.id);
|
||||
});
|
||||
arr = undefined;
|
||||
}
|
||||
|
||||
function parseMineralValue(str: string) {
|
||||
let result = new Array<{ type: number, output: number, count: number }>();
|
||||
if (!str) return result;
|
||||
let decodeArr = decodeArrayListStr(str);
|
||||
for (let [type, output, count] of decodeArr) {
|
||||
if (isNaN(parseInt(type)) || isNaN(parseInt(output)) || isNaN(parseInt(count))) {
|
||||
throw new Error('data table format wrong');
|
||||
}
|
||||
result.push({ type: parseInt(type), output: parseInt(output), count: parseInt(count) });
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// GVG千机阁
|
||||
import { FILENAME } from '../../consts'
|
||||
import { decodeArrayListStr, readFileAndParse } from '../util'
|
||||
import { decodeArrayListStr, parseNumberList, readFileAndParse } from '../util'
|
||||
|
||||
export interface DicGVGTech {
|
||||
// 唯一id
|
||||
@@ -12,7 +12,7 @@ export interface DicGVGTech {
|
||||
// 效果类型 1-资源产量上传 2-征战中原提升 3-激战期提升 4-复活cd减少 5-箭塔 6-攻城车
|
||||
type: number;
|
||||
// 资源提升量啊,复活cd减少量啊之类的值
|
||||
param: number;
|
||||
param: number[];
|
||||
// 点排序
|
||||
nodeSort: number;
|
||||
// 联军等级限制
|
||||
@@ -30,6 +30,7 @@ export function loadGVGTech() {
|
||||
let arr = readFileAndParse(FILENAME.DIC_GVG_TECH);
|
||||
arr.forEach(o => {
|
||||
o.prepositionId = parsePrePositionId(o.prepositionId);
|
||||
o.param = parseNumberList(o.param)
|
||||
dicGVGTech.set(o.id, o);
|
||||
});
|
||||
arr = undefined;
|
||||
|
||||
Reference in New Issue
Block a user