summaryrefslogtreecommitdiffstats
path: root/src/jrummikub
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub')
-rw-r--r--src/jrummikub/model/StoneTray.java6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/jrummikub/model/StoneTray.java b/src/jrummikub/model/StoneTray.java
index 07719cf..20dde3d 100644
--- a/src/jrummikub/model/StoneTray.java
+++ b/src/jrummikub/model/StoneTray.java
@@ -15,7 +15,7 @@ import jrummikub.util.Pair;
*/
public class StoneTray<E extends Sizeable> implements
Iterable<Pair<E, Position>> {
- protected List<Pair<E, Position>> objects = new ArrayList<Pair<E, Position>>();
+ protected ArrayList<Pair<E, Position>> objects = new ArrayList<Pair<E, Position>>();
/** Possible move directions in case of overlapping Stones/Sets */
@@ -68,8 +68,9 @@ public class StoneTray<E extends Sizeable> implements
drop(object, position, null);
}
+ @SuppressWarnings("unchecked")
private void drop(E object, Position position, Direction direction) {
- for (Pair<E, Position> i : objects) {
+ for (Pair<E, Position> i : (List<Pair<E, Position>>)objects.clone()) {
Position currentPosition = i.getSecond();
E currentObject = i.getFirst();
if (!objectsOverlap(object, position, currentObject,
@@ -100,6 +101,7 @@ public class StoneTray<E extends Sizeable> implements
currentPosition.getY());
break;
}
+
objects.remove(i);
drop(currentObject, newPosition, direction);
}