Add total fleet strength calculation
authorTheSaminator <thesaminator@users.noreply.github.com>
Mon, 4 Jul 2022 22:33:11 +0000 (18:33 -0400)
committerTheSaminator <thesaminator@users.noreply.github.com>
Mon, 4 Jul 2022 22:33:11 +0000 (18:33 -0400)
src/commonMain/kotlin/net/starshipfights/campaign/fleet_presence.kt
src/commonMain/kotlin/net/starshipfights/campaign/star_systems.kt
src/jsMain/kotlin/net/starshipfights/campaign/campaign_ui.kt

index 926e8afd3f6b1f38d715800194b21f6829af6b09..822775c8541bd7d74ae1f5596cad289c7ee17aa3 100644 (file)
@@ -47,6 +47,9 @@ data class FleetPresence(
        val admiralIsFemale: Boolean,
        val admiralRank: AdmiralRank,
 ) {
+       val pointValue: Int
+               get() = ships.values.sumOf { it.pointCost }
+       
        val admiralFullName: String
                get() = "${admiralRank.getDisplayName(owner)} $admiralName"
 }
index c237444dd88d847d71d848ea14eecb3eeb5574e7..9c7afa3e494b7a2f62d416ff4d4595716511e6dd 100644 (file)
@@ -28,7 +28,10 @@ data class StarSystem(
        val position: Position,
        val radius: Double,
        val bodies: Map<Id<CelestialObject>, CelestialObject>
-)
+) {
+       val totalFleetStrength: Int
+               get() = fleets.values.sumOf { it.pointValue }
+}
 
 @Serializable
 data class WarpLane(
index bc629cb921c5f1f41040f9ca0270564ac231c248..2be1410cb4549ec19eee22456197532c3b70fc5f 100644 (file)
@@ -203,6 +203,19 @@ object CampaignUI {
                                                        +" system"
                                                }
                                        }
+                                       p {
+                                               style = "text-align:center"
+                                               +when (system.bodies.values.filterIsInstance<CelestialObject.Star>().size) {
+                                                       1 -> "Unary star system"
+                                                       2 -> "Binary star system"
+                                                       3 -> "Trinary star system"
+                                                       0 -> "Rogue planet system"
+                                                       else -> "Multiple star system"
+                                               }
+                                               val planets = system.bodies.values.filterIsInstance<CelestialObject.Planet>()
+                                               val habitablePlanets = planets.filter { it.type == PlanetType.TERRESTRIAL }
+                                               +" with ${planets.size} planets, ${habitablePlanets.size} of them habitable"
+                                       }
                                        p {
                                                style = "text-align:center"
                                                +(system.holder?.loyalties?.first()?.getDefiniteShortName()?.let { "Controlled by $it" } ?: "Wilderness")
@@ -213,6 +226,10 @@ object CampaignUI {
                                                        img(alt = it.displayName, src = it.flagUrl) { style = "width:4em;height:2.5em" }
                                                }
                                        }
+                                       p {
+                                               style = "text-align:center"
+                                               +"${system.totalFleetStrength} fleet strength"
+                                       }
                                        
                                        selectedSystemIndicators[selection.id]?.visible = true
                                        visibleSelectedSystemIndicators += selection.id