diff options
author | EmeraldMerchant <96396730+EmeraldMerchant@users.noreply.github.com> | 2022-08-11 04:21:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-11 04:21:38 +0800 |
commit | 98e6000939b1fdded936f46969bcea04c975c993 (patch) | |
tree | 8ab9d5d50da59f20bfc41fcb54849fa5b2db0b88 | |
parent | f7185ba108df10f3d102a5be1294649daeaff6c6 (diff) | |
download | SoopyV2-98e6000939b1fdded936f46969bcea04c975c993.tar.gz SoopyV2-98e6000939b1fdded936f46969bcea04c975c993.tar.bz2 SoopyV2-98e6000939b1fdded936f46969bcea04c975c993.zip |
this.todoPickUpLog array -> object
so i can merge the same items into the same line
-rw-r--r-- | features/globalSettings/index.js | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/features/globalSettings/index.js b/features/globalSettings/index.js index eaa296d..1430824 100644 --- a/features/globalSettings/index.js +++ b/features/globalSettings/index.js @@ -148,7 +148,7 @@ class GlobalSettings extends Feature { this.itemData = {}; this.oldItemData = {}; this.initOldItemData(); - this.todoPickUpLog = []; + this.todoPickUpLog = {}; this.clearLog = false; this.registerStep(true, 5, () => { @@ -197,14 +197,16 @@ class GlobalSettings extends Feature { let todoText = []; if (!this.clearLog) { if (pick) { - this.todoPickUpLog.forEach((i, index, array) => { //positive and negative prefix colors - if (Math.abs(i.timeStamp - now) > 5000) { - array.splice(index, 1) + Object.keys(this.todoPickUpLog).forEach((i) => { + if (Math.abs(this.todoPickUpLog[i].timeStamp - now) > 5000 || !this.todoPickUpLog[i].Amount) { + delete this.todoPickUpLog[i] + return } - todoText.push((i.Amount > 0 ? "&r&a+ " : "&r&c- ") + Math.abs(i.Amount == 0 ? 1 : i.Amount) + "x &r" + i.itemName) - }); + //positive and negative prefix colors + todoText.push((this.todoPickUpLog[i].Amount > 0 ? "&r&a+ " : "&r&c- ") + Math.abs(this.todoPickUpLog[i].Amount == 0 ? 1 : this.todoPickUpLog[i].Amount) + "x &r" + i) + }) } else { - this.todoPickUpLog = []; + this.todoPickUpLog = {}; } } // doesn't need to put setText() in if (pick) cuz if (!pick) it clears the todo log list @@ -394,11 +396,16 @@ class GlobalSettings extends Feature { } addToTodoPickUpLog(timestamp, itemname, amount) { - this.todoPickUpLog.push({ + let basicValue = 0 + if (this.todoPickUpLog[itemname]) { + if (this.todoPickUpLog[itemname].Amount > 0) { + basicValue = this.todoPickUpLog[itemname].Amount + } + } + this.todoPickUpLog[itemname] = { timeStamp: timestamp, - itemName: itemname, - Amount: amount - }) + Amount: basicValue + amount + } } initOldItemData() { |