Verified Commit 048d4e66 authored by Jakob Moser's avatar Jakob Moser
Browse files

Improve fields and docs of scenes

parent 0da5df82
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ class Director:

    def nothing_requested(self) -> None:
        self._next_scene_on_card_presented = self.play.PaymentSuccess
        self.play.Idle(self, price=DRINK).present()
        self.play.Idle(self, price_cents=DRINK).present()

    def reversal_requested(self) -> None:
        self._next_scene_on_card_presented = self.play.Reversal
@@ -56,37 +56,37 @@ class Director:

    def _do_payment(self, card: Card) -> None:
        # We just pretend that this is certainly atomic and there is no way that we will ever have a race condition here
        old_balance = card.owner.balance_str
        old_balance_cents = card.owner.balance_cents
        card.owner.pay(DRINK)
        new_balance = card.owner.balance_str
        new_balance_cents = card.owner.balance_cents

        # TODO Commit to the database

        self.play.PaymentSuccess(
            self,
            old_balance=old_balance,
            new_balance=new_balance,
            old_balance_cents=old_balance_cents,
            new_balance_cents=new_balance_cents,
            person_name=card.owner.name,
        ).present()

    def _do_reversal(self, card: Card) -> None:
        # We just pretend that this is certainly atomic and there is no way that we will ever have a race condition here
        old_balance = card.owner.balance_str
        old_balance_cents = card.owner.balance_cents
        card.owner.pay(-DRINK)
        new_balance = card.owner.balance_str
        new_balance_cents = card.owner.balance_cents

        # TODO Commit to the database

        self.play.Reversal(
            self,
            old_balance=old_balance,
            new_balance=new_balance,
            old_balance_cents=old_balance_cents,
            new_balance_cents=new_balance_cents,
            person_name=card.owner.name,
        ).present()

    def _do_balance(self, card: Card) -> None:
        self.play.Balance(
            self,
            balance=card.owner.balance_str,
            balance_cents=card.owner.balance_cents,
            person_name=card.owner.name,
        ).present()
+10 −4
Original line number Diff line number Diff line
from abc import ABC
from dataclasses import dataclass

from poolpay.ui.scenes.Scene import Scene


@dataclass(frozen=True)
class Balance(Scene):
    balance: str
    person_name: str
class Balance(Scene, ABC):
    """
    This scene displays the name of the person and their current balance, for informational purposes.

    Currently, this scene does not allow any actions.
    TODO: In the future, this will have a button to allow a person to settle their debts.
    """

    # TODO Implement methods
    balance_cents: int
    person_name: str
+7 −3
Original line number Diff line number Diff line
from abc import ABC
from dataclasses import dataclass

from poolpay.ui.scenes.Scene import Scene


@dataclass(frozen=True)
class Idle(Scene):
    price: int
class Idle(Scene, ABC):
    """
    This scene displays the price of a drink, asks the person to present their card to pay and shows buttons
    to trigger different actions.
    """

    pass  # TODO Implement methods
    price_cents: int
+8 −5
Original line number Diff line number Diff line
from abc import ABC
from dataclasses import dataclass

from poolpay.ui.scenes.Scene import Scene


@dataclass(frozen=True)
class PaymentSuccess(Scene):
    old_balance: str
    new_balance: str
    person_name: str
class PaymentSuccess(Scene, ABC):
    """
    This shows a message that payment was successful and displays the old and new balance of the person.
    """

    # TODO Implement methods
    old_balance_cents: int
    new_balance_cents: int
    person_name: str
+8 −5
Original line number Diff line number Diff line
from abc import ABC
from dataclasses import dataclass

from poolpay.ui.scenes.Scene import Scene


@dataclass(frozen=True)
class Reversal(Scene):
    old_balance: str
    new_balance: str
    person_name: str
class Reversal(Scene, ABC):
    """
    This shows a message that a payment reversal (“Storno”) was successful and displays the old and new balance.
    """

    # TODO Implement methods
    old_balance_cents: int
    new_balance_cents: int
    person_name: str
Loading