Bring back old behavior where exhaustion is immediately nullified by energy buffer on Androids

This commit is contained in:
DBotThePony 2025-03-14 17:36:55 +07:00
parent 5d8f2d5a4a
commit ca37b4959f
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -69,21 +69,20 @@ class MatteryFoodData(private var player: Player) : FoodData() {
private var energyToDrain = Decimal.ZERO
private fun tickExhaustion() {
if (exhaustionLevel >= EXHAUSTION_PER_HUNGER_POINT) {
if (player.matteryPlayer.isAndroid && exhaustionLevel > 0f) {
energyToDrain += PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * (exhaustionLevel / EXHAUSTION_PER_HUNGER_POINT)
exhaustionLevel = 0f
} else if (exhaustionLevel >= EXHAUSTION_PER_HUNGER_POINT) {
var points = (exhaustionLevel / EXHAUSTION_PER_HUNGER_POINT).toInt()
exhaustionLevel %= EXHAUSTION_PER_HUNGER_POINT
if (player.matteryPlayer.isAndroid) {
energyToDrain += PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * points
} else {
if (saturationLevel > 0f) {
val satisfied = min(saturationLevel.roundToInt(), points)
points -= satisfied
saturationLevel -= satisfied
}
foodLevel = max(0, foodLevel - points)
if (saturationLevel > 0f) {
val satisfied = min(saturationLevel.roundToInt(), points)
points -= satisfied
saturationLevel -= satisfied
}
foodLevel = max(0, foodLevel - points)
}
}