Intact ships now need no maintenance
authorTheSaminator <TheSaminator@users.noreply.github.com>
Thu, 9 Jun 2022 15:41:22 +0000 (11:41 -0400)
committerTheSaminator <TheSaminator@users.noreply.github.com>
Thu, 9 Jun 2022 15:41:22 +0000 (11:41 -0400)
src/jvmMain/kotlin/net/starshipfights/game/server_game.kt

index a73eab8ca2a30324af69e007430bdb5a00078003..71600a21df79c27f2104a743127b8554bb5fe252 100644 (file)
@@ -210,7 +210,6 @@ private val BattleSize.acumenPerSubplotWon: Int
 
 private suspend fun onGameEnd(gameState: GameState, gameEnd: GameEvent.GameEnd, startedAt: Instant, endedAt: Instant) {
        val damagedShipReadyAt = endedAt.plus(6, ChronoUnit.HOURS)
-       val intactShipReadyAt = endedAt.plus(4, ChronoUnit.HOURS)
        val escapedShipReadyAt = endedAt.plus(4, ChronoUnit.HOURS)
        
        val shipWrecks = gameState.destroyedShips
@@ -255,8 +254,7 @@ private suspend fun onGameEnd(gameState: GameState, gameEnd: GameEvent.GameEnd,
        }
        
        val escapedShips = shipWrecks.filterValues { it.isEscape }.keys.map { it.reinterpret<ShipInDrydock>() }.toSet()
-       val damagedShips = ships.filterValues { it.hullAmount < it.durability.maxHullPoints }.keys.map { it.reinterpret<ShipInDrydock>() }.toSet()
-       val intactShips = ships.keys.map { it.reinterpret<ShipInDrydock>() }.toSet() - damagedShips
+       val damagedShips = ships.filterValues { it.hullAmount < it.durability.maxHullPoints || it.troopsAmount < it.durability.troopsDefense }.keys.map { it.reinterpret<ShipInDrydock>() }.toSet()
        
        val battleSize = gameState.battleInfo.size
        
@@ -280,9 +278,6 @@ private suspend fun onGameEnd(gameState: GameState, gameEnd: GameEvent.GameEnd,
                launch {
                        ShipInDrydock.update(ShipInDrydock::id `in` damagedShips, setValue(ShipInDrydock::readyAt, damagedShipReadyAt))
                }
-               launch {
-                       ShipInDrydock.update(ShipInDrydock::id `in` intactShips, setValue(ShipInDrydock::readyAt, intactShipReadyAt))
-               }
                launch {
                        ShipInDrydock.update(ShipInDrydock::id `in` escapedShips, setValue(ShipInDrydock::readyAt, escapedShipReadyAt))
                }