hanze/game-client

src/main/java/nl/isygameclient/models/Game.java in main
Repositories | Summary | Log | Files

Game.java (1352B) download


 1package nl.isygameclient.models;
 2
 3
 4import nl.isygameclient.models.board.Board;
 5import nl.isygameclient.models.board.HistoryBoard;
 6import nl.isygameclient.util.Vector2D;
 7
 8import java.util.List;
 9
10public abstract class Game {
11
12    protected PlayerManager playerManager;
13    protected HistoryBoard<Player> board;
14
15    public Game(PlayerManager playerManager, HistoryBoard<Player> board) {
16        this.playerManager = playerManager;
17        this.board = board;
18
19        for (Player player : playerManager.getPlayers()) {
20            player.setGame(this);
21        }
22    }
23
24    public abstract void restart();
25
26    public abstract boolean move(Player player, Vector2D<Integer, Integer> pos);
27
28    public abstract boolean isMoveValid(Player player, Vector2D<Integer, Integer> pos);
29
30    public abstract boolean isDraw();
31
32    public abstract boolean isGameOver();
33
34    public abstract boolean isWinner(Player player);
35
36    public void undo() {
37        board.undo();
38        playerManager.previousPlayer();
39    }
40
41    public abstract List<Vector2D<Integer, Integer>> getValidMoves(Player player);
42
43    public abstract List<Player> getWinners();
44
45    public abstract int getPlayerScore(Player player);
46
47    public PlayerManager getPlayerManager() {
48        return playerManager;
49    }
50
51    public HistoryBoard<Player> getBoard() {
52        return board;
53    }
54}