Skip to content

aponscat/checkers

Repository files navigation

checkers

Checkers game

Run with: php play.php

UML Diagram

UML DIAGRAM

´´´ @startuml Player <|-- ComputerPlayer Player <|-- HumanPlayer Checkers -- Board Checkers -- "2" Player Checkers -- Turn Checkers o-- IO Turn *-- "2" Player Board *-- "DIMENSIONxDIMENSION" Tile Tile o-- Token Player *-- Token Trajectory o-- "n" Tile Movement o-- "1 source" Tile Movement o-- "1 destination" Tile Movement -- Board Movements o-- Movement Player -- Movements

class Checkers {

play() initPlayer(string color) }

abstract class Player { string color

{static} createPlayer(string color, string type, IO $io): Player getColor(): string

{abstract} askForValidMovement(Movements $movement): Movement }

class HumanPlayer { askForValidMovement(Movements $movements): Movement }

class ComputerPlayer { askForValidMovement(Movements $movements): Movement }

class Board { init(Player[]) getAllTiles() getAllTilesForPlayer(Player) getTile(x,y) getTileFromInput(string) getWinner(Checkers) tokenReachedGoal(Token) }

class IO { askForTypeOfPlayer(string $color): string getInput (string message): string printBoard(Board board): void clearScreen(): void }

class Tile { int row int column

getBoard(): Board setToken(Token): void getToken(): ?Token getColor(): ?string getSymbol(): ?string getCoordinates(): string removeToken(): void isEmpty(): bool getRow(): int setRow(int): void getColumn(): int setColumn(int): void }

class Token { string symbol int row_direction boolean isQueen

getTile(): Tile getPlayer(): Player getNextRow(int offset): int getRowOffset(int offset): int getColor(): string moveTo(Tile): void getSymbol(): string convertToQueen(): void getAllTrajectories(): Trajectory[] getValidTilesInTrajectory(Trajectory, int offset): Tiles[] possibleDestinationTiles(): Tiles[] }

class Turn { int current_player

getCurrentPlayer(): Player changeToNextPlayer(): void }

class Trajectory { int x_direction int y_direction

getTiles(int offset): Tiles[] exists(): bool }

class Movement { getSource(): Tile getDestination(): Tile getAllTilesInTrajectory(): Tile[] evaluateIfIsKiller(Board $board): bool isKiller(): bool do(Board $board): void }

class Movements { getSources(): array getAIMovement(): ?Movement getDestinationsFromSource(Tile $source): array getRandom(): Movement } @enduml ´´´

About

Checkers game run with php test.php

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages