This commit is contained in:
Cedric Beck
2024-12-02 17:12:00 +01:00
9 changed files with 33 additions and 23 deletions

View File

@@ -18,7 +18,7 @@ public CeremonyState(ClientState parent, ClientGameLogic logic) {
@Override
public void enter() {
currentState = podiumState;
setState(podiumState);
logic.addNotification(createCeremonyNotification());
}
@@ -28,7 +28,9 @@ public void exit() {
}
public void setState(CeremonyStates state){
this.currentState.exit();
if(this.currentState != null){
this.currentState.exit();
}
state.enter();
currentState = state;
}

View File

@@ -30,13 +30,15 @@ public void exit(){
@Override
public void enter(){
currentState = startDialogState;
setState(startDialogState);
ownPlayerID = 0;
ownPlayerName = null;
}
public void setState(DialogStates newState){
currentState.exit();
if(currentState != null){
currentState.exit();
}
newState.enter();
currentState = newState;
}
@@ -69,11 +71,6 @@ public StartDialogState getStartDialog() {
return startDialogState;
}
public void startGame(){
exit();
logic.setState(logic.getGameState());
}
@Override
public void selectLeave(){
currentState.selectLeave();

View File

@@ -27,7 +27,6 @@ public class GameState extends ClientState {
*/
public GameState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
state = determineStartPlayerState;
}
/**
@@ -35,7 +34,7 @@ public GameState(ClientState parent, ClientGameLogic logic) {
*/
@Override
public void enter() {
this.setState(this.determineStartPlayerState);
}
/**
@@ -52,8 +51,10 @@ public void exit() {
* @param newState the state to be set
*/
public void setState(GameStates newState){
state.exit();
state.enter();
if(this.state != null){
this.state.exit();
}
newState.enter();
state = newState;
}

View File

@@ -95,7 +95,7 @@ public void received(ServerStartGameMessage msg){
}
logic.addNotification(new PlayerInGameNotification(entry.getKey(), pieceList , logic.getGame().getPlayerByColor(entry.getKey()).getName()));
}
parent.startGame();
logic.setState(logic.getGameState());
}
@Override

View File

@@ -34,7 +34,9 @@ public void exit() {
}
public void setState(DetermineStartPlayerStates state) {
this.state.exit();
if(this.state != null){
this.state.exit();
}
state.enter();
this.state = state;
}

View File

@@ -31,7 +31,7 @@ public TurnState(ClientState parent, ClientGameLogic logic) {
@Override
public void enter() {
state = powerCardState;
this.setState(this.powerCardState);
}
@Override
@@ -40,7 +40,9 @@ public void exit() {
}
public void setState(TurnStates state){
this.state.exit();
if(this.state != null){
this.state.exit();
}
state.enter();
this.state = state;
}

View File

@@ -6,6 +6,7 @@
import pp.mdga.message.client.RequestDieMessage;
import pp.mdga.message.server.DieMessage;
import pp.mdga.notification.DiceNowNotification;
import pp.mdga.notification.RollDiceNotification;
public class RollRankingDiceState extends DetermineStartPlayerStates {
@@ -23,16 +24,17 @@ public void enter() {
@Override
public void exit() {
}
@Override
public void selectDice(){
System.out.println("selectDice");
logic.send(new RequestDieMessage());
}
@Override
public void received(DieMessage msg){
logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getDialogs().getOwnPlayerId()).getColor(), msg.getDiceEye(),true));
parent.setState(parent.getWaitRanking());
}
}

View File

@@ -24,7 +24,7 @@ public ChoosePieceState(ClientState parent, ClientGameLogic logic) {
@Override
public void enter() {
currentState = noPieceState;
this.setState(this.noPieceState);
}
@Override
@@ -34,9 +34,11 @@ public void exit() {
}
public void setState(ChoosePieceStates state){
currentState.exit();
if(currentState != null){
currentState.exit();
}
state.enter();
currentState = state;
currentState.enter();
}
@Override

View File

@@ -31,7 +31,7 @@ public PowerCardState(ClientState parent, ClientGameLogic logic) {
@Override
public void enter() {
state = choosePowerCardState;
this.setState(this.choosePowerCardState);
}
public void exit() {
@@ -40,7 +40,9 @@ public void exit() {
}
public void setState(PowerCardStates state) {
this.state.exit();
if(this.state != null){
this.state.exit();
}
state.enter();
this.state = state;
}