This commit is contained in:
52
app/src/main/java/game/Game.java
Normal file
52
app/src/main/java/game/Game.java
Normal file
@@ -0,0 +1,52 @@
|
||||
package game;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import sudoku.structure.MultiDoku;
|
||||
|
||||
public class Game {
|
||||
|
||||
public static enum GameState {
|
||||
GameNotStarted, GameGoing, GameEnd
|
||||
}
|
||||
|
||||
private final Map<Integer, Player> players;
|
||||
private GameState gameState;
|
||||
private MultiDoku doku;
|
||||
|
||||
public Game() {
|
||||
this.players = new HashMap<>();
|
||||
this.gameState = GameState.GameNotStarted;
|
||||
}
|
||||
|
||||
public Player getPlayerById(int id) {
|
||||
return players.get(id);
|
||||
}
|
||||
|
||||
public void addPlayer(Player player) {
|
||||
players.put(player.getId(), player);
|
||||
}
|
||||
|
||||
public void removePlayer(int id) {
|
||||
players.remove(id);
|
||||
}
|
||||
|
||||
public Map<Integer, Player> getPlayers() {
|
||||
return players;
|
||||
}
|
||||
|
||||
public void startGame(MultiDoku doku) {
|
||||
this.doku = doku;
|
||||
this.gameState = GameState.GameGoing;
|
||||
}
|
||||
|
||||
public GameState getGameState() {
|
||||
return gameState;
|
||||
}
|
||||
|
||||
public MultiDoku getDoku() {
|
||||
return doku;
|
||||
}
|
||||
|
||||
}
|
||||
25
app/src/main/java/game/Player.java
Normal file
25
app/src/main/java/game/Player.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package game;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Player implements Serializable {
|
||||
|
||||
static private final long serialVersionUID = 9999;
|
||||
|
||||
private final String pseudo;
|
||||
private final int id;
|
||||
|
||||
public Player(int id, String pseudo) {
|
||||
this.pseudo = pseudo;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPseudo() {
|
||||
return this.pseudo;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user