From 674372e32b374a2f8cca5d286b40ba0c050b137d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=AB=E8=B0=B7=E5=89=91=E4=BB=99?= Date: Sat, 28 Dec 2019 21:52:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E5=A4=B1=E8=B4=A5=E7=9A=84?= =?UTF-8?q?=E4=BD=8D=E8=BF=90=E7=AE=97=E6=BD=9C=E8=A7=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script.js | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/script.js b/script.js index 6f38869a..9cbb98e5 100644 --- a/script.js +++ b/script.js @@ -42,14 +42,7 @@ Member.prototype.outObj = function(){ obj[3] = m.plus; } } - if (m.latent != undefined && m.latent instanceof Array && m.latent.length>=1) - { - //obj[4] = m.latent; - //潜觉为1-33,5位可以表示0-31,6位才能表示0-63 - obj[4] = m.latent.reduce((previousValue, currentValue, idx) => { - return previousValue | currentValue << 6*idx; - },m.latent[0]); - } + if (m.latent != undefined && m.latent instanceof Array && m.latent.length>=1) obj[4] = m.latent; if (m.sawoken != undefined && m.sawoken>=0) obj[5] = m.sawoken; return obj; } @@ -65,32 +58,7 @@ Member.prototype.loadObj = function(m,dataVersion){ const singlePlus = parseInt(m[3],10);//如果只有一个数字时,复制3份 this.plus = dataVersion>1 ? (isNaN(m[3])||m[3]==null ? m[3] : [singlePlus,singlePlus,singlePlus]) : m.plus; if (!(this.plus instanceof Array)) this.plus = [0,0,0]; //如果加值不是数组,则改变 - if (dataVersion>1) - { - if (isNaN(m[4])) - { - this.latent = m[4]; - } - else if(m[4] != null) - { - const binNum = m[4].toString(2); - const latentCount = Math.ceil(binNum.length/6); - const startSubStr = binNum.length % 6; - let latentArray = []; - - latentArray.push(parseInt(binNum.substr(0,startSubStr),2)); //从最后一个潜觉开始添加 - for (let i=0;i<(latentCount-1);i++) - { - latentArray.push(parseInt(binNum.substr(startSubStr+6*i,6),2)); - } - latentArray.reverse(); //数组反向 - this.latent = latentArray; - } - }else - { - this.latent = m.latent; - } - //this.latent = dataVersion>1 ? m[4] : m.latent; + this.latent = dataVersion>1 ? m[4] : m.latent; if (!(this.latent instanceof Array)) this.latent = []; //如果潜觉不是数组,则改变 this.sawoken = dataVersion>1 ? m[5] : m.sawoken; }