20 package net.sf.gridarta.var.crossfire.model.gameobject;
22 import java.util.Iterator;
26 import org.jetbrains.annotations.NotNull;
27 import org.junit.Assert;
28 import org.junit.Test;
48 check(gameObjectContainer, 123);
52 check(gameObjectContainer, 123);
56 check(gameObjectContainer, 123);
70 check(gameObjectContainer, 123);
74 check(gameObjectContainer, 123, 0);
78 check(gameObjectContainer, 123, 0, 321);
92 check(gameObjectContainer, 1);
96 check(gameObjectContainer, 1, 0);
101 check(gameObjectContainer, 1, 0, 0);
105 check(gameObjectContainer, 1, 3, 0, 0);
109 check(gameObjectContainer, 1, 0, 3, 0, 0);
123 check(gameObjectContainer, 1);
128 check(gameObjectContainer, 1, 2);
132 check(gameObjectContainer, 1, 0, 2);
136 check(gameObjectContainer, 1, 0, 3, 2);
140 check(gameObjectContainer, 1, 0, 0, 3, 2);
152 check(container1, 1, 0, 0, 0);
154 check(container1, 1, 0, 0, 0);
156 check(container1, 1, 0, 0, 0);
167 container1.
moveDown(
get(container1, 0));
168 check(container1, 1, 0, 0, 0);
169 container1.
moveDown(
get(container1, 1));
170 check(container1, 1, 0, 0, 0);
171 container1.
moveDown(
get(container1, 3));
172 check(container1, 1, 0, 0, 0);
183 container1.
moveUp(
get(container1, 0));
184 check(container1, 1, 0, 0, 0);
185 container1.
moveUp(
get(container1, 1));
186 check(container1, 1, 0, 0, 0);
187 container1.
moveUp(
get(container1, 3));
188 check(container1, 1, 0, 0, 0);
199 container1.
moveTop(
get(container1, 0));
200 check(container1, 1, 0, 0, 0);
201 container1.
moveTop(
get(container1, 1));
202 check(container1, 1, 0, 0, 0);
203 container1.
moveTop(
get(container1, 3));
204 check(container1, 1, 0, 0, 0);
215 container1.
remove(
get(container1, 0));
216 check(container1, 1, 0, 0);
217 container1.
remove(
get(container1, 2));
218 check(container1, 1, 0);
219 container1.
remove(
get(container1, 0));
220 check(container1, 1);
221 container1.
remove(
get(container1, 0));
234 check(container1, 1, 0, 0, 0);
236 check(container1, 1, 3, 0, 0);
238 check(container1, 1, 3, 0, 0);
249 final Iterator<GameObject> it = container1.
iterator();
252 check(container1, 1, 0, 0, 0, 0);
255 check(container1, 1, 0, 0, 0);
259 check(container1, 1, 0, 0);
270 final Iterator<GameObject> it = container1.
reverse().iterator();
273 check(container1, 1, 0, 0, 0, 0);
276 check(container1, 1, 0, 0, 0);
280 check(container1, 1, 0, 0);
283 check(container1, 1, 0);
286 check(container1, 1);
287 Assert.assertFalse(it.hasNext());
300 for (
final int elevation : elevations) {
301 gameObject.
addLast(gameObjectCreator.newGameObject(elevation));
313 private static GameObject get(@NotNull
final Iterable<GameObject> gameObjects,
final int index) {
315 for (
final GameObject gameObject : gameObjects) {
322 Assert.fail(
"index " + index +
" not found");
323 throw new AssertionError();
331 private static void check(@NotNull
final Iterable<GameObject> gameObjects,
final int... elevation) {
333 for (
final GameObject gameObject : gameObjects) {
335 final int expectedElevation = i < elevation.length ? elevation[i] : 0;
336 Assert.assertEquals(gameObject.getBestName(), expectedElevation, thisElevation);
void testRemove()
Checks that GameObjectContainer#remove(net.sf.gridarta.model.gameobject.GameObject) does work correct...
void addLast(@NotNull final G gameObject)
Add the given GameObject at the end of this Container.
void testReplace()
Checks that net.sf.gridarta.model.gameobject.GameObject) does work correctly.
void insertBefore(@NotNull final G gameObject, @Nullable final G nextGameObject)
Add a GameObject before another.
MapArchObject contains the specific meta data about a map that is stored in the map-arch, at the very beginning of the map file.
void testAddFirst()
Checks that GameObjectContainer#addFirst(net.sf.gridarta.model.gameobject.GameObject) does work corre...
void addFirst(@NotNull final G gameObject)
Add the given GameObject at the end of this Container.
Base class for classes that contain GameObjects as children in the sense of containment.
Handles the Crossfire GameObjects.
void moveTop(@NotNull final G gameObject)
Move an item to top.
void testMoveTop()
Checks that GameObjectContainer#moveTop(net.sf.gridarta.model.gameobject.GameObject) does work correc...
void testReverse()
Checks that GameObjectContainer#reverse()'s Iterator#remove() does work correctly.
void testInsertAfter()
Checks that net.sf.gridarta.model.gameobject.GameObject) does work correctly.
Base package of all Gridarta classes.
void testMoveUp()
Checks that GameObjectContainer#moveUp(net.sf.gridarta.model.gameobject.GameObject) does work correct...
G getFirst()
Return the first GameObject contained in this container.
Implements Crossfire archetypes.
void testInsertBefore()
Checks that net.sf.gridarta.model.gameobject.GameObject) does work correctly.
void testIterator()
Checks that GameObjectContainer#iterator()'s Iterator#remove() does work correctly.
void testAddLast()
Checks that GameObjectContainer#addLast(net.sf.gridarta.model.gameobject.GameObject) does work correc...
static void check(@NotNull final Iterable< GameObject > gameObjects, final int... elevation)
Checks some game objects for expected elevation values.
Checks that GameObjectContainers correctly propagate elevation information when being modified...
transient Iterable< G > reverse
Iterable implementation for reverse traversal.
void insertAfter(@Nullable final G previousGameObject, @NotNull final G gameObject)
Add a GameObject after another.
void moveUp(@NotNull final G gameObject)
Move an item up.
Main package of Gridarta4Crossfire, contains all classes specific to the Crossfire version of the Gri...
Iterator< G > iterator()
The Iterator returned does not recurse, it only contains objects on the first level.
void testMoveBottom()
Checks that GameObjectContainer#moveBottom(net.sf.gridarta.model.gameobject.GameObject) does work cor...
void moveDown(@NotNull final G gameObject)
Move an item down.
GameObject newGameObject(final int elevation)
Creates a new GameObject.
static GameObjectContainer< GameObject, MapArchObject, Archetype > newContainer(@NotNull final GameObjectCreator gameObjectCreator, final int... elevations)
Creates a new GameObjectContainer that contains game objects with the given elevation values...
static final String ELEVATION
The name of the "elevation" attribute.
void remove(@NotNull final G gameObject)
Remove a GameObject from this container.
void testMoveDown()
Checks that GameObjectContainer#moveDown(net.sf.gridarta.model.gameobject.GameObject) does work corre...
void replace(@NotNull final G oldGameObject, @NotNull final G newGameObject)
Replace an GameObject with another one.
void moveBottom(@NotNull final G gameObject)
Move an item to bottom.