| @@ -32,9 +32,25 @@ Member.prototype.outObj = function(){ | |||
| var obj = [m.id]; | |||
| if (m.level != undefined) obj[1] = m.level; | |||
| if (m.awoken != undefined) obj[2] = m.awoken; | |||
| if (m.plus != undefined && m.plus instanceof Array && m.plus.length>=3 && (m.plus[0]+m.plus[1]+m.plus[2])>0) obj[3] = m.plus; | |||
| if (m.latent != undefined && m.latent instanceof Array && m.latent.length>=1) obj[4] = m.latent; | |||
| if (m.sawoken != undefined) obj[5] = m.sawoken; | |||
| if (m.plus != undefined && m.plus instanceof Array && m.plus.length>=3 && (m.plus[0]+m.plus[1]+m.plus[2])!==0) | |||
| { | |||
| if (m.plus[0] === m.plus[1] && m.plus[0] === m.plus[2]) | |||
| { //当3个加值一样时只生成第一个减少长度 | |||
| obj[3] = m.plus[0]; | |||
| }else | |||
| { | |||
| 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.sawoken != undefined && m.sawoken>=0) obj[5] = m.sawoken; | |||
| return obj; | |||
| } | |||
| Member.prototype.loadObj = function(m,dataVersion){ | |||
| @@ -46,9 +62,35 @@ Member.prototype.loadObj = function(m,dataVersion){ | |||
| this.id = dataVersion>1 ? m[0] : m.id; | |||
| this.level = dataVersion>1 ? m[1] : m.level; | |||
| this.awoken = dataVersion>1 ? m[2] : m.awoken; | |||
| this.plus = dataVersion>1 ? m[3] : m.plus; | |||
| if (!(this.plus instanceof Array)) this.plus = [0,0,0]; //如果潜觉不是数组,则改变 | |||
| this.latent = dataVersion>1 ? m[4] : m.latent; | |||
| 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; | |||
| if (!(this.latent instanceof Array)) this.latent = []; //如果潜觉不是数组,则改变 | |||
| this.sawoken = dataVersion>1 ? m[5] : m.sawoken; | |||
| } | |||