From 6508f1544b610aa3961d55e9dd4b7463567a4f7d Mon Sep 17 00:00:00 2001 From: alanwatsonforster <68709385+alanwatsonforster@users.noreply.github.com> Date: Tue, 26 Sep 2023 09:05:50 -0600 Subject: [PATCH] Implement aircraft SPBR limits. --- airpower/aircraft.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/airpower/aircraft.py b/airpower/aircraft.py index 15efdf49..895b034d 100644 --- a/airpower/aircraft.py +++ b/airpower/aircraft.py @@ -168,7 +168,15 @@ def _H(self): self._x, self._y = aphex.nextposition(self._x, self._y, self._facing) def _J(self, configuration): - # See rule 4.4. We implement the delay of 1 FP by making this a non-movement element. + + """ + Jetison stores to achieve the specified configuration. + """ + + # See rule 4.4. + + # We implement the delay of 1 FP by making this an epilog element. + if self._configuration == configuration: raise ValueError("configuration is already %s." % configuration) if self._configuration == "CL" or configuration == "DT": @@ -182,13 +190,22 @@ def _K(self): self._destroyed = True def _S(self, spbrfp): - # TODO: check against aircraft SPBR capability. + + # See rule 6.5. + if self._spbrfp != 0: raise ValueError("speedbrakes can only be used once per turn.") + maxspbrfp = self._fp - self._hfp - self._vfp if spbrfp > maxspbrfp: - raise ValueError("attempt to use speedbrakes to eliminate %s FPs but only %s are remaining." % (spbrfp, maxspbrfp)) + raise ValueError("only %s FPs are remaining." % maxspbrfp) + + maxspbrfp = self._aircrafttype.SPBR(self._configuration): + if spbrfp > maxspbrfp: + raise ValueError("speedbrake capability is only %.1f FPs." % maxspbrfp) + self._spbrfp = spbrfp + self._spbrap = -spbrfp / 0.5 def _TD(self, turndirection, turnrate):