From: TheSaminator Date: Wed, 25 May 2022 22:01:12 +0000 (-0400) Subject: Slight refactor X-Git-Url: https://gitweb.starshipfights.net/?a=commitdiff_plain;h=d8a0f0e8dc9aa364ed606774b23da4fb8eec3e3e;p=starship-fights Slight refactor --- 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())