pvp:机器人次级属性

This commit is contained in:
luying
2022-04-21 19:38:26 +08:00
parent 8b02e7f5c1
commit 1e5bffc36c
8 changed files with 3938 additions and 65 deletions
+4 -1
View File
@@ -105,6 +105,7 @@ import { dicHeroTalent, initTalents, loadHeroTalent } from './dictionary/DicHero
import { Talent } from "../db/Hero";
import { dicEquipStrengthAttr, loadEquipStrengthAttr } from './dictionary/DicEquipStrengthAttr';
import { dicTowerGift, loadTowerGift } from './dictionary/DicTowerGift';
import { dicTowerPvpSubAttr, loadTowerPvpSubAttr } from './dictionary/DicTowerPvpSubAttr';
export const gameData = {
daily: dicDaily,
@@ -260,7 +261,8 @@ export const gameData = {
heroTalent: dicHeroTalent,
initTalents: initTalents,
talentPointOfJob: talentPointOfJob,
equipStrengthAttr: dicEquipStrengthAttr
equipStrengthAttr: dicEquipStrengthAttr,
towerPvpSubAttr: dicTowerPvpSubAttr,
};
// 在此提供一些原先在gamedata中提供的方法,以便更方便获取gameData数据
@@ -1060,6 +1062,7 @@ function loadDatas() {
loadMainStarBox();
loadHeroTalent();
loadEquipStrengthAttr();
loadTowerPvpSubAttr();
}
// 重载dicParam
@@ -6,8 +6,8 @@ export interface DicPvpDifficultRatio {
readonly teamLineupMin: number;
readonly teamLineupMax: number;
readonly value: number;
readonly enemyLv: number;
readonly enemyLv: number;
readonly secondAttrLevel: number;
}
export const dicPvpDifficultRatio = new Array<DicPvpDifficultRatio>();
@@ -0,0 +1,40 @@
import { decodeArrayListStr, readFileAndParse } from '../util'
import { ABI_TYPE, FILENAME, HERO_ATTR } from '../../consts'
type KeysEnum<T> = { [P in keyof Required<T>]: true };
const _ = require('lodash');
export interface DicTowerPvpSubAttr {
// 对应 dicPvpDifficultRatio表的同名字段
readonly secondAttrLevel: number;
// 属性
readonly secondAtr: {id: number, val: number}[];
}
const DicTowerPvpSubAttrKeys: KeysEnum<DicTowerPvpSubAttr> = {
secondAttrLevel: true,
secondAtr: true,
};
export const dicTowerPvpSubAttr = new Map<number, DicTowerPvpSubAttr>();
export function loadTowerPvpSubAttr() {
dicTowerPvpSubAttr.clear();
let arr = readFileAndParse(FILENAME.DIC_TOWER_PVP_SUB_ATTR);
arr.forEach(o => {
o.secondAtr = parseAttr(o.secondAtr);
dicTowerPvpSubAttr.set(o.secondAttrLevel, _.pick(o, Object.keys(DicTowerPvpSubAttrKeys)));
});
arr = undefined;
}
function parseAttr(str: string) {
let result = new Array<{id: number, val: number}>();
if(!str) return result;
let decodeArr = decodeArrayListStr(str);
for(let [id, val] of decodeArr) {
if(isNaN(parseInt(id)) || isNaN(parseInt(val))) {
throw new Error('data table format wrong');
}
result.push({id: parseInt(id), val: parseInt(val)});
}
return result
}