Gridarta Editor
DefaultMapModelTest.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2023 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.model.mapmodel;
21 
22 import java.awt.Point;
23 import java.util.Collection;
24 import java.util.List;
25 import java.util.Set;
26 import java.util.TreeSet;
37 import net.sf.gridarta.utils.Size2D;
38 import org.jetbrains.annotations.NotNull;
39 import org.jetbrains.annotations.Nullable;
40 import org.junit.Assert;
41 import org.junit.Test;
42 
47 @SuppressWarnings("FeatureEnvy")
48 // This is a test. It has feature envy by definition.
49 public class DefaultMapModelTest {
50 
55  @NotNull
57 
58  @Override
59  public void mapSizeChanged(@NotNull final Size2D newSize) {
60  log("mapSizeChanged", null, null);
61  }
62 
63  @Override
64  public void mapSquaresChanged(@NotNull final Set<MapSquare<TestGameObject, TestMapArchObject, TestArchetype>> mapSquares) {
65  log("mapSquaresChanged", mapSquares, null);
66  }
67 
68  @Override
69  public void mapObjectsChanged(@NotNull final Set<TestGameObject> gameObjects, @NotNull final Set<TestGameObject> transientGameObjects) {
70  if (!gameObjects.isEmpty()) {
71  log("mapObjectsChanged", null, gameObjects);
72  }
73  if (!transientGameObjects.isEmpty()) {
74  log("mapObjectsTransientChanged", null, transientGameObjects);
75  }
76  }
77 
78  @Override
79  public void errorsChanged(@NotNull final ErrorCollector<TestGameObject, TestMapArchObject, TestArchetype> errors) {
80  result.append("errorsChanged");
81  }
82 
83  @Override
84  public void mapFileChanged(@Nullable final MapFile oldMapFile) {
85  // ignore
86  }
87 
88  @Override
89  public void modifiedChanged() {
90  // ignore
91  }
92 
93  };
94 
99  @NotNull
100  private final MapArchObjectListener mapArchObjectListener = new MapArchObjectListener() {
101 
102  @Override
103  public void mapMetaChanged() {
104  result.append("mapMetaChanged");
105  }
106 
107  @Override
108  public void mapSizeChanged(@NotNull final Size2D mapSize) {
109  // ignore
110  }
111 
112  };
113 
117  @NotNull
118  private final StringBuilder result = new StringBuilder();
119 
123  @Test
124  public void testEmpty() {
125  final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false);
126  final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator);
127 
128  mapModel.beginTransaction("TEST");
129  mapModel.endTransaction();
130  Assert.assertEquals("", result.toString());
131  }
132 
136  @Test
137  public void testResizeMap1() {
138  final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false);
139  final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator);
140 
141  mapModel.beginTransaction("TEST");
142  mapModel.getMapArchObject().setMapSize(new Size2D(4, 3));
143  mapModel.endTransaction();
144  final StringBuilder expectedResult = new StringBuilder();
145  expectedResult.append("mapSizeChanged:\n");
146  expectedResult.append("no squares\n");
147  expectedResult.append("no game objects\n");
148  Assert.assertEquals(expectedResult.toString(), result.toString());
149  }
150 
154  @Test
155  public void testResizeMap2() {
156  final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false);
157  final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator);
158 
159  mapModel.beginTransaction("TEST");
160  mapModel.getMapArchObject().setMapSize(new Size2D(4, 3));
161  mapModel.endTransaction();
162 
163  result.setLength(0);
164  mapModel.beginTransaction("TEST");
165  mapModel.getMapArchObject().setMapSize(new Size2D(4, 3));
166  mapModel.endTransaction();
167  Assert.assertEquals("", result.toString());
168  }
169 
173  @Test
174  public void testResizeMap3() {
175  final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false);
176  final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator);
177 
178  mapModel.beginTransaction("TEST");
179  mapModel.getMapArchObject().setMapSize(new Size2D(4, 3));
180  mapModelCreator.addGameObjectToMap(mapModel, "arch", "1", 1, 2, mapModelCreator.getInsertionModeSet().getAutoInsertionMode());
181  mapModel.endTransaction();
182 
183  result.setLength(0);
184  mapModel.beginTransaction("TEST");
185  mapModelCreator.addGameObjectToMap(mapModel, "arch", "1", 2, 2, mapModelCreator.getInsertionModeSet().getAutoInsertionMode());
186  mapModel.getMapArchObject().setMapSize(new Size2D(1, 2)); // cancels square changed event
187  mapModel.endTransaction();
188  final StringBuilder expectedResult = new StringBuilder();
189  expectedResult.append("mapSizeChanged:\n");
190  expectedResult.append("no squares\n");
191  expectedResult.append("no game objects\n");
192  Assert.assertEquals(expectedResult.toString(), result.toString());
193  }
194 
198  @Test
199  public void testResizeMap4() {
200  final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false);
201  final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator);
202 
203  mapModel.beginTransaction("TEST");
204  mapModel.getMapArchObject().setMapSize(new Size2D(4, 3));
205  mapModelCreator.addGameObjectToMap(mapModel, "arch", "1", 1, 2, mapModelCreator.getInsertionModeSet().getAutoInsertionMode());
206  mapModel.endTransaction();
207 
208  result.setLength(0);
209  mapModel.beginTransaction("TEST");
210  for (final BaseObject<TestGameObject, TestMapArchObject, TestArchetype, ?> gameObject : mapModel.getMapSquare(new Point(1, 2))) {
211  gameObject.setAttributeString("key", "value");
212  }
213  mapModelCreator.addGameObjectToMap(mapModel, "arch", "1", 2, 2, mapModelCreator.getInsertionModeSet().getAutoInsertionMode());
214  mapModel.getMapArchObject().setMapSize(new Size2D(1, 2)); // cancels square changed event
215  mapModel.endTransaction();
216  final StringBuilder expectedResult = new StringBuilder();
217  expectedResult.append("mapSizeChanged:\n");
218  expectedResult.append("no squares\n");
219  expectedResult.append("no game objects\n");
220  Assert.assertEquals(expectedResult.toString(), result.toString());
221  }
222 
227  @Test
228  public void testAddGameObjectToMap1() {
229  final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false);
230  final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator);
231 
232  mapModel.beginTransaction("TEST");
233  mapModel.getMapArchObject().setMapSize(new Size2D(4, 3));
234  mapModel.endTransaction();
235 
236  result.setLength(0);
237  mapModel.beginTransaction("TEST");
238  mapModelCreator.addGameObjectToMap(mapModel, "arch", "1", 1, 2, mapModelCreator.getInsertionModeSet().getAutoInsertionMode());
239  mapModel.endTransaction();
240  final StringBuilder expectedResult = new StringBuilder();
241  expectedResult.append("mapObjectsChanged:\n");
242  expectedResult.append("no squares\n");
243  expectedResult.append("game object 1 2 1\n");
244  expectedResult.append("mapSquaresChanged:\n");
245  expectedResult.append("square 1 2\n");
246  expectedResult.append("no game objects\n");
247  Assert.assertEquals(expectedResult.toString(), result.toString());
248  }
249 
254  @Test
255  public void testAddGameObjectToMap2() {
256  final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false);
257  final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator);
258 
259  mapModel.beginTransaction("TEST");
260  mapModel.getMapArchObject().setMapSize(new Size2D(4, 3));
261  mapModel.endTransaction();
262 
263  result.setLength(0);
264  mapModel.beginTransaction("TEST");
265  mapModelCreator.addGameObjectToMap(mapModel, "arch", "1", 1, 2, mapModelCreator.getInsertionModeSet().getAutoInsertionMode());
266  mapModelCreator.addGameObjectToMap(mapModel, "arch", "1", 1, 2, mapModelCreator.getInsertionModeSet().getAutoInsertionMode());
267  mapModelCreator.addGameObjectToMap(mapModel, "arch", "1", 2, 2, mapModelCreator.getInsertionModeSet().getAutoInsertionMode());
268  mapModel.endTransaction();
269  final StringBuilder expectedResult = new StringBuilder();
270  expectedResult.append("mapObjectsChanged:\n");
271  expectedResult.append("no squares\n");
272  expectedResult.append("game object 1 2 1\n");
273  expectedResult.append("game object 2 2 1\n");
274  expectedResult.append("mapSquaresChanged:\n");
275  expectedResult.append("square 1 2\n");
276  expectedResult.append("square 2 2\n");
277  expectedResult.append("no game objects\n");
278  Assert.assertEquals(expectedResult.toString(), result.toString());
279  }
280 
284  @Test
285  public void testModifiedGameObject1() {
286  final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false);
287  final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator);
288 
289  mapModel.beginTransaction("TEST");
290  mapModel.getMapArchObject().setMapSize(new Size2D(4, 3));
291  mapModelCreator.addGameObjectToMap(mapModel, "arch", "1", 1, 2, mapModelCreator.getInsertionModeSet().getAutoInsertionMode());
292  mapModel.endTransaction();
293 
294  result.setLength(0);
295  mapModel.beginTransaction("TEST");
296  for (final GameObject<TestGameObject, TestMapArchObject, TestArchetype> gameObject : mapModel.getMapSquare(new Point(1, 2))) {
297  mapModelCreator.insertGameObject(gameObject, "arch", "2");
298  }
299  mapModel.endTransaction();
300  final StringBuilder expectedResult = new StringBuilder();
301  expectedResult.append("mapObjectsChanged:\n");
302  expectedResult.append("no squares\n");
303  expectedResult.append("game object 0 0 2\n");
304  expectedResult.append("game object 1 2 1\n");
305  Assert.assertEquals(expectedResult.toString(), result.toString());
306  }
307 
311  @Test
312  public void testModifiedGameObject2() {
313  final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false);
314  final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator);
315 
316  mapModel.beginTransaction("TEST");
317  mapModel.getMapArchObject().setMapSize(new Size2D(4, 3));
318  mapModelCreator.addGameObjectToMap(mapModel, "arch", "1", 1, 2, mapModelCreator.getInsertionModeSet().getAutoInsertionMode());
319  mapModel.endTransaction();
320 
321  result.setLength(0);
322  mapModel.beginTransaction("TEST");
323  for (final BaseObject<TestGameObject, TestMapArchObject, TestArchetype, ?> gameObject : mapModel.getMapSquare(new Point(1, 2))) {
324  gameObject.setAttributeString("key", "value");
325  }
326  mapModel.endTransaction();
327  final StringBuilder expectedResult = new StringBuilder();
328  expectedResult.append("mapObjectsChanged:\n");
329  expectedResult.append("no squares\n");
330  expectedResult.append("game object 1 2 1\n");
331  Assert.assertEquals(expectedResult.toString(), result.toString());
332  }
333 
338  @Test
339  public void testGetAllGameObjects1() {
340  final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false);
341  final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator);
343  final TestArchetype archetype2 = mapModelCreator.getArchetype("arch2");
344  archetype2.setMultiY(1);
345  archetype.addTailPart(archetype2);
346 
347  mapModel.beginTransaction("TEST");
348  mapModel.getMapArchObject().setMapSize(new Size2D(1, 2));
349  final TestGameObject gameObject = mapModel.insertBaseObject(archetype, new Point(0, 0), true, false, mapModelCreator.getInsertionModeSet().getAutoInsertionMode());
350  mapModel.endTransaction();
351 
352  final List<TestGameObject> gameObjects = mapModel.getAllGameObjects();
353  Assert.assertEquals(1, gameObjects.size());
354  Assert.assertEquals(gameObject, gameObjects.get(0));
355  }
356 
362  @Test
364  final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false);
365  mapModelCreator.getArchetypeChooserModel().setDirection(2);
366  final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator);
367  final BaseObject<TestGameObject, TestMapArchObject, TestArchetype, TestArchetype> archetypeWithoutDirection = mapModelCreator.getArchetype("arch_without");
368  final TestArchetype archetypeWithDirection = mapModelCreator.getArchetype("arch_with");
369  archetypeWithDirection.setUsesDirection(true);
370 
371  mapModel.beginTransaction("TEST");
372  mapModel.getMapArchObject().setMapSize(new Size2D(1, 1));
373  final TestGameObject gameObjectWithout = mapModel.insertBaseObject(archetypeWithoutDirection, new Point(0, 0), true, false, mapModelCreator.getInsertionModeSet().getAutoInsertionMode());
374  final TestGameObject gameObjectWith = mapModel.insertBaseObject(archetypeWithDirection, new Point(0, 0), true, false, mapModelCreator.getInsertionModeSet().getAutoInsertionMode());
375  mapModel.endTransaction();
376 
377  Assert.assertNotNull(gameObjectWithout);
378  Assert.assertFalse(archetypeWithoutDirection.usesDirection());
379  Assert.assertEquals(0, gameObjectWithout.getAttributeInt(BaseObject.DIRECTION));
380  Assert.assertNotNull(gameObjectWith);
381  Assert.assertTrue(archetypeWithDirection.usesDirection());
382  Assert.assertEquals(2, gameObjectWith.getAttributeInt(BaseObject.DIRECTION));
383  }
384 
388  @Test
389  public void testEditType1() {
390  final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false);
391  final GameObjectMatchers gameObjectMatchers = mapModelCreator.getGameObjectMatchers();
392  gameObjectMatchers.addGameObjectMatcher(new NamedGameObjectMatcher(1, "m1", "1", true, null, new TypeNrsGameObjectMatcher(1)));
393  gameObjectMatchers.addGameObjectMatcher(new NamedGameObjectMatcher(2, "m2", "2", true, null, new TypeNrsGameObjectMatcher(2)));
394  gameObjectMatchers.addGameObjectMatcher(new NamedGameObjectMatcher(4, "e3", "3", true, new TypeNrsGameObjectMatcher(3), new TypeNrsGameObjectMatcher(4)));
395  final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator);
396  final TestArchetype a1 = mapModelCreator.getArchetype("a1");
397  a1.setAttributeInt(BaseObject.TYPE, 1);
398  final TestArchetype a4 = mapModelCreator.getArchetype("a4");
399  a4.setAttributeInt(BaseObject.TYPE, 4);
400 
401  mapModel.addActiveEditType(7);
402 
403  mapModel.beginTransaction("TEST");
404  final TestGameObject g1 = mapModel.insertBaseObject(a1, new Point(0, 0), true, false, mapModelCreator.getInsertionModeSet().getAutoInsertionMode());
405  mapModel.endTransaction();
406  Assert.assertNotNull(g1);
407  Assert.assertEquals(1, g1.getEditType());
408 
409  mapModel.beginTransaction("TEST");
410  g1.setAttributeInt(BaseObject.TYPE, 2);
411  mapModel.endTransaction();
412  Assert.assertEquals(2, g1.getEditType());
413 
414  mapModel.beginTransaction("TEST");
415  g1.setAttributeInt(BaseObject.TYPE, 3);
416  mapModel.endTransaction();
417  Assert.assertEquals(0, g1.getEditType());
418 
419  final TestGameObject g2 = a4.newInstance(mapModelCreator.getGameObjectFactory());
420  mapModel.beginTransaction("TEST");
421  g1.addLast(g2);
422  mapModel.endTransaction();
423  Assert.assertEquals(4, g1.getEditType());
424  Assert.assertEquals(0, g2.getEditType());
425 
426  final TestGameObject g3 = a4.newInstance(mapModelCreator.getGameObjectFactory());
427  mapModel.beginTransaction("TEST");
428  g2.addLast(g3);
429  mapModel.endTransaction();
430  Assert.assertEquals(4, g1.getEditType());
431  Assert.assertEquals(0, g2.getEditType());
432  Assert.assertEquals(0, g3.getEditType());
433 
434  mapModel.beginTransaction("TEST");
435  g2.setAttributeInt(BaseObject.TYPE, 2);
436  mapModel.endTransaction();
437  Assert.assertEquals(4, g1.getEditType());
438  Assert.assertEquals(2, g2.getEditType());
439  Assert.assertEquals(0, g3.getEditType());
440 
441  mapModel.beginTransaction("TEST");
442  g3.setAttributeInt(BaseObject.TYPE, 2);
443  mapModel.endTransaction();
444  Assert.assertEquals(0, g1.getEditType());
445  Assert.assertEquals(2, g2.getEditType());
446  Assert.assertEquals(2, g3.getEditType());
447 
448  mapModel.beginTransaction("TEST");
449  g3.setAttributeInt(BaseObject.TYPE, 4);
450  mapModel.endTransaction();
451  Assert.assertEquals(4, g1.getEditType());
452  Assert.assertEquals(2, g2.getEditType());
453  Assert.assertEquals(0, g3.getEditType());
454 
455  mapModel.beginTransaction("TEST");
456  g2.setAttributeInt(BaseObject.TYPE, 3);
457  mapModel.endTransaction();
458  Assert.assertEquals(4, g1.getEditType());
459  Assert.assertEquals(4, g2.getEditType());
460  Assert.assertEquals(0, g3.getEditType());
461 
462  mapModel.beginTransaction("TEST");
463  mapModel.removeGameObject(g3, false);
464  mapModel.endTransaction();
465  Assert.assertEquals(0, g1.getEditType());
466  Assert.assertEquals(0, g2.getEditType());
467 
468  mapModel.beginTransaction("TEST");
469  mapModel.removeGameObject(g2, false);
470  mapModel.endTransaction();
471  Assert.assertEquals(0, g1.getEditType());
472 
473  mapModel.beginTransaction("TEST");
474  mapModel.removeGameObject(g1, false);
475  mapModel.endTransaction();
476  }
477 
484  private void log(@NotNull final String name, @Nullable final Iterable<MapSquare<TestGameObject, TestMapArchObject, TestArchetype>> mapSquares, @Nullable final Iterable<TestGameObject> gameObjects) {
485  result.append(name);
486  result.append(":\n");
487  if (mapSquares == null) {
488  result.append("no squares\n");
489  } else {
490  final Collection<String> lines = new TreeSet<>();
491  for (final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare : mapSquares) {
492  lines.add("square " + mapSquare.getMapX() + " " + mapSquare.getMapY() + "\n");
493  }
494  for (final String line : lines) {
495  result.append(line);
496  }
497  }
498  if (gameObjects == null) {
499  result.append("no game objects\n");
500  } else {
501  final Collection<String> lines = new TreeSet<>();
502  for (final BaseObject<TestGameObject, TestMapArchObject, TestArchetype, ?> gameObject : gameObjects) {
503  lines.add("game object " + gameObject.getMapX() + " " + gameObject.getMapY() + " " + gameObject.getBestName() + "\n");
504  }
505  for (final String line : lines) {
506  result.append(line);
507  }
508  }
509  }
510 
516  @NotNull
518  final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapModelCreator.newMapModel(1, 1);
519 
520  result.setLength(0);
521  mapModel.addMapModelListener(mapModelListener);
522  mapModel.getMapArchObject().addMapArchObjectListener(mapArchObjectListener);
523  Assert.assertEquals("", result.toString());
524 
525  return mapModel;
526  }
527 
528 }
net.sf.gridarta.model.archetype.TestArchetype
An Archetype implementation for testing purposes.
Definition: TestArchetype.java:30
net.sf.gridarta.model.mapmodel.TestMapModelCreator.getInsertionModeSet
InsertionModeSet< TestGameObject, TestMapArchObject, TestArchetype > getInsertionModeSet()
Returns the InsertionModeSet instance.
Definition: TestMapModelCreator.java:230
name
name
Definition: ArchetypeTypeSetParserTest-ignoreDefaultAttribute1-result.txt:2
net.sf.gridarta.model.mapmodel.MapModel
A MapModel reflects the data of a map.
Definition: MapModel.java:75
net.sf.gridarta.model.mapmodel.MapModel.getMapArchObject
A getMapArchObject()
Returns the Map Arch Object with the meta information about the map.
net.sf.gridarta.model.mapmodel.DefaultMapModelTest.newMapModel
MapModel< TestGameObject, TestMapArchObject, TestArchetype > newMapModel(@NotNull final TestMapModelCreator mapModelCreator)
Creates a new MapModel instance.
Definition: DefaultMapModelTest.java:517
net.sf.gridarta.model.mapmodel.MapModel.insertBaseObject
G insertBaseObject(@NotNull BaseObject< G, A, R, ?> baseObject, @NotNull Point pos, boolean allowMany, boolean join, @NotNull InsertionMode insertionMode)
Inserts a BaseObject to a map.
net.sf.gridarta
Base package of all Gridarta classes.
net.sf.gridarta.model.mapmodel.DefaultMapModelTest.testEditType1
void testEditType1()
Checks that modifications correctly update edit types.
Definition: DefaultMapModelTest.java:389
net.sf.gridarta.model.mapmodel.MapSquare
A single Map Square.
Definition: MapSquare.java:45
net.sf.gridarta.model.mapmodel.MapModel.endTransaction
void endTransaction()
End a transaction.
net.sf.gridarta.model.gameobject.TestGameObject
A GameObject implementation for testing purposes.
Definition: TestGameObject.java:34
net.sf
net.sf.gridarta.model.mapmodel.MapModel.beginTransaction
void beginTransaction(@NotNull String name)
Starts a new transaction.
net.sf.gridarta.model.maparchobject.MapArchObjectListener
Interface for listeners listening on map arch object changes.
Definition: MapArchObjectListener.java:30
net.sf.gridarta.model.mapmodel.TestMapModelCreator.insertGameObject
void insertGameObject(@NotNull final GameObject< TestGameObject, TestMapArchObject, TestArchetype > gameObject, @NotNull final String archetypeName, @NotNull final String name)
Inserts a game object into the inventory of another game object.
Definition: TestMapModelCreator.java:220
net.sf.gridarta.model.mapmodel.TestMapModelCreator
Helper class for regression tests to create MapModel instances.
Definition: TestMapModelCreator.java:63
net.sf.gridarta.model.mapmodel.DefaultMapModelTest.testAddGameObjectToMap2
void testAddGameObjectToMap2()
Test case for Point, InsertionMode).
Definition: DefaultMapModelTest.java:255
net.sf.gridarta.model.archetype
Definition: AbstractArchetype.java:20
net.sf.gridarta.model.gameobject.GameObject
Reflects a game object (object on a map).
Definition: GameObject.java:36
net.sf.gridarta.model.mapmodel.MapModel.addMapModelListener
void addMapModelListener(@NotNull MapModelListener< G, A, R > listener)
Register a map listener.
net.sf.gridarta.model.archetype.Archetype.setMultiY
void setMultiY(int multiY)
Sets the y-position of this part of a multi-part object.
net.sf.gridarta.model.mapmodel.DefaultMapModelTest.testResizeMap4
void testResizeMap4()
Test case for net.sf.gridarta.model.maparchobject.MapArchObject#setMapSize(Size2D).
Definition: DefaultMapModelTest.java:199
net.sf.gridarta.model.match.GameObjectMatchers.addGameObjectMatcher
void addGameObjectMatcher(@NotNull final NamedGameObjectMatcher gameObjectMatcher)
Adds a new GameObjectMatcher.
Definition: GameObjectMatchers.java:112
net.sf.gridarta.model.baseobject.BaseObject.usesDirection
boolean usesDirection()
Return whether this base object uses the "direction" attribute.
net.sf.gridarta.model.match.NamedGameObjectMatcher
Decorates an arbitrary GameObjectMatcher with a localized name that is suitable for the user interfac...
Definition: NamedGameObjectMatcher.java:33
net.sf.gridarta.model.gameobject
GameObjects are the objects based on Archetypes found on maps.
Definition: AbstractGameObject.java:20
net
net.sf.gridarta.model.mapmodel.DefaultMapModelTest.testAddGameObjectToMap1
void testAddGameObjectToMap1()
Test case for Point, InsertionMode).
Definition: DefaultMapModelTest.java:228
net.sf.gridarta.model.match.TypeNrsGameObjectMatcher
An GameObjectMatcher matching certain archetype types.
Definition: TypeNrsGameObjectMatcher.java:30
net.sf.gridarta.model.mapmodel.TestMapModelCreator.getGameObjectFactory
GameObjectFactory< TestGameObject, TestMapArchObject, TestArchetype > getGameObjectFactory()
Returns the GameObjectFactory instance.
Definition: TestMapModelCreator.java:294
net.sf.gridarta.model.mapmodel.DefaultMapModelTest.testEmpty
void testEmpty()
Test case for an empty transaction.
Definition: DefaultMapModelTest.java:124
net.sf.gridarta.model.mapmodel.DefaultMapModelTest.log
void log(@NotNull final String name, @Nullable final Iterable< MapSquare< TestGameObject, TestMapArchObject, TestArchetype >> mapSquares, @Nullable final Iterable< TestGameObject > gameObjects)
Records a change event.
Definition: DefaultMapModelTest.java:484
errors
errors
Definition: ArchetypeTypeSetParserTest-ignoreDefaultAttribute1-result.txt:1
net.sf.gridarta.model.match
Classes related to matching {GameObjects}, so called { net.sf.gridarta.model.match....
Definition: AndGameObjectMatcher.java:20
net.sf.gridarta.model.match.GameObjectMatchers
Maintains GameObjectMatcher instances.
Definition: GameObjectMatchers.java:40
net.sf.gridarta.model.mapmodel.MapModel.removeGameObject
void removeGameObject(@NotNull G gameObject, boolean join)
Delete an existing GameObject from the map.
net.sf.gridarta.model.mapmodel.DefaultMapModelTest.testModifiedGameObject2
void testModifiedGameObject2()
Test case for changed objects.
Definition: DefaultMapModelTest.java:312
net.sf.gridarta.model.validation.ErrorCollector
An interface for classes that collect errors.
Definition: ErrorCollector.java:33
net.sf.gridarta.model.validation
This package contains the framework for validating maps.
Definition: AbstractValidator.java:20
net.sf.gridarta.model.mapmodel.TestMapModelCreator.getGameObjectMatchers
GameObjectMatchers getGameObjectMatchers()
Returns the GameObjectMatchers instance.
Definition: TestMapModelCreator.java:340
net.sf.gridarta.model.baseobject.BaseObject
Definition: BaseObject.java:34
net.sf.gridarta.model.mapmodel.MapFile
The location of a map file with a map directory.
Definition: MapFile.java:31
net.sf.gridarta.model.mapmodel.DefaultMapModelTest.testResizeMap2
void testResizeMap2()
Test case for net.sf.gridarta.model.maparchobject.MapArchObject#setMapSize(Size2D).
Definition: DefaultMapModelTest.java:155
net.sf.gridarta.model.mapmodel.TestMapModelCreator.getArchetypeChooserModel
ArchetypeChooserModel< TestGameObject, TestMapArchObject, TestArchetype > getArchetypeChooserModel()
Returns the ArchetypeChooserModel instance.
Definition: TestMapModelCreator.java:331
net.sf.gridarta.model.mapmodel.TestMapModelCreator.getArchetype
TestArchetype getArchetype(@NotNull final String archetypeName)
Returns an archetype.
Definition: TestMapModelCreator.java:249
net.sf.gridarta.model.mapmodel.MapModelListener
Interface for listeners listening on MapModel events.
Definition: MapModelListener.java:36
net.sf.gridarta.model.mapmodel.MapModel.getMapSquare
MapSquare< G, A, R > getMapSquare(@NotNull Point pos)
Get the square at a specified location.
net.sf.gridarta.model.mapmodel.MapModel.addActiveEditType
void addActiveEditType(int editType)
Add edit type to the bitmask of active types.
net.sf.gridarta.model
net.sf.gridarta.model.mapmodel.DefaultMapModelTest.testModifiedGameObject1
void testModifiedGameObject1()
Test case for changed objects.
Definition: DefaultMapModelTest.java:285
net.sf.gridarta.model.baseobject
Definition: AbstractBaseObject.java:20
net.sf.gridarta.model.mapmodel.DefaultMapModelTest.testResizeMap3
void testResizeMap3()
Test case for net.sf.gridarta.model.maparchobject.MapArchObject#setMapSize(Size2D).
Definition: DefaultMapModelTest.java:174
net.sf.gridarta.model.mapmodel.TestMapModelCreator.addGameObjectToMap
void addGameObjectToMap(@NotNull final MapModel< TestGameObject, TestMapArchObject, TestArchetype > mapModel, @NotNull final String archetypeName, @NotNull final String name, final int x, final int y, @NotNull final InsertionMode insertionMode)
Inserts a game object into a map.
Definition: TestMapModelCreator.java:209
net.sf.gridarta.model.maparchobject.TestMapArchObject
A MapArchObject implementation for testing purposes.
Definition: TestMapArchObject.java:28
net.sf.gridarta.model.maparchobject
Definition: AbstractMapArchObject.java:20
net.sf.gridarta.model.baseobject.BaseObject.TYPE
String TYPE
The attribute name of the object's type.
Definition: BaseObject.java:66
net.sf.gridarta.model.baseobject.BaseObject.addTailPart
void addTailPart(@NotNull T tail)
Appends a tail to this GameObject.
net.sf.gridarta.model.mapmodel.DefaultMapModelTest.testGetAllGameObjects1
void testGetAllGameObjects1()
Test case for DefaultMapModel#getAllGameObjects(): for a 1x2 game object only the head should be retu...
Definition: DefaultMapModelTest.java:339
net.sf.gridarta.model.mapmodel.DefaultMapModelTest.testUpdateDirectionOnInsert
void testUpdateDirectionOnInsert()
Test case for DefaultMapModel#getAllGameObjects(): the {} attribute is set only if the inserted objec...
Definition: DefaultMapModelTest.java:363
net.sf.gridarta.utils.Size2D
The class Size2D represents a 2d rectangular area.
Definition: Size2D.java:30
net.sf.gridarta.model.mapmodel.MapModel.getAllGameObjects
List< G > getAllGameObjects()
Returns all game objects.
net.sf.gridarta.utils
Definition: ActionBuilderUtils.java:20
net.sf.gridarta.model.mapmodel.DefaultMapModelTest
Test for DefaultMapModel.
Definition: DefaultMapModelTest.java:49
net.sf.gridarta.model.mapmodel.DefaultMapModelTest.testResizeMap1
void testResizeMap1()
Test case for net.sf.gridarta.model.maparchobject.MapArchObject#setMapSize(Size2D).
Definition: DefaultMapModelTest.java:137
net.sf.gridarta.model.baseobject.BaseObject.DIRECTION
String DIRECTION
The attribute name of the object's direction.
Definition: BaseObject.java:48
net.sf.gridarta.model.archetype.TestArchetype.setUsesDirection
void setUsesDirection(boolean usesDirection)
Sets the return value of usesDirection().