diff --git a/script-universal_function.js b/script-universal_function.js index 4173b47b..29275810 100644 --- a/script-universal_function.js +++ b/script-universal_function.js @@ -50,10 +50,26 @@ function getQueryString(name,url) { } //数字补前导0 -Number.prototype.PrefixInteger = function(length) +Number.prototype.prefixInteger = function(length, useGrouping = false) { - return (Array(length).join('0') + this).slice(-length); + return this.toLocaleString(undefined, + { + useGrouping: useGrouping, + minimumIntegerDigits: length + }); +} +//数字补前导0 +Number.prototype.parseBigNumber = function() +{ + return this.toLocaleString(); +} + +//大数字缩短长度,默认返回本地定义字符串 +function parseBigNumber(number) +{ + return number.toLocaleString(); } + //数组删除自己尾部的空元素 Array.prototype.DeleteLatter = function(item = null) { diff --git a/script.js b/script.js index 5cf8a809..8a67eb57 100644 --- a/script.js +++ b/script.js @@ -1725,7 +1725,7 @@ function initialize() { const card = Cards[editBox.mid]; const decoder = new Adpcm(adpcm_wasm, pcmImportObj); decoder.resetDecodeState(new Adpcm.State(0, 0)); - decodeAudio(`sound/voice/${currentDataSource.code}/padv${card.voiceId.PrefixInteger(3)}.wav`, decoder.decode.bind(decoder)); + decodeAudio(`sound/voice/${currentDataSource.code}/padv${card.voiceId.prefixInteger(3)}.wav`, decoder.decode.bind(decoder)); } } monEditAwokensLabel.forEach(akDom => akDom.onclick = playVoiceAwoken); @@ -1771,14 +1771,14 @@ function initialize() { monEditLv110.onclick = setIptToMyValue; //编辑界面重新计算怪物的经验值 function reCalculateExp() { - const monid = parseInt(monstersID.value || 0, 10); + const monid = editBox.mid; const level = parseInt(monEditLv.value || 0, 10); const tempMon = { id: monid, level: level }; const needExp = calculateExp(tempMon); - monLvExp.textContent = needExp ? parseBigNumber(needExp[0]) + (level > 99 ? ` + ${parseBigNumber(needExp[1])}` : "") : ""; + monLvExp.textContent = needExp ? needExp[0].parseBigNumber() + (level > 99 ? ` + ${needExp[1].parseBigNumber()}` : "") : ""; } editBox.reCalculateExp = reCalculateExp; //三维