From cc3403bbc9a6d004751009dabd93480a95c610da Mon Sep 17 00:00:00 2001 From: TheSaminator Date: Sun, 20 Feb 2022 11:40:38 -0500 Subject: [PATCH] Rework Isarnareyksk superweapon --- .../kotlin/starshipfights/game/game_state.kt | 9 ---- .../starshipfights/game/ship_instances.kt | 1 - .../starshipfights/game/ship_weapons.kt | 51 ++++++++++--------- .../game/ship_weapons_formats.kt | 2 +- .../kotlin/starshipfights/game/game_ui.kt | 23 ++------- .../images/small-craft-disrupted.svg | 16 ------ .../kotlin/starshipfights/info/views_ships.kt | 8 +-- 7 files changed, 36 insertions(+), 74 deletions(-) delete mode 100644 src/jsMain/resources/images/small-craft-disrupted.svg diff --git a/src/commonMain/kotlin/starshipfights/game/game_state.kt b/src/commonMain/kotlin/starshipfights/game/game_state.kt index ae2a0d0..757ed96 100644 --- a/src/commonMain/kotlin/starshipfights/game/game_state.kt +++ b/src/commonMain/kotlin/starshipfights/game/game_state.kt @@ -72,15 +72,6 @@ fun GameState.afterPlayerReady(playerSide: GlobalSide) = if (ready == playerSide if (ship.bomberWings.isEmpty()) return@strikeBombard id to ship - if (ship.strikeCraftDisrupted) { - (ship.fighterWings + ship.bomberWings).forEach { - val (carrierId, wingId) = it - val maxDamage = (newShips[carrierId]?.armaments?.weaponInstances?.get(wingId) as? ShipWeaponInstance.Hangar)?.wingHealth ?: 0.0 - strikeWingDamage[it] = Random.nextDouble() * maxDamage - } - return@strikeBombard id to ship - } - val totalFighterHealth = ship.fighterWings.sumOf { (carrierId, wingId) -> (newShips[carrierId]?.armaments?.weaponInstances?.get(wingId) as? ShipWeaponInstance.Hangar)?.wingHealth ?: 0.0 } diff --git a/src/commonMain/kotlin/starshipfights/game/ship_instances.kt b/src/commonMain/kotlin/starshipfights/game/ship_instances.kt index d81fd4c..28df75f 100644 --- a/src/commonMain/kotlin/starshipfights/game/ship_instances.kt +++ b/src/commonMain/kotlin/starshipfights/game/ship_instances.kt @@ -26,7 +26,6 @@ data class ShipInstance( val fighterWings: List = emptyList(), val bomberWings: List = emptyList(), - val strikeCraftDisrupted: Boolean = false ) { val id: Id get() = ship.id.reinterpret() diff --git a/src/commonMain/kotlin/starshipfights/game/ship_weapons.kt b/src/commonMain/kotlin/starshipfights/game/ship_weapons.kt index f3859f2..ea6cceb 100644 --- a/src/commonMain/kotlin/starshipfights/game/ship_weapons.kt +++ b/src/commonMain/kotlin/starshipfights/game/ship_weapons.kt @@ -112,7 +112,7 @@ sealed class ShipWeapon { get() = 7_000.0 override val areaRadius: Double - get() = 600.0 + get() = 450.0 override val firingArcs: Set get() = setOf(FiringArc.BOW) @@ -132,7 +132,7 @@ sealed class ShipWeapon { get() = 1 override val maxRange: Double - get() = 2_500.0 + get() = 2_000.0 override val areaRadius: Double get() = SHIP_BASE_SIZE @@ -149,30 +149,30 @@ sealed class ShipWeapon { override val groupLabel: String get() = "Revelation Gun" - override fun instantiate() = ShipWeaponInstance.RevelationGun(false) + override fun instantiate() = ShipWeaponInstance.RevelationGun(numShots) } @Serializable - object PulseBeam : ShipWeapon(), AreaWeapon { + object EmpAntenna : ShipWeapon(), AreaWeapon { override val numShots: Int - get() = 1 + get() = 4 override val maxRange: Double - get() = 3_500.0 + get() = 3_000.0 override val areaRadius: Double - get() = 900.0 + get() = 650.0 override val firingArcs: Set - get() = FiringArc.FIRE_360 + get() = setOf(FiringArc.BOW) override val isNormal: Boolean get() = false override val groupLabel: String - get() = "Small Craft Disruptor" + get() = "EMP Emitter" - override fun instantiate() = ShipWeaponInstance.PulseBeam(0) + override fun instantiate() = ShipWeaponInstance.EmpAntenna(numShots) } } @@ -184,11 +184,6 @@ enum class StrikeCraftWing { val iconUrl: String get() = "/static/game/images/strike-craft-${toUrlSlug()}.svg" - - companion object { - val disruptedIconUrl: String - get() = "/static/game/images/small-craft-disrupted.svg" - } } @Serializable @@ -219,15 +214,15 @@ sealed class ShipWeaponInstance { } @Serializable - data class RevelationGun(val hasBeenUsed: Boolean) : ShipWeaponInstance() { + data class RevelationGun(val remainingShots: Int) : ShipWeaponInstance() { override val weapon: ShipWeapon get() = ShipWeapon.RevelationGun } @Serializable - data class PulseBeam(val cooldown: Int) : ShipWeaponInstance() { + data class EmpAntenna(val remainingShots: Int) : ShipWeaponInstance() { override val weapon: ShipWeapon - get() = ShipWeapon.PulseBeam + get() = ShipWeapon.EmpAntenna } } @@ -287,7 +282,14 @@ fun ShipInstance.afterUsing(weaponId: Id) = when (val weapon = armam } is ShipWeaponInstance.RevelationGun -> { val newWeapons = armaments.weaponInstances + mapOf( - weaponId to weapon.copy(hasBeenUsed = true) + weaponId to weapon.copy(remainingShots = weapon.remainingShots - 1) + ) + + copy(armaments = ShipInstanceArmaments(newWeapons), usedArmaments = usedArmaments + setOf(weaponId)) + } + is ShipWeaponInstance.EmpAntenna -> { + val newWeapons = armaments.weaponInstances + mapOf( + weaponId to weapon.copy(remainingShots = weapon.remainingShots - 1) ) copy(armaments = ShipInstanceArmaments(newWeapons), usedArmaments = usedArmaments + setOf(weaponId)) @@ -339,9 +341,12 @@ fun ShipInstance.afterTargeted(by: ShipInstance, weaponId: Id) = whe is ShipWeaponInstance.RevelationGun -> { ImpactResult.Destroyed(ShipWreck(ship, owner)) } - is ShipWeaponInstance.PulseBeam -> { + is ShipWeaponInstance.EmpAntenna -> { ImpactResult.Damaged( - copy(strikeCraftDisrupted = true) + copy( + weaponAmount = (0..weaponAmount).random(), + shieldAmount = (0..shieldAmount).random(), + ) ) } } @@ -352,8 +357,8 @@ fun canWeaponBeUsed(shipInstance: ShipInstance, shipWeapon: ShipWeaponInstance): is ShipWeaponInstance.Lance -> shipWeapon.numCharges > 0 is ShipWeaponInstance.Torpedo -> true is ShipWeaponInstance.MegaCannon -> shipWeapon.remainingShots > 0 - is ShipWeaponInstance.RevelationGun -> !shipWeapon.hasBeenUsed - is ShipWeaponInstance.PulseBeam -> shipWeapon.cooldown == 0 + is ShipWeaponInstance.RevelationGun -> shipWeapon.remainingShots > 0 + is ShipWeaponInstance.EmpAntenna -> shipWeapon.remainingShots > 0 } fun getWeaponPickRequest(weapon: ShipWeapon, position: ShipPosition, side: GlobalSide): PickRequest = when (weapon) { diff --git a/src/commonMain/kotlin/starshipfights/game/ship_weapons_formats.kt b/src/commonMain/kotlin/starshipfights/game/ship_weapons_formats.kt index 0099524..c6cbbb6 100644 --- a/src/commonMain/kotlin/starshipfights/game/ship_weapons_formats.kt +++ b/src/commonMain/kotlin/starshipfights/game/ship_weapons_formats.kt @@ -128,7 +128,7 @@ fun fulkreykkShipWeapons( } if (hasPulseBeam) - idCounter.add(weapons, ShipWeapon.PulseBeam) + idCounter.add(weapons, ShipWeapon.EmpAntenna) repeat(cannonSections) { idCounter.add(weapons, ShipWeapon.Cannon(3, setOf(FiringArc.ABEAM_PORT), "Port cannon battery")) diff --git a/src/jsMain/kotlin/starshipfights/game/game_ui.kt b/src/jsMain/kotlin/starshipfights/game/game_ui.kt index 5c984cc..6dffa1c 100644 --- a/src/jsMain/kotlin/starshipfights/game/game_ui.kt +++ b/src/jsMain/kotlin/starshipfights/game/game_ui.kt @@ -134,7 +134,7 @@ object GameUI { suspend fun displayErrorMessage(message: String) { errorMessages.textContent = message - delay(3750) + delay(5000) errorMessages.textContent = "" } @@ -454,23 +454,6 @@ object GameUI { }.toPercent() } } - - +Entities.nbsp - - if (ship.strikeCraftDisrupted) { - span { - val (borderColor, fillColor) = when (ship.owner.relativeTo(mySide)) { - LocalSide.BLUE -> "#39F" to "#135" - LocalSide.RED -> "#F66" to "#522" - } - - style = "display:inline-block;border:5px solid $borderColor;border-radius:15px;background-color:$fillColor;color:#fff" - - img(src = StrikeCraftWing.disruptedIconUrl, alt = "Strike Craft Disrupted") { - style = "width:1.125em" - } - } - } } } } @@ -736,8 +719,8 @@ object GameUI { } + " (${weaponInstance.wingHealth.toPercent()})" is ShipWeaponInstance.Torpedo -> "Torpedo" + (if (weaponIsPlural) "es" else "") is ShipWeaponInstance.MegaCannon -> "Mega Giga Cannon (" + weaponInstance.remainingShots + ")" - is ShipWeaponInstance.RevelationGun -> "Revelation Gun" - is ShipWeaponInstance.PulseBeam -> "Small Craft Disruptor" + is ShipWeaponInstance.RevelationGun -> "Revelation Gun (" + weaponInstance.remainingShots + ")" + is ShipWeaponInstance.EmpAntenna -> "EMP Antenna (" + weaponInstance.remainingShots + ")" } when (ability) { diff --git a/src/jsMain/resources/images/small-craft-disrupted.svg b/src/jsMain/resources/images/small-craft-disrupted.svg deleted file mode 100644 index d1c06e6..0000000 --- a/src/jsMain/resources/images/small-craft-disrupted.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - diff --git a/src/jvmMain/kotlin/starshipfights/info/views_ships.kt b/src/jvmMain/kotlin/starshipfights/info/views_ships.kt index e2b7467..5673464 100644 --- a/src/jvmMain/kotlin/starshipfights/info/views_ships.kt +++ b/src/jvmMain/kotlin/starshipfights/info/views_ships.kt @@ -25,7 +25,7 @@ suspend fun ApplicationCall.shipsPage(): HTML.() -> Unit = page("Game Manual", s +"The four main types of weapons in Starship Fights are cannons, lances, torpedoes, and strike craft. Cannons fire bolts of massive particles that have a chance to miss their target; this chance increases with distance and relative velocity. Lances fire a beam of massless particles that strike their target instantly, however lances also need to be charged by spending Weapons Power. Torpedoes are strong against unshielded hulls, guaranteed to deal two impacts, but are weak against shields, with only a 50% chance to hit if the target has its shields up. Strike craft come in two flavors: fighters and bombers. Fighters are used to defend your ships from bombers, while bombers are used to attack hostile ships." } p { - +"There are also three types of special weapons: the Mechyrdians' Mega Giga Cannon, the Masra Draetsen Revelation Gun, and the Isarnareyksk Small Craft Disruptor. The Mega Giga Cannon fires a long-range projectile that deals severe damage to enemy ships, but has a limited number of shots. The Revelation Gun instantly vaporizes an enemy ship, but can only be used once in a battle. The Small Craft Disruptor destroys all small craft within a certain targeted range." + +"There are also three types of special weapons: the Mechyrdians' Mega Giga Cannon, the Masra Draetsen Revelation Gun, and the Isarnareyksk EMP Emitter. The Mega Giga Cannon fires a long-range projectile that deals severe damage to enemy ships, but has a limited number of shots. The Revelation Gun instantly vaporizes an enemy ship, but can only be used once in a battle. The EMP Antenna depletes by a random amount the targeted ships' subsystem powers." } h3 { +"Subsystem Powering" } p { @@ -146,7 +146,7 @@ suspend fun ApplicationCall.shipPage(shipType: ShipType): HTML.() -> Unit = page } } td { - weapon.minRange.takeIf { it != SHIP_BASE_SIZE }?.roundToInt()?.let { +"$it-" } + weapon.minRange.takeIf { it != SHIP_BASE_SIZE }?.let { +"${it.roundToInt()}-" } +"${weapon.maxRange.roundToInt()} meters" if (weapon is AreaWeapon) { br @@ -159,9 +159,9 @@ suspend fun ApplicationCall.shipPage(shipType: ShipType): HTML.() -> Unit = page is ShipWeapon.Lance -> "$numShots lance" + (if (numShots == 1) "" else "s") is ShipWeapon.Torpedo -> "$numShots launcher" + (if (numShots == 1) "" else "s") is ShipWeapon.Hangar -> "$numShots strike wing" + (if (numShots == 1) "" else "s") - ShipWeapon.MegaCannon -> "Severe" - ShipWeapon.PulseBeam -> "Disables strike craft" + ShipWeapon.MegaCannon -> "Severely damages targets" ShipWeapon.RevelationGun -> "Vaporizes target" + ShipWeapon.EmpAntenna -> "Randomly depletes targets' subsystems" } } } -- 2.25.1