战斗开始和战斗结算
This commit is contained in:
@@ -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
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user