From d8a0f0e8dc9aa364ed606774b23da4fb8eec3e3e Mon Sep 17 00:00:00 2001 From: TheSaminator Date: Wed, 25 May 2022 18:01:12 -0400 Subject: [PATCH] Slight refactor --- .../kotlin/starshipfights/game/ship_instances.kt | 12 ++++++------ .../kotlin/starshipfights/game/ship_weapons.kt | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/commonMain/kotlin/starshipfights/game/ship_instances.kt b/src/commonMain/kotlin/starshipfights/game/ship_instances.kt index dc773ce..678dbff 100644 --- a/src/commonMain/kotlin/starshipfights/game/ship_instances.kt +++ b/src/commonMain/kotlin/starshipfights/game/ship_instances.kt @@ -54,6 +54,12 @@ data class ShipInstance( else -> false } && felinaeShipPowerMode == FelinaeShipPowerMode.INERTIALESS_DRIVE + val remainingInertialessDriveJumps: Int + get() = when (val movement = ship.movement) { + is FelinaeShipMovement -> movement.inertialessDriveShots - usedInertialessDriveShots + else -> 0 + } + val canUseDisruptionPulse: Boolean get() = ship.canUseDisruptionPulse && modulesStatus[ShipModule.Turrets].canBeUsed && when (val durability = ship.durability) { is FelinaeShipDurability -> usedDisruptionPulseShots < durability.disruptionPulseShots @@ -66,12 +72,6 @@ data class ShipInstance( else -> 0 } - val remainingInertialessDriveJumps: Int - get() = when (val movement = ship.movement) { - is FelinaeShipMovement -> movement.inertialessDriveShots - usedInertialessDriveShots - else -> 0 - } - val canUseRecoalescence: Boolean get() = ship.canUseRecoalescence && felinaeShipPowerMode == FelinaeShipPowerMode.HULL_RECOALESCENSE && !isDoneCurrentPhase && hullAmount < durability.maxHullPoints && recoalescenceMaxHullDamage < (ship.durability.maxHullPoints - 1) diff --git a/src/commonMain/kotlin/starshipfights/game/ship_weapons.kt b/src/commonMain/kotlin/starshipfights/game/ship_weapons.kt index 4b2de43..bd08193 100644 --- a/src/commonMain/kotlin/starshipfights/game/ship_weapons.kt +++ b/src/commonMain/kotlin/starshipfights/game/ship_weapons.kt @@ -342,8 +342,8 @@ fun ShipInstance.felinaeArmorIgnoreDamageChance(): Double { val maxVelocity = movement.moveSpeed val curVelocity = currentVelocity val ratio = curVelocity / maxVelocity - val exponent = -ratio / sqrt(1 + abs(4 * ratio)) - return -expm1(exponent) + val exponent = ratio / sqrt(1 + abs(4 * ratio)) + return -expm1(-exponent) } fun ShipInstance.impact(damage: Int, ignoreShields: Boolean = false) = if (durability is FelinaeShipDurability && Random.nextDouble() < felinaeArmorIgnoreDamageChance()) -- 2.25.1