From 64d2c04fcbda888533c646072ff5aee04491d692 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Mon, 1 Jun 2020 18:29:17 +0200 Subject: [PATCH] Swap playWithMaxUnits after applying boosts --- GoldWars/GoldWars/RoundCalculatorService.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/GoldWars/GoldWars/RoundCalculatorService.swift b/GoldWars/GoldWars/RoundCalculatorService.swift index 5792e59..af824c4 100644 --- a/GoldWars/GoldWars/RoundCalculatorService.swift +++ b/GoldWars/GoldWars/RoundCalculatorService.swift @@ -88,6 +88,13 @@ class RoundCalculatorService { if boosts[playerMoveWithSecMaxUnits.key]!.0 { playerMoveWithSecMaxUnits.value.unitCount = Int(Double(playerMoveWithSecMaxUnits.value.unitCount) * ATK_BOOST_MULTIPLICATOR) } + + if playerMoveWithMaxUnits.value.unitCount < playerMoveWithSecMaxUnits.value.unitCount { + let temp = playerMoveWithMaxUnits + playerMoveWithMaxUnits = playerMoveWithSecMaxUnits + playerMoveWithSecMaxUnits = temp + } + playerMoveWithMaxUnits.value.unitCount -= playerMoveWithSecMaxUnits.value.unitCount }