From f5cff88ec9177b23dc8979aa9645a427a78c6f46 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 21 Jun 2011 00:04:16 +0200 Subject: Major refactoring of RoundControl and TurnControl git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@516 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/control/turn/ITurnControl.java | 68 ++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 20 deletions(-) (limited to 'src/jrummikub/control/turn/ITurnControl.java') 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 getEndOfTurnEvent(); + public IEvent2 getEndOfTurnEvent(); /** * Emitted when the round is aborted and needs to be restarted @@ -58,35 +60,61 @@ public interface ITurnControl { public IEvent1 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(); } /** -- cgit v1.2.3