Verified Commit 8a5f2a96 authored by Jakob Moser's avatar Jakob Moser
Browse files

Fix accidental charging bug

parent 78bc9ca3
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ class Director:
    _last_placed_card: Card | None = field(init=False)
    _last_card_removed_at: float | None = field(init=False)
    _last_card_placed_at: float | None = field(init=False)
    _last_card_presentation_failed: bool = field(init=False, default=False)

    _next_scene_on_card_placed: type[Scene] = field(init=False)

@@ -42,10 +43,12 @@ class Director:
        card = Card.get_only(card_id)

        if not card:
            self._last_card_presentation_failed = True
            self.play.PaymentFailure(self).present()
            return

        self._last_placed_card = card
        self._last_card_presentation_failed = False
        self._last_card_placed_at = monotonic()

        match self._next_scene_on_card_placed:
@@ -59,6 +62,12 @@ class Director:
    def card_removed(self) -> None:
        self._last_card_removed_at = monotonic()
        self._ensure_minimum_presentation_time()
        if self._next_scene_on_card_placed is self.play.Balance and self._last_card_presentation_failed:
            # If the user wanted to see their balance, but the card detection failed, show the balance
            # next time a card is presented
            # TODO Move this hotfix in a better place
            self.play.WaitForCard(self).present()
        else:
            self.nothing_requested()

    def screen_touched(self) -> None: