From: TheSaminator Date: Sat, 28 May 2022 16:40:11 +0000 (-0400) Subject: Recalculate attack phase initiative when it is necessary to do so X-Git-Url: https://gitweb.starshipfights.net/?a=commitdiff_plain;h=0e1e987c8a6f2caa7bd59e828a791df9ba65003b;p=starship-fights Recalculate attack phase initiative when it is necessary to do so --- 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