blob: a0b2b426d62e1def0eab852d511d3e53a750e9d6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
package at.hannibal2.skyhanni.utils.tracker
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import com.google.gson.annotations.Expose
abstract class ItemTrackerData : TrackerData() {
abstract fun resetItems()
abstract fun getDescription(timesGained: Long): List<String>
abstract fun getCoinName(item: TrackedItem): String
abstract fun getCoinDescription(item: TrackedItem): List<String>
open fun getCustomPricePer(internalName: NEUInternalName) = SkyHanniTracker.getPricePer(internalName)
override fun reset() {
items.clear()
resetItems()
}
fun addItem(internalName: NEUInternalName, amount: Int, command: Boolean) {
val item = items.getOrPut(internalName) { TrackedItem() }
if (!command) {
item.timesGained++
}
item.totalAmount += amount
item.lastTimeUpdated = SimpleTimeMark.now()
if (command && item.totalAmount <= 0) {
items.remove(internalName)
}
}
@Expose
var items: MutableMap<NEUInternalName, TrackedItem> = HashMap()
class TrackedItem {
@Expose
var timesGained: Long = 0
@Expose
var totalAmount: Long = 0
@Expose
var hidden = false
var lastTimeUpdated = SimpleTimeMark.farPast()
fun copy(
timesGained: Long = this.timesGained,
totalAmount: Long = this.totalAmount,
hidden: Boolean = this.hidden,
lastTimeUpdated: SimpleTimeMark = this.lastTimeUpdated,
): TrackedItem {
val copy = TrackedItem()
copy.timesGained = timesGained
copy.totalAmount = totalAmount
copy.hidden = hidden
copy.lastTimeUpdated = lastTimeUpdated
return copy
}
}
}
|