Improved accuracy of player wealth calculation

This commit is contained in:
Avi Weinstock
2023-03-03 02:15:52 +00:00
committed by Ryan
parent f1e2083506
commit eeedafe637
3 changed files with 37 additions and 1 deletions
@@ -237,4 +237,22 @@ class GrandExchangeOffer() {
return o
}
}
fun cacheValue(): Int {
var value = 0
if(sell) {
// count the cache value of the unsold items
value += ItemDefinition.forId(itemID).getValue() * amountLeft
} else {
// count the number of coins that haven't yet been spent
value += offeredValue * amountLeft
}
// for both the buyer and seller, the already completed portion is present in withdraw
for(item in withdraw) {
if(item != null) {
value += item.definition.value * item.amount
}
}
return value
}
}
@@ -251,4 +251,4 @@ class GrandExchangeRecords(private val player: Player? = null) : PersistPlayer,
return player?.getAttribute("ge-records", GrandExchangeRecords()) ?: GrandExchangeRecords()
}
}
}
}