Fix some issues with initiative calculation & chat scrolling
authorTheSaminator <TheSaminator@users.noreply.github.com>
Sat, 28 May 2022 17:35:18 +0000 (13:35 -0400)
committerTheSaminator <TheSaminator@users.noreply.github.com>
Sat, 28 May 2022 17:38:23 +0000 (13:38 -0400)
src/commonMain/kotlin/starshipfights/game/game_initiative.kt
src/jsMain/kotlin/starshipfights/game/game_ui.kt

index b8cab0032d922586785fbbda88c980848c06639f..7d8e4d42b3950504ec0ee3baa70cb14d8437d0e2 100644 (file)
@@ -47,8 +47,11 @@ fun GameState.calculateAttackPhaseInitiative(): InitiativePair = InitiativePair(
                                                .filterValues { weaponInstance ->
                                                        when (val weapon = weaponInstance.weapon) {
                                                                is AreaWeapon -> true
-                                                               else -> ships.values.any { target ->
-                                                                       target.position.location in ship.getWeaponPickRequest(weapon).boundary
+                                                               else -> {
+                                                                       val pickRequest = ship.getWeaponPickRequest(weapon)
+                                                                       ships.values.any { target ->
+                                                                               target.owner in (pickRequest.type as PickType.Ship).allowSides && target.position.location in pickRequest.boundary
+                                                                       }
                                                                }
                                                        }
                                                }
index 197d24e0107e4cd9837f87059a12ea91e6e6fb2f..0a6d7233f25f41c9f48447415b9860ef407ad665 100644 (file)
@@ -364,7 +364,7 @@ object GameUI {
                                        }
                                }
                        }
-               }
+               }.last().scrollIntoView()
                
                val abilities = state.getPossibleAbilities(mySide)