Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marydn/shogi
Japanese variation of chess game written in PHP
https://github.com/marydn/shogi
chess docker game japanese-chess php php74 shogi
Last synced: 2 months ago
JSON representation
Japanese variation of chess game written in PHP
- Host: GitHub
- URL: https://github.com/marydn/shogi
- Owner: marydn
- Created: 2020-02-11T14:57:40.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-23T11:08:45.000Z (over 4 years ago)
- Last Synced: 2024-09-29T20:01:29.495Z (3 months ago)
- Topics: chess, docker, game, japanese-chess, php, php74, shogi
- Language: PHP
- Size: 246 KB
- Stars: 7
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
## Table of Contents
* [Environment setup](#environment-setup)
* [Needed tools](#needed-tools)
* [Application execution](#application-execution)
* [Tests execution](#tests-execution)
* [Project explanation](#project-explanation)
* [Developed features](#developed-features)
* [Diving project structure](#diving-project-structure)
* [UI Preview](#ui-preview)## Environment setup
### Needed tools
1. [Install Docker](https://www.docker.com/get-started)
2. Clone this project: `git clone https://github.com/marydn/shogi`
3. Move to the project folder: `cd shogi`
4. Install PHP dependencies and bring up the project Docker containers with Docker Compose: `make build`
5. Check everything's up using: `$ docker-compose ps`. It should show `php` service up.Note: If you want to bring down Docker service use: `make destroy`
### Application execution
Start game using: `make play`
End the game at any time by writing `quit` instead of entering a new move.
### Tests execution
Execute PHP Unit tests: `make test`
## Project explanation
OOP Design example for a variation of a Japanese chess version called [Shogi](https://en.wikipedia.org/wiki/Shogi).
### Developed features:
* Console interactive interface
* Pieces placement
* Pieces movements
* Capture opponent's pieces
* Drop captured pieces (only Pawns)
* Pieces are automatically promoted when they reach promotion zone (last 3 rows)### Diving project structure:
```bash
$ tree -L 4 src
src
├── Board.php
├── CliPrintableSpot.php # Decorator for console output
├── Command
│ └── GameCommand.php # Console output application
├── CoordinateTranslator.php # Translate user's input to a valid coordinate to handle internally
├── Exception
│ ├── CoordinateNotFound.php
│ ├── CoordinateNotWellFormedNotation.php
│ ├── IllegalMove.php
│ └── PieceNotFoundInInventory.php
├── Game.php
├── Move.php
├── MovesList.php # Collection of Moves
├── Notation.php # Every move is saved as a Notation object
├── Pieces # Every piece in the Board
│ ├── BasePiece.php
│ ├── Bishop.php
│ ├── GoldGeneral.php
│ ├── King.php
│ ├── Knight.php
│ ├── Lance.php
│ ├── Pawn.php
│ ├── PieceDroppableInterface.php # This Interface is for pieces that can be droppable
│ ├── PieceInterface.php
│ ├── PiecePromotableInterface.php # This Interface is for pieces that can be promoted
│ ├── Rook.php
│ └── SilverGeneral.php
├── PlayerInventory.php # Player's inventory
├── Player.php # Every player of the game
├── Shared
│ ├── Collection.php # Abstract class for Objects that holds collections
│ └── Enum.php # Abstract class for Objects used as an Enum value object
├── Spot.php # Every spot in the Board
└── ValueObject
├── Coordinate.php # User's input
└── NotationType.php # ValueObject to identify the type of move
```### UI Preview:
![image info](./doc/images/demo.png)