diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-05-09 00:33:34 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-05-09 00:33:34 +0200 |
commit | b86571cf832ff13010798f3607eea6ad0ef039d0 (patch) | |
tree | d39b22dc07ad068083181d701a8d8aad95a10c85 /mock/jrummikub | |
parent | b9fbe279c3d6e750f7c90ad0b244d315c9744bb2 (diff) | |
download | JRummikub-b86571cf832ff13010798f3607eea6ad0ef039d0.tar JRummikub-b86571cf832ff13010798f3607eea6ad0ef039d0.zip |
Allow laying out stone sets
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@180 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'mock/jrummikub')
-rw-r--r-- | mock/jrummikub/model/MockHand.java | 17 | ||||
-rw-r--r-- | mock/jrummikub/view/MockHandPanel.java | 11 |
2 files changed, 22 insertions, 6 deletions
diff --git a/mock/jrummikub/model/MockHand.java b/mock/jrummikub/model/MockHand.java index dc4dd04..994f7f5 100644 --- a/mock/jrummikub/model/MockHand.java +++ b/mock/jrummikub/model/MockHand.java @@ -8,7 +8,7 @@ import jrummikub.util.Pair; public class MockHand implements IHand { - public List<Stone> stones = new ArrayList<Stone>(); + public List<Pair<Stone, Position>> stones = new ArrayList<Pair<Stone, Position>>(); public Iterable<Pair<Stone, Position>> iterable; @@ -19,7 +19,7 @@ public class MockHand implements IHand { @Override public void drop(Stone object, Position position) { - stones.add(object); + stones.add(new Pair<Stone, Position>(object, position)); } @Override @@ -30,7 +30,12 @@ public class MockHand implements IHand { @Override public void pickUp(Stone object) { - stones.remove(object); + List<Pair<Stone, Position>> itList = new ArrayList(stones); + for (Pair<Stone, Position> entry : itList) { + if (entry.getFirst() == object) { + stones.remove(entry); + } + } } @Override @@ -40,7 +45,11 @@ public class MockHand implements IHand { @Override public Iterator<Pair<Stone, Position>> iterator() { - return iterable.iterator(); + if (iterable != null) { + return iterable.iterator(); + } else { + return stones.iterator(); + } } public MockHand clone() { diff --git a/mock/jrummikub/view/MockHandPanel.java b/mock/jrummikub/view/MockHandPanel.java index 4fdd58e..42bc41e 100644 --- a/mock/jrummikub/view/MockHandPanel.java +++ b/mock/jrummikub/view/MockHandPanel.java @@ -1,5 +1,8 @@ package jrummikub.view; +import java.util.ArrayList; +import java.util.List; + import jrummikub.model.Position; import jrummikub.model.Stone; import jrummikub.util.Event2; @@ -9,7 +12,7 @@ import jrummikub.util.Pair; public class MockHandPanel implements IHandPanel { public Event2<Stone, Boolean> stoneClickEvent = new Event2<Stone, Boolean>(); - public Iterable<Pair<Stone, Position>> stones; + public List<Pair<Stone, Position>> stones; @Override public IEvent2<Stone, Boolean> getStoneClickEvent() { @@ -36,7 +39,11 @@ public class MockHandPanel implements IHandPanel { @Override public void setStones(Iterable<Pair<Stone, Position>> stones) { - this.stones = stones; + this.stones = new ArrayList<Pair<Stone, Position>>(); + + for (Pair<Stone, Position> entry : stones) { + this.stones.add(entry); + } } } |