20 package net.sf.gridarta.model.mapmodel;
22 import java.awt.Point;
23 import java.util.regex.Pattern;
38 import org.jetbrains.annotations.NotNull;
39 import org.junit.Assert;
125 archetypeSet.addArchetype(mob21bArchetype);
186 if (gameObject ==
null) {
187 throw new IllegalArgumentException(
"failed to insert archetype");
221 gameObject.addLast(newGameObject);
222 return newGameObject;
231 final Size2D mapSize = mapModel.getMapArchObject().getMapSize();
232 Assert.assertEquals(lines.length, mapSize.
getHeight());
233 final Pattern pattern1 = Pattern.compile(
"\\|");
235 final Point pos =
new Point();
236 for (
int y = 0; y < lines.length; y++) {
237 final CharSequence line = lines[y];
238 final String[] square = pattern1.split(line, -1);
239 Assert.assertEquals(square.length, mapSize.
getWidth());
241 for (
int x = 0; x < square.length; x++) {
242 final String square2 = square[x];
243 final String[] gameObjects = square2.isEmpty() ?
EMPTY_STRING_ARRAY : pattern2.split(square2, -1);
259 final String gameObjectName = gameObject.getBestName();
260 if (i >= gameObjects.length) {
261 Assert.fail(
"map square " + mapSquare.
getMapX() +
"/" + mapSquare.
getMapY() +
" contains excess game object '" + gameObjectName +
"'");
262 }
else if (!gameObjectName.equals(gameObjects[i])) {
263 Assert.fail(
"map square " + mapSquare.
getMapX() +
"/" + mapSquare.
getMapY() +
" contains wrong game object '" + gameObjectName +
"' at index " + i +
", expected '" + gameObjects[i] +
"'");
267 if (i < gameObjects.length) {
268 Assert.fail(
"map square " + mapSquare.
getMapX() +
"/" + mapSquare.
getMapY() +
" is missing game object '" + gameObjects[i] +
"'");
280 final String gameObjectName = gameObject.getBestName();
281 if (i >= gameObjects.length) {
282 Assert.fail(
"map square contains excess game object '" + gameObjectName +
"'");
283 }
else if (gameObject != gameObjects[i]) {
284 Assert.fail(
"map square contains wrong game object '" + gameObjectName +
"' at index " + i +
", expected '" + gameObjects[i].getBestName() +
"'");
288 if (i < gameObjects.length) {
289 Assert.fail(
"map square is missing game object '" + gameObjects[i].getBestName() +
"'");
292 final boolean inContainer = mapSquare instanceof
GameObject;
294 Assert.assertEquals(inContainer, gameObject.isInContainer());
297 Assert.assertFalse(gameObject.isMulti());
300 Assert.assertEquals(gameObject.getArchetype().isMulti(), gameObject.isMulti());