summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control/TurnControl.java
diff options
context:
space:
mode:
authorJannis Harder <harder@informatik.uni-luebeck.de>2011-05-25 17:10:43 +0200
committerJannis Harder <harder@informatik.uni-luebeck.de>2011-05-25 17:10:43 +0200
commita1c0cb89f67386738fc59426fd68737a393e1827 (patch)
tree8f0603073d4ea10919ce74840bb1d7514553bcb2 /src/jrummikub/control/TurnControl.java
parent157bd4f60635dc27d2c9baebea5589455b05f17b (diff)
downloadJRummikub-a1c0cb89f67386738fc59426fd68737a393e1827.tar
JRummikub-a1c0cb89f67386738fc59426fd68737a393e1827.zip
Added test and implementation for an inspection turn before the first
turn git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@273 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/control/TurnControl.java')
-rw-r--r--src/jrummikub/control/TurnControl.java35
1 files changed, 20 insertions, 15 deletions
diff --git a/src/jrummikub/control/TurnControl.java b/src/jrummikub/control/TurnControl.java
index 4140b57..9ce08b0 100644
--- a/src/jrummikub/control/TurnControl.java
+++ b/src/jrummikub/control/TurnControl.java
@@ -35,22 +35,27 @@ public class TurnControl {
private Event endOfTurnEvent = new Event();
private List<Connection> connections = new ArrayList<Connection>();
+
+ private boolean inspectOnly;
/**
- * Create a new TurnControl using a given hand (of the active player), a given
- * table and a given view for user interaction.
+ * Create a new TurnControl using a given hand (of the active player), a
+ * given table and a given view for user interaction.
*
* @param hand
- * active player's hand
+ * active player's hand
* @param table
- * current table
+ * current table
* @param view
- * view for user interaction.
+ * view for user interaction.
+ * @param inspectOnly
+ * the current turn doesn't allow any table manipulation
*/
- public TurnControl(IHand hand, ITable table, IView view) {
+ public TurnControl(IHand hand, ITable table, IView view, boolean inspectOnly) {
this.hand = hand;
this.table = table;
this.view = view;
+ this.inspectOnly = inspectOnly;
this.timer = new TurnTimer(view);
}
@@ -60,6 +65,7 @@ public class TurnControl {
this.table = table;
this.view = view;
this.timer = testTimer;
+ this.inspectOnly = false;
}
/**
@@ -80,7 +86,8 @@ public class TurnControl {
addHandPanelHandlers();
addStoneCollectionHandlers();
- addTablePanelHandlers();
+ if (!inspectOnly)
+ addTablePanelHandlers();
connections.add(view.getPlayerPanel().getSortByGroupsEvent()
.add(new IListener() {
@@ -419,15 +426,12 @@ public class TurnControl {
table.drop(joinedSet, newPos);
} else {
StoneSet joinedSet = new StoneSet(selectedStones).join(newSet);
- table.drop(joinedSet,
- new Position(newPos.getX() - selectedStones.size(), newPos.getY()));
+ table.drop(joinedSet, new Position(newPos.getX()
+ - selectedStones.size(), newPos.getY()));
}
} else {
- table.drop(
- new StoneSet(selectedStones),
- new Position(
- pos.getX() + (set.size() - selectedStones.size()) * 0.5f, pos
- .getY()));
+ table.drop(new StoneSet(selectedStones), new Position(pos.getX()
+ + (set.size() - selectedStones.size()) * 0.5f, pos.getY()));
}
selectedStones.clear();
@@ -527,7 +531,8 @@ public class TurnControl {
static class HandStonePositionComparator implements
Comparator<Pair<Stone, Position>> {
@Override
- public int compare(Pair<Stone, Position> pair1, Pair<Stone, Position> pair2) {
+ public int compare(Pair<Stone, Position> pair1,
+ Pair<Stone, Position> pair2) {
Position pos1 = pair1.getSecond(), pos2 = pair2.getSecond();
if (pos1.getY() < pos2.getY()) {
return -1;