From 0e1e987c8a6f2caa7bd59e828a791df9ba65003b Mon Sep 17 00:00:00 2001 From: TheSaminator Date: Sat, 28 May 2022 12:40:11 -0400 Subject: [PATCH] Recalculate attack phase initiative when it is necessary to do so --- .../kotlin/starshipfights/game/game_initiative.kt | 7 +++++-- src/commonMain/kotlin/starshipfights/game/ship_weapons.kt | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/commonMain/kotlin/starshipfights/game/game_initiative.kt b/src/commonMain/kotlin/starshipfights/game/game_initiative.kt index 25fd6fd..b8cab00 100644 --- a/src/commonMain/kotlin/starshipfights/game/game_initiative.kt +++ b/src/commonMain/kotlin/starshipfights/game/game_initiative.kt @@ -45,8 +45,11 @@ fun GameState.calculateAttackPhaseInitiative(): InitiativePair = InitiativePair( .sumOf { ship -> val allWeapons = ship.armaments.weaponInstances .filterValues { weaponInstance -> - ships.values.any { target -> - target.position.location in ship.getWeaponPickRequest(weaponInstance.weapon).boundary + when (val weapon = weaponInstance.weapon) { + is AreaWeapon -> true + else -> ships.values.any { target -> + target.position.location in ship.getWeaponPickRequest(weapon).boundary + } } } val usableWeapons = allWeapons - ship.usedArmaments diff --git a/src/commonMain/kotlin/starshipfights/game/ship_weapons.kt b/src/commonMain/kotlin/starshipfights/game/ship_weapons.kt index 464dfd0..7fa0012 100644 --- a/src/commonMain/kotlin/starshipfights/game/ship_weapons.kt +++ b/src/commonMain/kotlin/starshipfights/game/ship_weapons.kt @@ -683,6 +683,7 @@ fun GameState.useWeaponPickResponse(attacker: ShipInstance, weaponId: Id { @@ -706,6 +707,7 @@ fun GameState.useWeaponPickResponse(attacker: ShipInstance, weaponId: Id