Dialog state machine is now fully functional
This commit is contained in:
@@ -247,8 +247,8 @@ public void selectLeave(){
|
||||
state.selectLeave();
|
||||
}
|
||||
|
||||
public void selectJoin(String name){
|
||||
state.selectJoin(name);
|
||||
public void selectJoin(String ip){
|
||||
state.selectJoin(ip);
|
||||
}
|
||||
|
||||
public void selectAnimationEnd(){
|
||||
|
||||
@@ -207,7 +207,7 @@ public void selectHost(String name) {
|
||||
LOGGER.log(Level.DEBUG, "Selecting host not allowed.");
|
||||
}
|
||||
|
||||
public void selectJoin(String name) {
|
||||
public void selectJoin(String string) {
|
||||
LOGGER.log(Level.DEBUG, "Selecting join not allowed.");
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,9 @@
|
||||
import pp.mdga.client.dialogState.LobbyState;
|
||||
import pp.mdga.client.dialogState.NetworkDialogState;
|
||||
import pp.mdga.client.dialogState.StartDialogState;
|
||||
import pp.mdga.game.Color;
|
||||
import pp.mdga.game.Player;
|
||||
import pp.mdga.message.server.LobbyPlayerJoinMessage;
|
||||
import pp.mdga.message.server.LobbyPlayerLeaveMessage;
|
||||
import pp.mdga.message.server.UpdateReadyMessage;
|
||||
import pp.mdga.message.server.UpdateTSKMessage;
|
||||
import pp.mdga.message.server.*;
|
||||
|
||||
public class DialogsState extends ClientState {
|
||||
|
||||
@@ -73,6 +71,46 @@ public void startGame(){
|
||||
logic.setState(logic.getGameState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectLeave(){
|
||||
currentState.selectLeave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectTSK(Color color){
|
||||
currentState.selectTSK(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deselectTSK(Color color){
|
||||
currentState.deselectTSK(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectReady(boolean ready){
|
||||
currentState.selectReady(ready);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectUnready(){
|
||||
currentState.selectUnready();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectStart(){
|
||||
currentState.selectStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectJoin(String string){
|
||||
currentState.selectJoin(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectHost(String name){
|
||||
currentState.selectHost(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(LobbyPlayerJoinMessage msg){
|
||||
currentState.received(msg);
|
||||
@@ -93,6 +131,11 @@ public void received(UpdateReadyMessage msg){
|
||||
currentState.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(ServerStartGameMessage msg){
|
||||
currentState.received(msg);
|
||||
}
|
||||
|
||||
public DialogStates getState() {
|
||||
return currentState;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,13 @@ public void selectUnready(){
|
||||
|
||||
@Override
|
||||
public void selectStart(){
|
||||
logic.send(new StartGameMessage());
|
||||
if(logic.isHost() && logic.getGame().allReady()){
|
||||
logic.send(new StartGameMessage(false));
|
||||
} else if(logic.isHost() && !logic.getGame().allReady()) {
|
||||
logic.send(new StartGameMessage(true));
|
||||
} else {
|
||||
LOGGER.log(System.Logger.Level.ERROR, "You are not the host");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,6 +27,7 @@ public void enter() {
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
currentState.exit();
|
||||
currentState= null;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,16 @@
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gameState.TurnState;
|
||||
import pp.mdga.message.server.*;
|
||||
|
||||
public class MovePieceState extends TurnStates {
|
||||
|
||||
private final TurnState parent;
|
||||
|
||||
public MovePieceState(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
this.parent = (TurnState) parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -17,4 +23,28 @@ public void enter() {
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(CeremonyMessage msg){
|
||||
logic.setState(logic.getCeremony());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(EndOfTurnMessage msg){
|
||||
parent.getParent().setState(parent.getParent().getWaiting());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(SpectatorMessage msg){
|
||||
parent.getParent().setState(parent.getParent().getSpectator());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DiceAgainMessage msg){
|
||||
parent.setState(parent.getRollDice());
|
||||
}
|
||||
|
||||
public TurnState getParent() {
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gameState.TurnState;
|
||||
import pp.mdga.message.client.AnimationEndMessage;
|
||||
import pp.mdga.message.server.PlayCardMessage;
|
||||
import pp.mdga.notification.PlayCardNotification;
|
||||
|
||||
public class PlayPowerCardState extends TurnStates {
|
||||
|
||||
@@ -18,7 +20,7 @@ public PlayPowerCardState(ClientState parent, ClientGameLogic logic) {
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
logic.addNotification(new PlayCardNotification(null , playCardMessage.getCard())); //TODO: get color
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -29,4 +31,10 @@ public void exit() {
|
||||
public void setPlayCard(PlayCardMessage playCardMessage) {
|
||||
this.playCardMessage = playCardMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectAnimationEnd(){
|
||||
parent.setState(parent.getRollDice());
|
||||
logic.send(new AnimationEndMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ public void enter() {
|
||||
state = choosePowerCardState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
state.exit();
|
||||
state = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,17 @@
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gameState.TurnState;
|
||||
import pp.mdga.message.server.DieMessage;
|
||||
import pp.mdga.message.server.NoTurnMessage;
|
||||
|
||||
public class RollDiceState extends TurnStates {
|
||||
|
||||
private final TurnState parent;
|
||||
|
||||
public RollDiceState(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
this.parent = (TurnState) parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -15,6 +22,20 @@ public void enter() {
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
logic.getGame().setDiceModifier(1);
|
||||
}
|
||||
|
||||
public TurnState getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void received(DieMessage msg){
|
||||
logic.getGame().setDiceEyes(msg.getDiceEye());
|
||||
parent.setState(parent.getChoosePiece());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(NoTurnMessage msg){
|
||||
parent.getParent().setState(parent.getParent().getWaiting());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public void selectPiece(Piece piece) {
|
||||
|
||||
@Override
|
||||
public void received(PlayCardMessage msg) {
|
||||
parent.getParent().setState(parent.getParent().getPlayPowerCard());
|
||||
parent.getParent().getPlayPowerCard().setPlayCard(msg);
|
||||
parent.getParent().setState(parent.getParent().getPlayPowerCard());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public void selectPiece(Piece piece){
|
||||
|
||||
@Override
|
||||
public void received(PlayCardMessage msg) {
|
||||
parent.getParent().setState(parent.getParent().getPlayPowerCard());
|
||||
parent.getParent().getPlayPowerCard().setPlayCard(msg);
|
||||
parent.getParent().setState(parent.getParent().getPlayPowerCard());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,11 +14,6 @@ public class DieMessage extends ServerMessage {
|
||||
*/
|
||||
private final int diceEye;
|
||||
|
||||
/**
|
||||
* The pieces that can be moved
|
||||
*/
|
||||
private final List<String> moveablePieces;
|
||||
|
||||
/**
|
||||
* Constructor for Dice
|
||||
*
|
||||
@@ -28,7 +23,6 @@ public class DieMessage extends ServerMessage {
|
||||
public DieMessage(int diceEye, List<String> moveablePieces) {
|
||||
super();
|
||||
this.diceEye = diceEye;
|
||||
this.moveablePieces = moveablePieces;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,7 +30,6 @@ public DieMessage(int diceEye, List<String> moveablePieces) {
|
||||
*/
|
||||
private DieMessage() {
|
||||
diceEye = 0;
|
||||
moveablePieces = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,15 +62,6 @@ public int getDiceEye() {
|
||||
return diceEye;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for the pieces that can be moved
|
||||
*
|
||||
* @return the pieces that can be moved
|
||||
*/
|
||||
public List<String> getMoveablePieces() {
|
||||
return moveablePieces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts a visitor to process this message.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user