The casino starter project. It is a scaffold: the dashboard, console and class structure work, and the parts
students implement are stubs that raise NotImplementedError.
cd python
python3 -m venv .venv && source .venv/bin/activate
pip install -e '.[dev]'
montycasino # or: python -m montycasino
pytest --cov=montycasino # fails under 80% coverage, as the assignment requiresRequires Python 3.11+.
python/
├── pyproject.toml
├── src/montycasino/
│ ├── casino.py # Casino: the dashboard loop
│ ├── accounts.py # CasinoAccount, CasinoAccountManager (stubs)
│ ├── game.py # Game: abstract base class for games
│ ├── player.py # Player: abstract base class for players
│ ├── errors.py # AccountNotFoundError, InvalidGameSelectionError
│ ├── utils/ # IOConsole, AnsiColor
│ └── games/
│ ├── __init__.py # GAMES registry: menu name -> (game, player)
│ ├── slots/ # SlotsGame, SlotsPlayer (stubs)
│ └── numberguess/ # NumberGuessGame, NumberGuessPlayer (stubs)
└── tests/
CasinoAccountManager.get_account,create_account,register_account, and giveCasinoAccounta balance.SlotsGame/SlotsPlayerandNumberGuessGame/NumberGuessPlayer.- Four more games (see the root README for the requirements).
To add a game, write a Game and Player subclass and add one line to GAMES; the menu updates itself.
The tests marked xfail describe behaviour you still owe. They are strict: once you implement something, its test reports as failing until you delete the marker.
GameandPlayerare abstract base classes. All players must have a reference to theCasinoAccountused to log in, and are capable ofplaying a game.Gameimplementsadd/removewith a list, so multi-player games work out of the box; each subclass defines how the game willrun.CasinoAccountis registered for each user and is used to log in and select a game. It outlives any single game, so it is the natural owner of the player's balance.CasinoAccountManagerstores, manages and retrieves accounts. It is advised that every operation in it is logged.IOConsoleprompts the user and reads input. Its message templates usestr.formatplaceholders ("{}"), and its streams are injectable so tests need no mocking.AnsiColorsupplies output colours.Casinochooses a game through theGAMESdictionary, so the menu updates itself when one is added.- The
TODOs inCasinomark where better error handling is expected: a failed login raisesAccountNotFoundErrorand a bad selection raisesInvalidGameSelectionError.