From: TheSaminator Date: Tue, 5 Jul 2022 15:19:41 +0000 (-0400) Subject: Extract battle-size generation X-Git-Url: https://gitweb.starshipfights.net/?a=commitdiff_plain;h=82a98fefea632d9f8e8003c6fe6977beff5811ab;p=starship-fights Extract battle-size generation --- diff --git a/src/jvmMain/kotlin/net/starshipfights/game/game_start_jvm.kt b/src/jvmMain/kotlin/net/starshipfights/game/game_start_jvm.kt index 3cfca24..461c103 100644 --- a/src/jvmMain/kotlin/net/starshipfights/game/game_start_jvm.kt +++ b/src/jvmMain/kotlin/net/starshipfights/game/game_start_jvm.kt @@ -5,9 +5,10 @@ import net.starshipfights.data.admiralty.generateFleet import net.starshipfights.data.admiralty.getAdmiralsShips import kotlin.math.PI +fun battleSize() = ((25..35).random() * 500.0) to ((15..45).random() * 500.0) + suspend fun generate1v1GameInitialState(hostInfo: InGameAdmiral, guestInfo: InGameAdmiral, battleInfo: BattleInfo): GameState { - val battleWidth = (25..35).random() * 500.0 - val battleLength = (15..45).random() * 500.0 + val (battleWidth, battleLength) = battleSize() val deployWidth2 = battleWidth / 2 val deployLength2 = 875.0 @@ -54,8 +55,7 @@ suspend fun generate1v1GameInitialState(hostInfo: InGameAdmiral, guestInfo: InGa } suspend fun generate2v1GameInitialState(player1Info: InGameAdmiral, player2Info: InGameAdmiral, enemyFaction: Faction, enemyFlavor: FactionFlavor, battleInfo: BattleInfo): GameState { - val battleWidth = (25..35).random() * 500.0 - val battleLength = (15..45).random() * 500.0 + val (battleWidth, battleLength) = battleSize() val deployWidth2 = battleWidth / 2 val deployLength2 = 875.0 @@ -135,8 +135,7 @@ suspend fun generate2v1GameInitialState(player1Info: InGameAdmiral, player2Info: } suspend fun generateTrainingInitialState(playerInfo: InGameAdmiral, enemyFaction: Faction, enemyFlavor: FactionFlavor, battleInfo: BattleInfo): GameState { - val battleWidth = (25..35).random() * 500.0 - val battleLength = (15..45).random() * 500.0 + val (battleWidth, battleLength) = battleSize() val deployWidth2 = battleWidth / 2 val deployLength2 = 875.0