 |
Gridarta Editor
|
Go to the documentation of this file.
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());
An Archetype implementation for testing purposes.
int getWidth()
Returns the width of the area.
A MapModel reflects the data of a map.
An Archetype implementation for testing purposes.
Abstract factory for creating GameObject instances.
TestGameObject insertExit(@NotNull final MapModel< TestGameObject, TestMapArchObject, TestArchetype > mapModel, @NotNull final Point point)
Inserts an exitArchetype game object into a map model.
final TestArchetype mob21Archetype
The archetype to create 2x1 mob game objects.
Base package of all Gridarta classes.
int getMapX()
Returns the X coordinate of this GameObject on its map.
Helper class for creating MapModel instances for regression tests.
AnimationObjects is a container for AnimationObjects.
A GameObject implementation for testing purposes.
Provider for faces of GameObjects and Archetypes.
Reflects a game object (object on a map).
TestGameObject insertMob21(@NotNull final MapModel< TestGameObject, TestMapArchObject, TestArchetype > mapModel, @NotNull final Point point)
Inserts a mob21Archetype game object into a map model.
static void checkContentsString(@NotNull final MapSquare< TestGameObject, TestMapArchObject, TestArchetype > mapSquare, @NotNull final String... gameObjects)
Checks that a MapSquare contains the given game objects.
GameObjects are the objects based on Archetypes found on maps.
int getHeight()
Returns the height of the area.
TestGameObject insertMob21(@NotNull final GameObjectContainer< TestGameObject, TestMapArchObject, TestArchetype > gameObject)
Inserts a mob21Archetype game object into a game object.
final GameObjectFactory< TestGameObject, TestMapArchObject, TestArchetype > gameObjectFactory
The GameObjectFactory instance.
TestGameObject insertExit(@NotNull final GameObjectContainer< TestGameObject, TestMapArchObject, TestArchetype > gameObject)
Inserts an exitArchetype game object into a game object.
final TestArchetype exitArchetype
The archetype to create exit game objects.
static final String[] EMPTY_STRING_ARRAY
An empty array of strings.
TestGameObject insertFloor(@NotNull final MapModel< TestGameObject, TestMapArchObject, TestArchetype > mapModel, @NotNull final Point point)
Inserts a floorArchetype game object into a map model.
Interface that captures similarities between different ArchetypeSet implementations.
Utility class for string manipulation.
TestGameObject insertArchetype(@NotNull final MapModel< TestGameObject, TestMapArchObject, TestArchetype > mapModel, final int x, final int y, @NotNull final BaseObject< TestGameObject, TestMapArchObject, TestArchetype, ?> archetype, final boolean join)
Inserts an archetype game object into a map model.
int getMapY()
Returns the Y coordinate of this GameObject on its map.
static final int FLOOR_TYPE
The archetype type used for "floor" game objects.
static final Pattern PATTERN_COMMA
The pattern that matches a single comma (",").
static final int MOB_TYPE
The archetype type used for "mob" game objects.
static void checkMapContents(@NotNull final MapModel< TestGameObject, TestMapArchObject, TestArchetype > mapModel, @NotNull final String... lines)
Checks for expected MapModel's contents.
static final int EXIT_TYPE
The archetype type used for "exit" game objects.
The face is the appearance of an object.
Gridarta can handle frame information of animations and allow the selection of an animation using a t...
An Exception indicating that an Archetype name is not unique.
final TestArchetype floorArchetype
The archetype to create floor game objects.
A MapArchObject implementation for testing purposes.
TestMapModelHelper(@NotNull final InsertionMode topmostInsertionMode, @NotNull final GameObjectFactory< TestGameObject, TestMapArchObject, TestArchetype > gameObjectFactory, @NotNull final ArchetypeSet< TestGameObject, TestMapArchObject, TestArchetype > archetypeSet, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects)
Creates a new instance.
String TYPE
The attribute name of the object's type.
Base class for classes that contain GameObjects as children in the sense of containment.
final InsertionMode topmostInsertionMode
The "topmost" InsertionMode instance.
The class Size2D represents a 2d rectangular area.
TestGameObject insertArchetype(@NotNull final GameObjectContainer< TestGameObject, TestMapArchObject, TestArchetype > gameObject, @NotNull final BaseObject< TestGameObject, TestMapArchObject, TestArchetype, ?> archetype)
Inserts an archetype into a game object.
static void checkContents(@NotNull final Iterable< TestGameObject > mapSquare, @NotNull final BaseObject<?, ?, ?, ?>... gameObjects)
Checks that a MapSquare contains the given game objects.
TestGameObject insertArchetype(@NotNull final MapModel< TestGameObject, TestMapArchObject, TestArchetype > mapModel, @NotNull final Point point, @NotNull final BaseObject< TestGameObject, TestMapArchObject, TestArchetype, ?> archetype, final boolean join)
Inserts an archetype game object into a map model.
void setMultiX(int multiX)
Sets the x-position of this part of a multi-part object.