Slight refactor
authorTheSaminator <TheSaminator@users.noreply.github.com>
Wed, 25 May 2022 22:01:12 +0000 (18:01 -0400)
committerTheSaminator <TheSaminator@users.noreply.github.com>
Wed, 25 May 2022 22:10:49 +0000 (18:10 -0400)
src/commonMain/kotlin/starshipfights/game/ship_instances.kt
src/commonMain/kotlin/starshipfights/game/ship_weapons.kt

index dc773ceb6cc388bff8c9020b2741e02669205b54..678dbff091f1da96ac4e91fb473189e14a56c0f5 100644 (file)
@@ -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)
        
index 4b2de43bf7a0ac092fe5127735eda363fb7c5f20..bd08193122c406d32683cbc9676f47b3be7670b2 100644 (file)
@@ -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())