implemented all methods required for the state pattern in the client and adjusted the messages to work with player ids instead of names
This commit is contained in:
@@ -19,9 +19,15 @@ public class ClientGameLogic implements ServerInterpreter {
|
||||
private Map<UUID, Piece> pieces;
|
||||
private Map<UUID, BonusCard> cards;
|
||||
|
||||
private Dialogs dialogs = new Dialogs(null, this);
|
||||
private GameState gameState = new GameState(null, this);
|
||||
private Ceremony ceremony = new Ceremony(null, this);
|
||||
private Interrupt interrupt = new Interrupt(null, this);
|
||||
|
||||
public ClientGameLogic(Game game, ClientSender clientSender) {
|
||||
this.game = game;
|
||||
this.clientSender = clientSender;
|
||||
state = dialogs;
|
||||
}
|
||||
|
||||
public void send(ClientMessage msg){
|
||||
@@ -43,178 +49,197 @@ public ClientState getState(){
|
||||
|
||||
@Override
|
||||
public void received(ActivePlayer msg) {
|
||||
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(AnyPiece msg) {
|
||||
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(Briefing msg) {
|
||||
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(CeremonyMessage msg) {
|
||||
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(Dice msg) {
|
||||
|
||||
public void received(Die msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DiceAgain msg) {
|
||||
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DiceNow msg) {
|
||||
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(EndOfTurn msg) {
|
||||
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(LobbyAccept msg) {
|
||||
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(LobbyDeny msg) {
|
||||
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(LobbyPlayerJoin msg) {
|
||||
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(LobbyPlayerLeave msg) {
|
||||
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(MoveMessage msg) {
|
||||
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(NoTurn msg) {
|
||||
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(PauseGame msg) {
|
||||
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(PlayCard msg) {
|
||||
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(PossibleCard msg) {
|
||||
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(PossiblePiece msg) {
|
||||
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(RankingResponse msg) {
|
||||
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(RankingRollAgain msg) {
|
||||
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(ReconnectBriefing msg) {
|
||||
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(ResumeGame msg) {
|
||||
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(ServerStartGame msg) {
|
||||
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(StartPiece msg) {
|
||||
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(UpdateReady msg) {
|
||||
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(UpdateTSK msg) {
|
||||
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(WaitPiece msg) {
|
||||
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
public void selectPiece(UUID pieceId){
|
||||
//TODO
|
||||
state.selectPiece(pieceId);
|
||||
}
|
||||
|
||||
public void selectCard(UUID cardId){
|
||||
//TODO
|
||||
state.selectCard(cardId);
|
||||
}
|
||||
|
||||
public void selectTsk(Color color){
|
||||
//TODO
|
||||
state.selectTSK(color);
|
||||
}
|
||||
|
||||
public void selectDice(){
|
||||
//TODO
|
||||
state.selectDice();
|
||||
}
|
||||
|
||||
public void selectName(String name){
|
||||
//TODO
|
||||
state.setName(name);
|
||||
}
|
||||
|
||||
public void selectReady(boolean ready){
|
||||
//TODO
|
||||
state.selectReady();
|
||||
}
|
||||
|
||||
public void selectHost(){
|
||||
//TODO
|
||||
state.selectHost();
|
||||
}
|
||||
|
||||
public void selectLeave(){
|
||||
//TODO
|
||||
state.selectLeave();
|
||||
}
|
||||
|
||||
public void selectJoin(){
|
||||
//TODO
|
||||
state.selectJoin();
|
||||
}
|
||||
|
||||
public void selectStart(){
|
||||
//TODO
|
||||
state.selectStart();
|
||||
}
|
||||
|
||||
public void setState(ClientState state){
|
||||
this.state.exit();
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public GameState getGameState(){
|
||||
return gameState;
|
||||
}
|
||||
|
||||
public Ceremony getCeremony(){
|
||||
return ceremony;
|
||||
}
|
||||
|
||||
public Interrupt getInterrupt(){
|
||||
return interrupt;
|
||||
}
|
||||
|
||||
public Dialogs getDialogs(){
|
||||
return dialogs;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package pp.mdga.client;
|
||||
|
||||
import pp.mdga.game.Color;
|
||||
import pp.mdga.message.server.*;
|
||||
|
||||
import java.lang.System.Logger.Level;
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class ClientState implements Observer, ServerInterpreter {
|
||||
protected static final System.Logger LOGGER = System.getLogger(ClientState.class.getName());
|
||||
@@ -52,7 +54,7 @@ public void received(CeremonyMessage msg) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(Dice msg) {
|
||||
public void received(Die msg) {
|
||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||
}
|
||||
|
||||
@@ -165,4 +167,52 @@ public void received(UpdateTSK msg) {
|
||||
public void received(WaitPiece msg) {
|
||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||
}
|
||||
|
||||
public void selectPiece(UUID id) {
|
||||
LOGGER.log(Level.DEBUG, "Selecting piece not allowed.");
|
||||
}
|
||||
|
||||
public void selectCard(UUID id) {
|
||||
LOGGER.log(Level.DEBUG, "Selecting card not allowed.");
|
||||
}
|
||||
|
||||
public void selectTSK(Color color) {
|
||||
LOGGER.log(Level.DEBUG, "Selecting TSK not allowed.");
|
||||
}
|
||||
|
||||
public void selectDice() {
|
||||
LOGGER.log(Level.DEBUG, "Selecting dice not allowed.");
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
LOGGER.log(Level.DEBUG, "Setting name not allowed.");
|
||||
}
|
||||
|
||||
public void selectReady() {
|
||||
LOGGER.log(Level.DEBUG, "Selecting ready not allowed.");
|
||||
}
|
||||
|
||||
public void selectHost() {
|
||||
LOGGER.log(Level.DEBUG, "Selecting host not allowed.");
|
||||
}
|
||||
|
||||
public void selectJoin() {
|
||||
LOGGER.log(Level.DEBUG, "Selecting join not allowed.");
|
||||
}
|
||||
|
||||
public void selectLeave() {
|
||||
LOGGER.log(Level.DEBUG, "Selecting leave not allowed.");
|
||||
}
|
||||
|
||||
public void deselectTSK(Color color) {
|
||||
LOGGER.log(Level.DEBUG, "Deselecting TSK not allowed.");
|
||||
}
|
||||
|
||||
public void selectUnready(){
|
||||
LOGGER.log(Level.DEBUG, "Selecting unready not allowed.");
|
||||
}
|
||||
|
||||
public void selectStart(){
|
||||
LOGGER.log(Level.DEBUG, "Starting not allowed");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,4 +45,9 @@ public NetworkDialog getNetworkDialog() {
|
||||
public StartDialog getStartDialog() {
|
||||
return startDialog;
|
||||
}
|
||||
|
||||
public void startGame(){
|
||||
exit();
|
||||
logic.setState(logic.getGameState());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package pp.mdga.client;
|
||||
|
||||
public class Game extends ClientState {
|
||||
|
||||
public Game(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package pp.mdga.client;
|
||||
|
||||
import pp.mdga.client.gameState.*;
|
||||
|
||||
public class GameState extends ClientState {
|
||||
|
||||
private GameStates state;
|
||||
|
||||
private Animation animation = new Animation(this, logic);
|
||||
private DetermineStartPlayer determineStartPlayer = new DetermineStartPlayer(this, logic);
|
||||
private Spectator spectator = new Spectator(this, logic);
|
||||
private Turn turn = new Turn(this, logic);
|
||||
private Waiting waiting = new Waiting(this, logic);
|
||||
|
||||
public GameState(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
state = determineStartPlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,17 @@
|
||||
|
||||
public class Interrupt extends ClientState {
|
||||
|
||||
private final Game lastState;
|
||||
|
||||
public Interrupt(ClientState parent, ClientGameLogic logic, Game lastState) {
|
||||
public Interrupt(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
this.lastState = lastState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package pp.mdga.client.ceremonyState;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
|
||||
public abstract class CeremonyStates extends ClientState {
|
||||
protected CeremonyStates(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,18 @@
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
|
||||
public class Podium extends ClientState {
|
||||
public class Podium extends CeremonyStates {
|
||||
public Podium(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,18 @@
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
|
||||
public class Statistics extends ClientState {
|
||||
public class Statistics extends CeremonyStates {
|
||||
public Statistics(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,62 @@
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.Dialogs;
|
||||
import pp.mdga.game.Color;
|
||||
import pp.mdga.message.client.*;
|
||||
import pp.mdga.message.server.ServerStartGame;
|
||||
|
||||
public class Lobby extends DialogStates {
|
||||
|
||||
private final Dialogs parent;
|
||||
|
||||
public Lobby(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
this.parent = (Dialogs) parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectLeave() {
|
||||
parent.setState(parent.getStartDialog());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectTSK(Color color) {
|
||||
logic.send(new SelectTSK(color));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deselectTSK(Color color) {
|
||||
logic.send(new DeselectTSK(color));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectReady() {
|
||||
logic.send(new LobbyReady());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectUnready(){
|
||||
logic.send(new LobbyNotReady());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectStart(){
|
||||
logic.send(new StartGame());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(ServerStartGame msg){
|
||||
parent.startGame();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,14 @@ public class Animation extends GameStates {
|
||||
public Animation(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,4 +8,14 @@ public class DetermineStartPlayer extends GameStates {
|
||||
public DetermineStartPlayer(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,14 @@ public class Spectator extends GameStates {
|
||||
public Spectator(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,4 +8,14 @@ public class Turn extends GameStates {
|
||||
public Turn(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,14 @@ public class Waiting extends GameStates {
|
||||
public Waiting(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gameState.GameStates;
|
||||
|
||||
public class DetermineStartPlayerStates extends GameStates {
|
||||
public abstract class DetermineStartPlayerStates extends GameStates {
|
||||
public DetermineStartPlayerStates(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,4 +7,14 @@ public class RollRankingDice extends DetermineStartPlayerStates {
|
||||
public RollRankingDice(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,4 +8,14 @@ public class WaitRanking extends GameStates {
|
||||
public WaitRanking(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,4 +8,14 @@ public class ChoosePiece extends TurnStates {
|
||||
public ChoosePiece(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,14 @@ public class MovePiece extends TurnStates {
|
||||
public MovePiece(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,14 @@ public class PlayPowerCard extends TurnStates {
|
||||
public PlayPowerCard(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,4 +8,14 @@ public class PowerCard extends TurnStates {
|
||||
public PowerCard(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,14 @@ public class RollDice extends TurnStates {
|
||||
public RollDice(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,14 @@ public class NoPiece extends ChoosePieceStates {
|
||||
public NoPiece(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,14 @@ public class SelectPiece extends ChoosePieceStates {
|
||||
public SelectPiece(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,14 @@ public class StartPiece extends ChoosePieceStates {
|
||||
public StartPiece(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,14 @@ public class WaitingPiece extends ChoosePieceStates {
|
||||
public WaitingPiece(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,14 @@ public class ChoosePowerCard extends PowerCardStates {
|
||||
public ChoosePowerCard(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,14 @@ public class Shield extends PowerCardStates {
|
||||
public Shield(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,14 @@ public class Swap extends PowerCardStates {
|
||||
public Swap(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,14 @@ public class AudioSettings extends SettingStates {
|
||||
public AudioSettings(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,14 @@ public class MainSettings extends ClientState {
|
||||
public MainSettings(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,14 @@ public class VideoSettings extends SettingStates {
|
||||
public VideoSettings(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public interface ClientInterpreter {
|
||||
* @param msg the ForceStartGame message to be processed
|
||||
* @param from the connection ID from which the message was received
|
||||
*/
|
||||
void received(ForceStartGame msg, int from);
|
||||
void received(StartGame msg, int from);
|
||||
|
||||
/**
|
||||
* Processes a received JoinServer message.
|
||||
@@ -140,4 +140,12 @@ public interface ClientInterpreter {
|
||||
* @param from the connection ID from which the message was received
|
||||
*/
|
||||
void received(SelectedPieces msg, int from);
|
||||
|
||||
/**
|
||||
* Processes a received disconnect message.
|
||||
*
|
||||
* @param msg the disconnect message to be processed
|
||||
* @param from the connection ID from which the message was received
|
||||
*/
|
||||
void received(Disconnected msg, int from);
|
||||
}
|
||||
|
||||
@@ -7,11 +7,23 @@
|
||||
*/
|
||||
@Serializable
|
||||
public class JoinServer extends ClientMessage {
|
||||
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Constructs a new JoinServer instance.
|
||||
*/
|
||||
public JoinServer(String name) {
|
||||
super();
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new JoinServer instance.
|
||||
*/
|
||||
public JoinServer() {
|
||||
super();
|
||||
name = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,12 +6,21 @@
|
||||
* A message sent by the host to force start the game when not everyone is ready or not everyone has selected a TSK.
|
||||
*/
|
||||
@Serializable
|
||||
public class ForceStartGame extends ClientMessage {
|
||||
public class StartGame extends ClientMessage {
|
||||
|
||||
private final boolean forceStartGame;
|
||||
|
||||
public StartGame(boolean forceStartGame){
|
||||
super();
|
||||
this.forceStartGame = forceStartGame;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new ForceStartGame message.
|
||||
*/
|
||||
public ForceStartGame() {
|
||||
public StartGame() {
|
||||
super();
|
||||
forceStartGame = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -13,14 +13,20 @@ public class LobbyPlayerJoin extends ServerMessage {
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* The ID of the new Player
|
||||
*/
|
||||
private final int id;
|
||||
|
||||
/**
|
||||
* Constructs a new LobbyPlayerJoin instance with the specified player name.
|
||||
*
|
||||
* @param name the name of the player joining the lobby
|
||||
*/
|
||||
public LobbyPlayerJoin(String name) {
|
||||
public LobbyPlayerJoin(int id, String name) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -28,6 +34,7 @@ public LobbyPlayerJoin(String name) {
|
||||
*/
|
||||
private LobbyPlayerJoin() {
|
||||
name = null;
|
||||
id = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,6 +46,15 @@ public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the id of the new Player
|
||||
*
|
||||
* @return the id of the player
|
||||
*/
|
||||
public int getId(){
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts a visitor to process this message.
|
||||
*
|
||||
|
||||
@@ -11,7 +11,7 @@ public class LobbyPlayerLeave extends ServerMessage {
|
||||
/**
|
||||
* The name of the player leaving the lobby.
|
||||
*/
|
||||
private final String name;
|
||||
private final int id;
|
||||
|
||||
/**
|
||||
* The color associated with the player leaving the lobby.
|
||||
@@ -21,12 +21,12 @@ public class LobbyPlayerLeave extends ServerMessage {
|
||||
/**
|
||||
* Constructs a new LobbyPlayerLeave instance with the specified player name and color.
|
||||
*
|
||||
* @param name the name of the player leaving the lobby
|
||||
* @param id the id of the player leaving the lobby
|
||||
* @param color the color associated with the player leaving the lobby
|
||||
*/
|
||||
public LobbyPlayerLeave(String name, Color color) {
|
||||
public LobbyPlayerLeave(int id, Color color) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.id = id;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public LobbyPlayerLeave(String name, Color color) {
|
||||
* Default constructor for serialization purposes.
|
||||
*/
|
||||
private LobbyPlayerLeave() {
|
||||
name = null;
|
||||
id = 0;
|
||||
color = null;
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ private LobbyPlayerLeave() {
|
||||
*
|
||||
* @return the name of the player leaving the lobby
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,11 +34,11 @@ public interface ServerInterpreter {
|
||||
void received(CeremonyMessage msg);
|
||||
|
||||
/**
|
||||
* Handles a Dice message received from the server.
|
||||
* Handles a Die message received from the server.
|
||||
*
|
||||
* @param msg the Dice message received
|
||||
*/
|
||||
void received(Dice msg);
|
||||
void received(Die msg);
|
||||
|
||||
/**
|
||||
* Handles a DiceAgain message received from the server.
|
||||
|
||||
@@ -11,7 +11,7 @@ public class UpdateTSK extends ServerMessage {
|
||||
/**
|
||||
* The name associated with the update.
|
||||
*/
|
||||
private final String name;
|
||||
private final int id;
|
||||
|
||||
/**
|
||||
* The color associated with the update.
|
||||
@@ -21,12 +21,12 @@ public class UpdateTSK extends ServerMessage {
|
||||
/**
|
||||
* Constructs a new UpdateTSK instance with the specified name and color.
|
||||
*
|
||||
* @param name the name associated with the update
|
||||
* @param id the name associated with the update
|
||||
* @param color the color associated with the update
|
||||
*/
|
||||
public UpdateTSK(String name, Color color) {
|
||||
public UpdateTSK(int id, Color color) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.id = id;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ private UpdateTSK() {
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,7 +53,7 @@ public void received(DeselectTSK msg, int from) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(ForceStartGame msg, int from) {
|
||||
public void received(StartGame msg, int from) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user