{"id":24839871,"url":"https://github.com/danidrd/matching-pairs-game","last_synced_at":"2026-07-10T11:31:59.465Z","repository":{"id":266865323,"uuid":"899575100","full_name":"danidrd/Matching-Pairs-Game","owner":"danidrd","description":"First Programming assignment on Java Beans for the subject Advanced Programming","archived":false,"fork":false,"pushed_at":"2024-12-09T15:38:05.000Z","size":129,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-29T00:35:00.156Z","etag":null,"topics":["beans","jakarta-ee","java","mvc-pattern"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danidrd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-12-06T14:51:39.000Z","updated_at":"2024-12-27T12:28:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"b68fe3cd-2874-49ed-a3d7-dd38955afcff","html_url":"https://github.com/danidrd/Matching-Pairs-Game","commit_stats":null,"previous_names":["danidrd/matching-pairs-game"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/danidrd/Matching-Pairs-Game","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danidrd%2FMatching-Pairs-Game","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danidrd%2FMatching-Pairs-Game/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danidrd%2FMatching-Pairs-Game/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danidrd%2FMatching-Pairs-Game/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danidrd","download_url":"https://codeload.github.com/danidrd/Matching-Pairs-Game/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danidrd%2FMatching-Pairs-Game/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35330738,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-10T02:00:06.465Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["beans","jakarta-ee","java","mvc-pattern"],"created_at":"2025-01-31T06:49:46.632Z","updated_at":"2026-07-10T11:31:59.459Z","avatar_url":"https://github.com/danidrd.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Matching Pairs Game\nFirst exercise of the assignment of Advanced Programming (MSc in Computer Science and Networking at UniPisa)\n    \n    https://pages.di.unipi.it/corradini/Didattica/AP-24/PROG-ASS/01/2024-Assignment-1-v1.pdf\n## Overview\nThe Matching Pairs game is a turn-based card-matching game implemented in Java. This implementation focuses on modularity, scalability, and maintainability by following the **Model-View-Controller (MVC)** architecture, ensuring a clean separation of responsibilities. The project also adheres to **high decoupling** and the **Observer pattern**, enabling robust communication between components.\n\n---\n\n## Features\n\n### Single-Player Mode\n- Play a classic matching pairs game with a dynamic board size.\n- Track your total flips and matched pairs during gameplay.\n\n### Multiplayer Mode\n- Supports up to 4 players with a turn-based system.\n- Each player has individual scores (`matchedPairs` and `totalFlips`).\n- The current player’s progress is dynamically displayed in the UI.\n- The global game state ensures consistency among all players.\n\n### Leaderboard\n- Tracks the best scores across different board sizes.\n- Players can view rankings for specific configurations and compete for the top spot.\n\n### Dynamic Board Resizing\n- Change the number of pairs dynamically during the game.\n- A button allows manual input of the new board size, which adjusts the layout and updates the game state seamlessly.\n\n---\n\n## Design Principles\n\n### Model-View-Controller (MVC) Architecture\n- **Model**: `GameController` manages game logic, such as player turns, scoring, and the overall game state.\n- **View**: `BoardView` and `CardView` handle user interface elements, displaying the game board and cards.\n- **Controller**: Bridges the user input, game logic, and view, ensuring synchronization.\n\nThis architecture ensures modularity, making it easy to adapt or extend the game logic or UI independently.\n\n### High Decoupling\n- Instead of having each `CardView` directly respond to the `shuffle` event, the `GameController` centrally manages this logic.\n- The `GameController` listens to the `BoardView`'s `shuffle` event and updates the `CardView` instances.\n- This design reduces direct dependencies between components, enhancing maintainability and scalability.\n\n### Observer Pattern\nThe implementation makes extensive use of the Observer pattern:\n- The `BoardView` emits a `shuffle` event, which is handled by the `GameController` to update all `CardView` instances.\n- Each `CardView` observes changes to its `state` property:\n    - The `state` is **vetoable**, ensuring valid state transitions, and **bound**, notifying the `GameController` when flips occur.\n    - The `GameController` processes the `state` event and invokes the `handleCardFlip` method to manage the game logic.\n- Button actions are also handled centrally by the `GameController`, maintaining consistency and proper sequencing of events.\n\n---\n\n## How It Works\n\n1. **Game Initialization**:\n    - Players are prompted to choose single-player or multiplayer mode and specify the number of players.\n    - Players then enter their usernames.\n\n2. **Gameplay**:\n    - Players take turns flipping cards to find matching pairs.\n    - If a match is found, the player continues; otherwise, the next player takes their turn.\n\n3. **Game End**:\n    - The game ends when all pairs are matched.\n    - The player with the most matches (and fewest flips in case of a tie) is declared the winner.\n    - A detailed ranking of all players is displayed.\n\n4. **Leaderboard**:\n    - At the end of a game, scores are stored in a leaderboard that can be viewed based on the board size.\n\n---\n\n## How to Run\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/danidrd/matching-pairs-game.git\n\n2. Use Maven from an IDE(e.g. IntelliJ, Apache NetBeans) for install and packaging the project.\n\n---\n## Run with .jar file\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/danidrd/matching-pairs-game.git\n\n2. Run the .jar file inside the out/ folder;\n   ```bash\n   java -jar matching-pairs-game.jar\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanidrd%2Fmatching-pairs-game","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanidrd%2Fmatching-pairs-game","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanidrd%2Fmatching-pairs-game/lists"}