diff --git a/bin/cards/maumau/model/ActionHandler.class b/bin/cards/maumau/model/ActionHandler.class index 8be4178..836885c 100644 Binary files a/bin/cards/maumau/model/ActionHandler.class and b/bin/cards/maumau/model/ActionHandler.class differ diff --git a/bin/cards/maumau/model/Normal.class b/bin/cards/maumau/model/Normal.class index 3d4eb02..b028978 100644 Binary files a/bin/cards/maumau/model/Normal.class and b/bin/cards/maumau/model/Normal.class differ diff --git a/bin/cards/maumau/model/WaitForNextTurnState.class b/bin/cards/maumau/model/WaitForNextTurnState.class index eef4723..bc438b7 100644 Binary files a/bin/cards/maumau/model/WaitForNextTurnState.class and b/bin/cards/maumau/model/WaitForNextTurnState.class differ diff --git a/src/cards/maumau/model/ActionHandler.java b/src/cards/maumau/model/ActionHandler.java index 02ffb61..b71e657 100644 --- a/src/cards/maumau/model/ActionHandler.java +++ b/src/cards/maumau/model/ActionHandler.java @@ -1,5 +1,6 @@ package cards.maumau.model; + import cards.Card; import cards.Suit; @@ -11,8 +12,8 @@ class ActionHandler { private Suit chosenSuit; private int ctr7 = 0; - private GameState gameState; - private HandlerState handlerState; + private GameState gameState = GameState.GAME_INITIALIZED; + private HandlerState handlerState = new Initialized(this); /** * Constructs an ActionHandler for the specified MauMau game. @@ -37,7 +38,7 @@ class ActionHandler { * @param player The player to be added to the game. */ void addPlayer(Player player) { - //TODO implement + handlerState.addPlayer(player); } /** diff --git a/src/cards/maumau/model/Normal.java b/src/cards/maumau/model/Normal.java index ae9bc86..206b498 100644 --- a/src/cards/maumau/model/Normal.java +++ b/src/cards/maumau/model/Normal.java @@ -1,6 +1,7 @@ package cards.maumau.model; import cards.Card; +import cards.Rank; import cards.Suit; public class Normal implements HandlerState { @@ -12,15 +13,30 @@ public class Normal implements HandlerState { public void addPlayer(Player player){} public void startGame(){} - public void finishGame(){ - // Logic for finishing Game ???? - if (handler.getGame().getPlayerHandler().getPlayers().isEmpty()) { - handler.setHandlerState(new Finished(handler)); + public void finishGame(){} + public void cancelGame(){} + + public void chooseCard(Card c){ + if (handler.canPlay(c)) { + handler.getGame().getPlayerHandler().getCurrentPlayer().playCard(c); + if (c.rank() == Rank.SEVEN) { + handler.increment7Counter(); + handler.getGame().getPlayerHandler().nextTurn(1); + handler.setHandlerState(new SevenChosen(handler)); + } else if (c.rank() == Rank.JACK) { + handler.setHandlerState(new JackChosen(handler)); + } else if (c.rank() == Rank.EIGHT) { + handler.getGame().getPlayerHandler().nextTurn(2); + } else { + handler.getGame().getPlayerHandler().nextTurn(1); + } } } - public void cancelGame(){} - public void chooseCard(Card c){} + public void chooseSuit(Suit suit){} - public void skip(){} + public void skip(){ + handler.getGame().getPlayerHandler().getCurrentPlayer().drawCards(1); + handler.getGame().getPlayerHandler().nextTurn(1); + } public void no7(){} } diff --git a/src/cards/maumau/model/WaitForNextTurnState.java b/src/cards/maumau/model/WaitForNextTurnState.java index 97bc700..95d568d 100644 --- a/src/cards/maumau/model/WaitForNextTurnState.java +++ b/src/cards/maumau/model/WaitForNextTurnState.java @@ -1,6 +1,6 @@ package cards.maumau.model; -public class WaitForNextTurnState implements PlayerState { +public class WaitForNextTurnState implements PlayerState { private final PlayerHandler handler; public WaitForNextTurnState(PlayerHandler handler) { @@ -14,9 +14,13 @@ public class WaitForNextTurnState implements PlayerState { handler.setRemember(handler.getCurrentPlayer()); handler.localNextTurn(n); handler.setCurrentState(handler.getWaitForMauMauState()); - } else { + } else if (handler.getCurrentPlayer().getCards().size() == 1) { + handler.setRemember(handler.getCurrentPlayer()); handler.localNextTurn(n); handler.setCurrentState(handler.getWaitForMauState()); + } else { + handler.localNextTurn(n); + handler.setCurrentState(handler.getWaitForNextTurnState()); } }