diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-05-05 16:48:17 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-05-05 16:48:17 +0200 |
commit | 7ee737f0d38bd815dc26a81a440148beebb17385 (patch) | |
tree | 0cf573d0a930ec710183d15b23d16f75228e1c75 /src/jrummikub | |
parent | f5075789facf8a133f1c225ca9d25a1e0a801f43 (diff) | |
download | JRummikub-7ee737f0d38bd815dc26a81a440148beebb17385.tar JRummikub-7ee737f0d38bd815dc26a81a440148beebb17385.zip |
Implement tableDifference (and fix test...)
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@144 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub')
-rw-r--r-- | src/jrummikub/control/RoundControl.java | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/jrummikub/control/RoundControl.java b/src/jrummikub/control/RoundControl.java index cce6160..1411337 100644 --- a/src/jrummikub/control/RoundControl.java +++ b/src/jrummikub/control/RoundControl.java @@ -1,5 +1,6 @@ package jrummikub.control; +import java.util.HashSet; import java.util.Set; import jrummikub.model.IGameState; @@ -7,7 +8,9 @@ import jrummikub.model.IHand; import jrummikub.model.ITable; import jrummikub.model.Position; import jrummikub.model.Stone; +import jrummikub.model.StoneSet; import jrummikub.util.IListener; +import jrummikub.util.Pair; import jrummikub.view.IView; public class RoundControl { @@ -52,10 +55,8 @@ public class RoundControl { for (int i = 0; i < gameState.getPlayerCount(); i++) { IHand hand = gameState.getPlayer(i).getHand(); for (int j = 0; j < 7; j++) { - hand.drop(gameState.getGameHeap().drawStone(), new Position(j, - 0)); - hand.drop(gameState.getGameHeap().drawStone(), new Position(j, - 1)); + hand.drop(gameState.getGameHeap().drawStone(), new Position(j, 0)); + hand.drop(gameState.getGameHeap().drawStone(), new Position(j, 1)); } } } @@ -65,7 +66,20 @@ public class RoundControl { } static Set<Stone> tableDifference(ITable oldTable, ITable newTable) { - return null; + Set<Stone> ret = new HashSet<Stone>(); + + for (Pair<StoneSet, Position> entry : newTable) { + for (Stone stone : entry.getFirst()) { + ret.add(stone); + } + } + for (Pair<StoneSet, Position> entry : oldTable) { + for (Stone stone : entry.getFirst()) { + ret.remove(stone); + } + } + + return ret; } private void resetTable() { |