- Install Docker
- Clone this project:
git clone https://github.com/marydn/shogi
- Move to the project folder:
cd shogi
- Install PHP dependencies and bring up the project Docker containers with Docker Compose:
make build
- Check everything's up using:
$ docker-compose ps
. It should showphp
service up.
Note: If you want to bring down Docker service use: make destroy
Start game using: make play
End the game at any time by writing quit
instead of entering a new move.
Execute PHP Unit tests: make test
OOP Design example for a variation of a Japanese chess version called Shogi.
- 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)
$ 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