-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGame.java
46 lines (40 loc) · 903 Bytes
/
Game.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import java.util.ArrayList;
public class Game {
private State currentState;
private Player human;
private Player bot;
private Player currentPlayer;
/**
* Constructor
*/
public Game(Player human, Player bot) {
currentState = new State();
this.human = human;
this.bot = bot;
currentPlayer = this.human;
}
public void updateGame() {
if(currentPlayer.getId() == 1) {
currentPlayer = bot;
} else {
currentPlayer = human;
}
}
/**
* Checks if the game is finished
* @return true if the game is finished, otherwise false
*/
public boolean isFinished() {
if(currentPlayer.possibleActions(currentState).size() == 0 || currentState.isFull()) {
return true;
} else {
return false;
}
}
public Player getCurrentPlayer(){
return currentPlayer;
}
public State getGameState(){
return currentState;
}
}