From dcdcc3bc8cc528ab4c626bec8822034050b01840 Mon Sep 17 00:00:00 2001 From: AlatarTheYoung <110571755+AlatarTheYoung@users.noreply.github.com> Date: Mon, 23 Jan 2023 22:56:14 +0100 Subject: [PATCH] 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 * Added conversion to Long Co-authored-by: Yair Morgenstern --- core/src/com/unciv/logic/battle/Battle.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/com/unciv/logic/battle/Battle.kt b/core/src/com/unciv/logic/battle/Battle.kt index bb503bfe6e..49a66a818a 100644 --- a/core/src/com/unciv/logic/battle/Battle.kt +++ b/core/src/com/unciv/logic/battle/Battle.kt @@ -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 {