diff --git a/script-universal_function.js b/script-universal_function.js index a9007014..576157f0 100644 --- a/script-universal_function.js +++ b/script-universal_function.js @@ -54,6 +54,20 @@ Number.prototype.PrefixInteger = function(length) { return (Array(length).join('0') + this).slice(-length); } +//数组删除自己尾部的空元素 +Array.prototype.DeleteLatter = function(item = null) +{ + let index = this.length - 1; + for (; index>=0; index--) + { + if (this[index] !== item) + { + break; + } + } + this.splice(index + 1); + return this; +} //▼ADPCM播放相关,来自 https://github.com/jy4340132/aaa const pcmMemory = new WebAssembly.Memory({initial: 256, maximum: 256}); diff --git a/script.js b/script.js index 86f94a5f..95830ea3 100644 --- a/script.js +++ b/script.js @@ -129,6 +129,7 @@ var Member = function() { }; Member.prototype.outObj = function() { const m = this; + if (m.id == 0) return null; let obj = [m.id]; if (m.level != undefined) obj[1] = m.level; if (m.awoken != undefined) obj[2] = m.awoken; @@ -254,10 +255,10 @@ Formation.prototype.outObj = function() { const teamArr = []; teamArr[0] = t[0].map(m => m.outObj() - ); + ).DeleteLatter(); teamArr[1] = t[1].map(m => m.outObj() - ); + ).DeleteLatter(); if (t[2]) teamArr[2] = t[2]; return teamArr; });