diff --git a/monsters-info/extractByNode.js b/monsters-info/extractByNode.js index 12362338..0802c5a9 100644 --- a/monsters-info/extractByNode.js +++ b/monsters-info/extractByNode.js @@ -1,112 +1,133 @@ -var fs = require('fs'); -var officialAPI = ["ja","en","ko"]; //来源于官方API -var custom = ["cht","chs"]; //来源于自定义文件 +const fs = require('fs'); +var officialAPI = [ //来源于官方API + { + code:"ja", + customName:["cht","chs"] + }, + { + code:"en", + customName:[] + }, + { + code:"ko", + customName:[] + } +]; -var cards = officialAPI.map(function(code){ - console.log("正在读取官方 " + code + " 信息"); - var json = fs.readFileSync("official-API/" + code +".json", 'utf-8'); //使用同步读取 - var card = JSON.parse(json).card;//将字符串转换为json对象 - return card; +officialAPI.forEach(function(lang){ + console.log("正在读取官方 " + lang.code + " 信息"); + let json = fs.readFileSync("official-API/" + lang.code +".json", 'utf-8'); //使用同步读取 + lang.cardOriginal = JSON.parse(json).card;//将字符串转换为json对象 }) -var mainCard = cards[0]; //数据的主要card -var mArr = []; //储存输出内容 +//比较两只怪物是否是同一只(在不同语言服务器) +function sameCard(m1,m2) +{ + //因为觉醒数量的不一样,所以需要制定序号 + //let awokenCountIdx1 = 58+m1[57]*3; //觉醒数量的序号 + //let superAwokenIdx1 = awokenCountIdx1+1+m1[awokenCountIdx1]; //超觉醒的序号 + //let awokenCountIdx2 = 58+m2[57]*3; //觉醒数量的序号 + //let superAwokenIdx2 = awokenCountIdx2+1+m2[awokenCountIdx2]; //超觉醒的序号 + + let res = true; + if (m1[2] != m2[2]) return false; //主属性 + if (m1[3] != m2[3]) return false; //副属性 + if (m1[5] != m2[5]) return false; //type1 + if (m1[6] != m2[6]) return false; //type2 + //if (m1[superAwokenIdx+3] != m2[superAwokenIdx+3]) return false; //type3 + if (m1[10] != m2[10]) return false; //最大等级 + return res; +} +for (let li = 0;li < officialAPI.length; li++) +{ + let otherLangs = officialAPI.concat(); //复制一份原始数组 + let lang = otherLangs.splice(li,1)[0]; //删掉并取得当前的数组 + let card = lang.cardOriginal; + let monArray = []; //储存输出内容 -var maxLength = cards.map(function(card){ //获取最大怪物id - var length = card.length; - for (var mi=0;mi2 && [303,305,307,600,602].indexOf(m[0])<0)?1:0, //但是5种小企鹅是特殊情况 - ability: [ //三维 - [m[14],m[15]], //HP - [m[17],m[18]], //ATK - [m[20],m[21]], //RCV - ], - } - if (m[superAwokenIdx+9]>0) //如果可以110级 - { - mon.a110 = m[superAwokenIdx+9]; - var superAwoken = //超觉醒 - m[superAwokenIdx].length>0 - ? (m[superAwokenIdx].split(",").map(function(sa){return parseInt(sa);})) - : null; - if (superAwoken) + let mon = { + id: m[0], + name: nameObj, + ppt: [m[2],m[3]], //属性property + type: type, + rare: m[7], //稀有度 + awoken: awokens, //觉醒 + maxLv: m[10], + assist: (m[superAwokenIdx+7]>2 && [303,305,307,600,602].indexOf(m[0])<0)?1:0, //但是5种小企鹅是特殊情况 + ability: [ //三维 + [m[14],m[15]], //HP + [m[17],m[18]], //ATK + [m[20],m[21]], //RCV + ], + } + if (m[superAwokenIdx+9]>0) //如果可以110级 { - mon.sAwoken = superAwoken; + mon.a110 = m[superAwokenIdx+9]; + let superAwoken = //超觉醒 + m[superAwokenIdx].length>0 + ? (m[superAwokenIdx].split(",").map(function(sa){return parseInt(sa);})) + : null; + if (superAwoken) + { + mon.sAwoken = superAwoken; + } } + monArray.push(mon); } - mArr.push(mon); -} - -var cards_c = custom.map(function(code){ - console.log("正在读取自定义 " + code + " 信息"); - var json = fs.readFileSync("custom/" + code +".json", 'utf-8'); //使用同步读取 - var card = JSON.parse(json);//将字符串转换为json对象 - return card; -}) -cards_c.forEach(function(card,cidx){ //每个文件循环 - card.forEach(function(cm,idx){ //每个文件内的名字循环 - var m = mArr[cm.id]; - m.name[custom[cidx]] = cm.name; + //加入自定义的语言 + lang.customName.forEach(function(lcode){ + console.log("正在读取自定义 " + lcode + " 信息"); + let json = fs.readFileSync("custom/" + lcode +".json", 'utf-8'); //使用同步读取 + let ccard = JSON.parse(json);//将字符串转换为json对象 + ccard.forEach(function(cm,idx){ //每个文件内的名字循环 + let m = monArray[cm.id]; + if (m) + m.name[lcode] = cm.name; + }); }); -}); -var str = JSON.stringify(mArr); -fs.writeFile('./mon.json',str,function(err){ - if(err){ - console.error(err); - } - console.log('----------导出成功-------------'); -}) \ No newline at end of file + let str = JSON.stringify(monArray); + fs.writeFile('./mon_'+lang.code+'.json',str,function(err){ + if(err){ + console.error(err); + } + console.log('mon_'+lang.code+'.json 导出成功'); + }) +} \ No newline at end of file diff --git a/monsters-info/提取中文数据.bat b/monsters-info/提取中文数据.bat index 3fa5c861..1a9a51ad 100644 --- a/monsters-info/提取中文数据.bat +++ b/monsters-info/提取中文数据.bat @@ -2,6 +2,6 @@ echo ʼȡҳ node.exe extract_CHT.js echo ڽתΪ -opencc\opencc.exe -i custom\cht.json -o custom\chs.json -c opencc\t2s.json +opencc\opencc.exe -i custom\cht.json -o custom\chs.json -c opencc\hk2s.json echo ת pause \ No newline at end of file diff --git a/solo.html b/solo.html index 74c8823b..b2e6cb0a 100644 --- a/solo.html +++ b/solo.html @@ -23,7 +23,7 @@ var formation = new Formation(1,6);
- +