From 3338af2d439019fedced4be5b105ce06129a3712 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 10 May 2011 00:28:06 +0200 Subject: Add tests for hand auto-sort git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@203 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/control/TurnControl.java | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/jrummikub/control/TurnControl.java b/src/jrummikub/control/TurnControl.java index bf921e4..e82b30f 100644 --- a/src/jrummikub/control/TurnControl.java +++ b/src/jrummikub/control/TurnControl.java @@ -21,7 +21,7 @@ import jrummikub.util.Pair; import jrummikub.view.IView; public class TurnControl { - private static class HandStoneComparator implements + static class HandStonePositionComparator implements Comparator> { @Override public int compare(Pair pair1, @@ -161,6 +161,20 @@ public class TurnControl { connectorClick(set, true); } })); + connections.add(view.getPlayerPanel().getSortByGroupsEvent() + .add(new IListener() { + @Override + public void handle() { + sortByGroups(); + } + })); + connections.add(view.getPlayerPanel().getSortByRunsEvent() + .add(new IListener() { + @Override + public void handle() { + sortByRuns(); + } + })); view.getPlayerPanel().getHandPanel().setStones(hand.clone()); view.enableStartTurnPanel(false); @@ -168,11 +182,11 @@ public class TurnControl { timer.startTimer(); } - private void sortByValue() { + private void sortByRuns() { } - private void sortByColor() { + private void sortByGroups() { } @@ -286,7 +300,7 @@ public class TurnControl { handPairs.add(entry); } - Collections.sort(handPairs, new HandStoneComparator()); + Collections.sort(handPairs, new HandStonePositionComparator()); List handStones = new ArrayList(); for (Pair entry : handPairs) { @@ -338,8 +352,7 @@ public class TurnControl { - 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(RoundControl.HAND_WIDTH-1, RoundControl.HAND_HEIGHT-1)); } selectedStones.clear(); -- cgit v1.2.3