Skip to content

Commit

Permalink
Ship: reimplement "turn_rate"
Browse files Browse the repository at this point in the history
  • Loading branch information
biqqles committed Nov 5, 2020
1 parent 1651833 commit 6319b5b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions flint/entities/ship.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"""
from typing import Tuple, List, Optional
import math
from statistics import mean

from . import Entity, EntitySet
from .goods import ShipHull, ShipPackage
Expand Down Expand Up @@ -75,6 +74,14 @@ def type(self) -> str:
"""The name of the type (class) of this ship."""
return self.TYPE_ID_TO_NAME.get(self.ship_class)

def turn_rate(self) -> float:
"""The maximum turn rate (i.e. angular speed) of this ship in degrees per second.
TODO: this is inaccurate for vectors with unequal elements but is *reasonably* accurate for now."""
try:
return math.degrees(min(self.steering_torque) / min(self.angular_drag))
except TypeError:
return 0

def equipment(self) -> EntitySet[Equipment]:
"""The set of this ship package's equipment upon purchase."""
package = self.package()
Expand All @@ -101,12 +108,12 @@ def impulse_speed(self) -> float:
def reverse_speed(self) -> float:
"""The maximum reverse speed of this ship."""
engine = self.engine()
return self.impulse_speed() * self.engine().reverse_fraction if engine else 0
return self.impulse_speed() * engine.reverse_fraction if engine else 0

def cruise_charge_time(self):
"""The time taken to charge this ship's cruise engine."""
engine = self.engine()
return self.engine().cruise_charge_time if engine else 0
return engine.cruise_charge_time if engine else 0

TYPE_ID_TO_NAME = {0: 'Light Fighter',
1: 'Heavy Fighter',
Expand Down

0 comments on commit 6319b5b

Please sign in to comment.