Modification of the random part of Prize Ship to avoid save scumming (#8448)

* Modification of the random part of Prize Ship to avoid save scumming

* Update core/src/com/unciv/logic/battle/Battle.kt

Code modification for readability

Co-authored-by: Yair Morgenstern <yairm210@hotmail.com>

* Added conversion to Long

Co-authored-by: Yair Morgenstern <yairm210@hotmail.com>
This commit is contained in:
AlatarTheYoung 2023-01-23 22:56:14 +01:00 committed by GitHub
parent 04cb4bd2a9
commit dcdcc3bc8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -242,7 +242,9 @@ object Battle {
0.1f + attacker.getAttackingStrength().toFloat() / defender.getDefendingStrength()
.toFloat() * 0.4f
)
return Random().nextFloat() <= captureChance
/** Between 0 and 1. Defaults to turn and location-based random to avoid save scumming */
val random = Random((attacker.getCivInfo().gameInfo.turns * defender.getTile().position.hashCode()).toLong())
return random.nextFloat() <= captureChance
}
fun unitGainFromEncampment(): Boolean {