Improved accuracy of player wealth calculation
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user