diff options
Diffstat (limited to 'src/jrummikub/control/turn/ITurnControl.java')
-rw-r--r-- | src/jrummikub/control/turn/ITurnControl.java | 68 |
1 files changed, 48 insertions, 20 deletions
diff --git a/src/jrummikub/control/turn/ITurnControl.java b/src/jrummikub/control/turn/ITurnControl.java index 5c91c0c..6994466 100644 --- a/src/jrummikub/control/turn/ITurnControl.java +++ b/src/jrummikub/control/turn/ITurnControl.java @@ -1,11 +1,13 @@ package jrummikub.control.turn; +import jrummikub.control.RoundControl.InvalidTurnInfo; import jrummikub.model.GameSettings; import jrummikub.model.IHand; +import jrummikub.model.IRoundState; import jrummikub.model.ITable; import jrummikub.util.IEvent; import jrummikub.util.IEvent1; -import jrummikub.util.IEvent3; +import jrummikub.util.IEvent2; import jrummikub.view.IView; /** @@ -17,12 +19,12 @@ public interface ITurnControl { * Start the turn * * @param info - * the current turn state + * the current turn state * * @param settings - * the game settings + * the game settings * @param view - * view for user interaction. + * view for user interaction. */ public void setup(TurnInfo info, GameSettings settings, IView view); @@ -31,7 +33,7 @@ public interface ITurnControl { * * @return end of turn event */ - public IEvent3<IHand, ITable, ITable> getEndOfTurnEvent(); + public IEvent2<IRoundState, InvalidTurnInfo> getEndOfTurnEvent(); /** * Emitted when the round is aborted and needs to be restarted @@ -58,35 +60,61 @@ public interface ITurnControl { public IEvent1<ITable> getTableUpdateEvent(); /** - * The TurnInfo class encapsulates all information concerning the current - * turn + * The TurnInfo class encapsulates all information concerning the current turn */ public class TurnInfo { + private IRoundState roundState; + + private ITable oldTable; + private IHand oldHand; + private ITable table; private IHand hand; - private boolean hasLaidOut; + private TurnMode turnMode; /** * Creates a new TurnInfo instance * - * @param table - * the current table - * @param hand - * the current player's hand * @param hasLaidOut - * has the player laid out yet? + * has the player laid out yet? * @param turnMode - * the turn mode + * the turn mode */ - public TurnInfo(ITable table, IHand hand, boolean hasLaidOut, - TurnMode turnMode) { - this.table = table; - this.hand = hand; - this.hasLaidOut = hasLaidOut; + public TurnInfo(IRoundState roundState, TurnMode turnMode) { + this.roundState = roundState; + + oldTable = roundState.getTable(); + oldHand = roundState.getActivePlayer().getHand(); + + this.table = (ITable) oldTable.clone(); + this.hand = (IHand) oldHand.clone(); + this.turnMode = turnMode; } + public IRoundState getRoundState() { + return roundState; + } + + /** + * Gets the table at the beginning of the turn + * + * @return the table + */ + public ITable getOldTable() { + return oldTable; + } + + /** + * Gets the current player's hand at the beginning of the turn + * + * @return the hand + */ + public IHand getOldHand() { + return oldHand; + } + /** * Gets the current table * @@ -111,7 +139,7 @@ public interface ITurnControl { * @return if the player has laid out */ public boolean getLaidOut() { - return hasLaidOut; + return roundState.getActivePlayer().getLaidOut(); } /** |