From 07e2388b95fc58dfa6c053b9384c883fb5dfc8e3 Mon Sep 17 00:00:00 2001 From: Bennet Gerlach Date: Tue, 10 May 2011 03:55:58 +0200 Subject: Fixed method lines of code of TurnControl git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@214 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/control/TurnControl.java | 86 ++++++++++++++++++++++------------ 1 file changed, 55 insertions(+), 31 deletions(-) (limited to 'src/jrummikub') diff --git a/src/jrummikub/control/TurnControl.java b/src/jrummikub/control/TurnControl.java index ace201e..d280096 100644 --- a/src/jrummikub/control/TurnControl.java +++ b/src/jrummikub/control/TurnControl.java @@ -77,6 +77,33 @@ public class TurnControl { connections.add(view.getPlayerPanel().getEndTurnEvent() .add(endOfTurnListener)); + addHandPanelHandlers(); + addStoneCollectionHandlers(); + addTablePanelHandlers(); + + 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); + + timer.startTimer(); + } + + private void addHandPanelHandlers() { connections.add(view.getPlayerPanel().getHandPanel().getClickEvent() .add(new IListener1() { @Override @@ -85,8 +112,8 @@ public class TurnControl { } })); - connections.add(view.getPlayerPanel().getHandPanel() - .getStoneClickEvent().add(new IListener2() { + connections.add(view.getPlayerPanel().getHandPanel().getStoneClickEvent() + .add(new IListener2() { @Override public void handle(Stone stone, Boolean collect) { @@ -94,15 +121,17 @@ public class TurnControl { } })); - connections.add(view.getPlayerPanel().getHandPanel() - .getRangeClickEvent().add(new IListener2() { + connections.add(view.getPlayerPanel().getHandPanel().getRangeClickEvent() + .add(new IListener2() { @Override public void handle(Stone stone, Boolean collect) { handRangeClick(stone, collect); } })); + } + private void addStoneCollectionHandlers() { connections.add(view.getTablePanel().getStoneCollectionPanel() .getStoneClickEvent().add(new IListener2() { @@ -111,6 +140,7 @@ public class TurnControl { collectionStoneClick(stone, collect); } })); + connections.add(view.getTablePanel().getStoneCollectionPanel() .getSetClickEvent().add(new IListener2() { @@ -119,6 +149,9 @@ public class TurnControl { collectionSetClick(stone, collect); } })); + } + + private void addTablePanelHandlers() { connections.add(view.getTablePanel().getStoneClickEvent() .add(new IListener2() { @@ -127,6 +160,7 @@ public class TurnControl { stoneClick(stone, collect); } })); + connections.add(view.getTablePanel().getSetClickEvent() .add(new IListener2() { @@ -135,6 +169,7 @@ public class TurnControl { tableSetClick(stone, collect); } })); + connections.add(view.getTablePanel().getRangeClickEvent() .add(new IListener2() { @@ -151,6 +186,11 @@ public class TurnControl { tableClick(pos); } })); + + addTablePanelConnectorClickHandlers(); + } + + private void addTablePanelConnectorClickHandlers() { connections.add(view.getTablePanel().getLeftConnectorClickEvent() .add(new IListener1() { @Override @@ -158,6 +198,7 @@ public class TurnControl { connectorClick(set, false); } })); + connections.add(view.getTablePanel().getRightConnectorClickEvent() .add(new IListener1() { @Override @@ -165,25 +206,6 @@ 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); - - timer.startTimer(); } private void handClick(Position pos) { @@ -226,8 +248,8 @@ public class TurnControl { if (y >= GameControl.HAND_HEIGHT) { throw new ArrayIndexOutOfBoundsException(); // TODO We can't - // handle - // this yet... + // handle + // this yet... } } } @@ -401,12 +423,15 @@ 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(); @@ -506,8 +531,7 @@ public class TurnControl { static class HandStonePositionComparator implements Comparator> { @Override - public int compare(Pair pair1, - Pair pair2) { + public int compare(Pair pair1, Pair pair2) { Position pos1 = pair1.getSecond(), pos2 = pair2.getSecond(); if (pos1.getY() < pos2.getY()) { return -1; -- cgit v1.2.3