mirror of
https://github.com/Vale54321/schafkopf-bot.git
synced 2025-12-16 11:49:33 +01:00
refactored a lot and added possibility to play games on DedicatedServer (#43)
This commit is contained in:
committed by
GitHub
parent
6259d0bef3
commit
cab2d36f48
@@ -0,0 +1,80 @@
|
||||
package org.schafkopf;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.schafkopf.karte.Karte;
|
||||
import org.schafkopf.karte.KartenFarbe;
|
||||
|
||||
/** GameState. */
|
||||
public class GameState {
|
||||
|
||||
public GamePhase getGamePhase() {
|
||||
return this.gamePhase;
|
||||
}
|
||||
|
||||
/** GamePhase. */
|
||||
public enum GamePhase {
|
||||
CHOOSE_GAME("Spiel muss gewählt werden"),
|
||||
|
||||
GAME_START("Warten auf das Legen einer Karte"),
|
||||
|
||||
TRICK_START("Warten auf das Legen einer Karte"),
|
||||
WAIT_FOR_CARD("Warten auf das Legen einer Karte"),
|
||||
PLAYER_CARD("Warten auf das Legen einer Karte"),
|
||||
PLAYER_TRICK("Spieler sticht"),
|
||||
GAME_STOP("Spieler sticht");
|
||||
// Add more phases as needed
|
||||
|
||||
private final String description;
|
||||
|
||||
GamePhase(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
}
|
||||
|
||||
private GamePhase gamePhase;
|
||||
private Integer currentPlayer; // Using Integer to allow for null
|
||||
private Karte card;
|
||||
private KartenFarbe color;
|
||||
private boolean trumpf;
|
||||
|
||||
// Constructors, getters, and setters
|
||||
|
||||
public GameState(GamePhase phase) {
|
||||
this.gamePhase = phase;
|
||||
}
|
||||
|
||||
public GameState(GamePhase phase, Integer player) {
|
||||
this.gamePhase = phase;
|
||||
this.currentPlayer = player;
|
||||
}
|
||||
|
||||
/** GameState. */
|
||||
public GameState(GamePhase phase, Integer player, Karte card, KartenFarbe color, boolean trumpf) {
|
||||
this.gamePhase = phase;
|
||||
this.currentPlayer = player;
|
||||
this.card = card;
|
||||
this.color = color;
|
||||
this.trumpf = trumpf;
|
||||
}
|
||||
|
||||
/** GameState. */
|
||||
public GameState(GamePhase phase, Integer player, Karte card) {
|
||||
this.gamePhase = phase;
|
||||
this.currentPlayer = player;
|
||||
this.card = card;
|
||||
}
|
||||
|
||||
/** GameState. */
|
||||
public JsonObject getJson() {
|
||||
Gson gson = new Gson();
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.add("gamestate", gson.toJsonTree(this));
|
||||
|
||||
return jsonObject;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user