refactored the GameStates

This commit is contained in:
Johannes Schmelz 2024-06-09 14:52:57 +02:00
parent 49d958652a
commit 1178730173
30 changed files with 42 additions and 20 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -21,7 +21,7 @@ class ActionHandler {
*/
ActionHandler(MauMau game) {
this.game = game;
gameState = new Initialized();
gameState = new Initialized(this);
}
/**

View File

@ -1,4 +1,4 @@
package cards.maumau.model.gamestate;
package cards.maumau.model;
public class Canceled implements GameState{

View File

@ -1,4 +1,4 @@
package cards.maumau.model.gamestate;
package cards.maumau.model;
public class Finished implements GameState{

View File

@ -0,0 +1,17 @@
package cards.maumau.model;
import cards.Card;
import cards.Suit;
public interface GameState {
public void addPlayer(Player player);
public void startGame();
public void finishGame();
public void cancelGame();
public void chooseCard(Card c);
public void chooseSuit(Suit suit);
public void skip();
public void no7();
boolean canPlay(Card c);
}

View File

@ -0,0 +1,16 @@
package cards.maumau.model;
public class Initialized implements GameState {
private final ActionHandler handler;
Initialized(ActionHandler handler) {
this.handler = handler;
}
public void addPlayer(Player player) {
handler.getGame().getPlayerHandler().addPlayer(player);
}
}

View File

@ -1,4 +1,4 @@
package cards.maumau.model.gamestate;
package cards.maumau.model;
public class JackChosen implements GameState{

View File

@ -61,7 +61,7 @@ public class MauMau {
*
* @return The player handler.
*/
PlayerHandler getPlayerHandler() {
public PlayerHandler getPlayerHandler() {
return playerHandler;
}
@ -70,7 +70,7 @@ public class MauMau {
*
* @return The card handler.
*/
CardHandler getCardHandler() {
public CardHandler getCardHandler() {
return cardHandler;
}

View File

@ -1,4 +1,4 @@
package cards.maumau.model.gamestate;
package cards.maumau.model;
public class Normal implements GameState{

View File

@ -1,4 +1,4 @@
package cards.maumau.model.gamestate;
package cards.maumau.model;
public class SevenChosen implements GameState{

View File

@ -1,4 +1,4 @@
package cards.maumau.model.gamestate;
package cards.maumau.model;
public class SuitChosen implements GameState{

View File

@ -1,5 +0,0 @@
package cards.maumau.model.gamestate;
public interface GameState {
}

View File

@ -1,6 +0,0 @@
package cards.maumau.model.gamestate;
public class Initialized implements GameState {
}