From 2bd2117448b47fda90326ed43521f7d74c6822fd Mon Sep 17 00:00:00 2001 From: alanwatsonforster <68709385+alanwatsonforster@users.noreply.github.com> Date: Sat, 7 Oct 2023 09:43:44 -0600 Subject: [PATCH] Implemented VR restrictions for HPR aircraft. --- airpower/aircraft/_normalflight.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/airpower/aircraft/_normalflight.py b/airpower/aircraft/_normalflight.py index 1143eebd..1c3db5e8 100644 --- a/airpower/aircraft/_normalflight.py +++ b/airpower/aircraft/_normalflight.py @@ -347,13 +347,18 @@ def doturn(sense, facingchange): def doverticalroll(sense, facingchange, shift): - # TODO: HPR restrictions + # See rule 13.3.4. + # TODO: LRR restrictions if self._flighttype != "VC" and self._flighttype != "VD": - raise RuntimeError("attempt to roll vertically while flight type is %s." % self._flighttype) + raise RuntimeError("attempt to roll vertically while flight type is %s." % self._flighttype) if not self._vertical: - raise RuntimeError("attempt to roll vertically during an HFP.") + raise RuntimeError("attempt to roll vertically during an HFP.") + + # The following applies only to HPR aircaft that enter a VC from LVL. + if self._lastflighttype == "LVL" and self._flighttype != "VC" and not self._lastfp: + raise RuntimeError("attempt to roll vertically following LVL flight and not on the last FP.") self._maneuverap -= self.rolldrag("VR") @@ -608,6 +613,11 @@ def doaction(action): if not self._unloaded: self._turnfp += 1 + # Some rules apply only to the last FP of a move, so we determine if this + # FP is the last FP. See rule 13.3.4. + fp = self._hfp + self._vfp + self._spbrfp + self._lastfp = (fp + 1 > self._fp) + doelements(action, "maneuver", False) assert aphex.isvalid(self._x, self._y, facing=self._facing)