战斗开始和战斗结算

This commit is contained in:
wangdan
2020-09-11 15:24:49 +08:00
parent b591a0120c
commit 96d81052f9
10 changed files with 8984 additions and 1 deletions
+44
View File
@@ -0,0 +1,44 @@
const fs = require('fs');
const path = require('path');
var gamedata = {};
function initData () {
fs.readdirSync(__dirname + '/../../config/resource')
.filter(function(file) {
return (file.indexOf(".") !== 0) && (file !== "index.js");
})
//筛选有文件名且不是index进行遍历
.forEach(function(file) {
var name = file.split('.')[0];
try {
gamedata[name] = JSON.parse(
fs.readFileSync(path.resolve(__dirname, "../../config/resource/" + file))
);
} catch(e) {
console.error('【文件缺少】:' + file);
gamedata[name] = [];
}
});
}
initData();
export function getGamedata(key) {
return gamedata[key];
}
export function getWarById(warid) {
let warInfo = gamedata['dic_zyz_gk']||[];
return warInfo.find(cur => {
return cur.war_id == warid
});
}
export function getGoodById(gid) {
console.log(gid)
let goodsInfo = gamedata['goods']||[];
return goodsInfo.find(cur => {
return cur.good_id == gid
});
}