Skip to main content

Tetris with Apulian elements - a Software Engineering project.

Project description

OrecchietTetris

An exact copy of the Tetris game, with Apulian elements. Built as a Software Engineering university project.

Features

  • Classic Tetris gameplay with all 7 standard tetrominoes (I, O, T, S, Z, J, L)
  • Tetromino rotation, hard drop, and shadow piece (ghost piece preview)
  • Hold slot — store the current piece and swap it back in at any time
  • Observer pattern architecture decoupling game logic from the GUI
  • Formal interfaces (ITetromino, IBoard, ITetris) for clean dependency inversion
  • Automated testing via GitHub Actions (Windows, macOS, Ubuntu)
  • Automatic releases to PyPI via semantic-release on pushes to master
  • Automatic dependency updates via Renovate

Requirements

  • Python >= 3.11
  • Node >= 20 and npm >= 10.8 (for semantic-release)
  • Poetry (dependency manager)

Installation

  1. Clone the repository:

    git clone https://github.com/unibo-dtm-se-2425-OrecchietTetris/OrecchietTetris-artifact
    cd OrecchietTetris-artifact
    
  2. Install Poetry if you don't have it yet:

    pip install -r requirements.txt
    
  3. Install the project's dependencies:

    poetry install
    npm install
    
  4. (Optional) Install pre-commit hooks for commit-message linting:

    poetry run poe hooks
    

Usage

Run the game:

poetry run OrecchietTetris

or alternatively:

python -m OrecchietTetris

Development

Run tests

poetry run poe test

Run a single test file or test case:

poetry run pytest -v tests/model/test_tetromino.py
poetry run pytest -v tests/model/test_tetromino.py::test_rotations

Coverage

poetry run poe coverage

Lint & type check

poetry run poe flake8
poetry run poe mypy

Project structure

OrecchietTetris-artifact/
├── OrecchietTetris/
│   ├── model/
│   │   ├── interfaces.py       # ITetromino, IBoard, ITetris abstract interfaces
│   │   ├── tetromino.py        # ShapeType enum and Tetromino(ITetromino)
│   │   ├── board.py            # Board(IBoard) — fixed grid engine
│   │   └── tetris.py           # Tetris(Subject, ITetris) — game orchestrator
│   ├── gui/
│   │   └── TetrisGui.py        # GUI layer (Observer)
│   ├── utils/
│   │   └── observer_subject.py # Observer pattern base classes
│   ├── __init__.py
│   └── __main__.py
├── tests/
│   └── model/
│       └── test_tetromino.py
├── pyproject.toml
└── README.md

Architecture

The project uses the Observer pattern to decouple game logic from the view, with abstract interfaces for dependency inversion:

  • ITetromino, IBoard, ITetris — abstract interfaces defined in model/interfaces.py; ITetris inherits from Subject so the observer contract is part of the interface itself
  • Tetris(ITetris) — game orchestrator; fires observer events on every state change
  • TetrisGui(Observer) — reacts to game events via update(event_type, data)
  • Board(IBoard) — pure grid engine (collision detection, line clearing)
  • Tetromino(ITetromino) — falling piece with clockwise rotation

Observer events fired by Tetris

Event When Data
board_updated piece moved, rotated, or locked None
new_piece new piece spawned ITetromino
hold_updated hold slot changed ITetromino | None
lines_cleared lines removed int
score_updated score changed int
game_over spawn blocked None
paused / resumed pause toggled None

Releases

Releases are automated via GitHub Actions when pushing to master. Commit messages must follow the Conventional Commits specification for semantic-release to compute version numbers correctly (e.g. feat:, fix:, chore:).

License

Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

orecchiettetris-0.3.2.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

orecchiettetris-0.3.2-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file orecchiettetris-0.3.2.tar.gz.

File metadata

  • Download URL: orecchiettetris-0.3.2.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for orecchiettetris-0.3.2.tar.gz
Algorithm Hash digest
SHA256 27d6ee28e58ce206aa55277d8256e1ce33b0f601f14fb58488b7c3737c87dbd8
MD5 153ff1790fce9939f44e8303ccaf899f
BLAKE2b-256 abcd839fdd0e487b4d670a86f94960fe3903df2d99f63de865741ca5cebd801c

See more details on using hashes here.

Provenance

The following attestation bundles were made for orecchiettetris-0.3.2.tar.gz:

Publisher: deploy.yml on unibo-dtm-se-2425-OrecchietTetris/OrecchietTetris-artifact

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file orecchiettetris-0.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for orecchiettetris-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 81f4f3efeca22f298c2c5f669185bb3eef82801008b4f0396095014457341023
MD5 912c760e2665eb11e3ae17f72fb36d4c
BLAKE2b-256 fbd3e6915e046f151b2943887c6fe0c65d1bfeafc2393ad45cf8429ddf8c90b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for orecchiettetris-0.3.2-py3-none-any.whl:

Publisher: deploy.yml on unibo-dtm-se-2425-OrecchietTetris/OrecchietTetris-artifact

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page