Gridarta Editor
AbstractBaseObjectTest.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.baseobject;
21 
22 import java.awt.Point;
38 import org.jetbrains.annotations.NotNull;
39 import org.jetbrains.annotations.Nullable;
40 import org.junit.Assert;
41 import org.junit.Test;
42 
47 public class AbstractBaseObjectTest {
48 
52  @NotNull
53  private final ResourceIcons resourceIcons = new ResourceIcons();
54 
58  @Test
59  public void testSetFaceName1() {
60  final AnimationObjects animationObjects = new TestAnimationObjects();
61  final FaceObjectProviders faceObjectProviders = newFaceObjectProviders();
62  final TestArchetype archetype = newArchetype("arch", null, faceObjectProviders, animationObjects);
63  Assert.assertNull(archetype.getFaceName());
64  archetype.setAttributeString("face", "arch_face");
65  Assert.assertEquals("arch_face", archetype.getFaceName());
66  final GameObject<TestGameObject, TestMapArchObject, TestArchetype> gameObject = newGameObject(archetype, "test", faceObjectProviders, animationObjects);
67 
68  // check that default face is archetype face
69  Assert.assertNull(gameObject.getFaceName());
70 
71  // reset face
72  gameObject.setObjectText("");
73  Assert.assertNull(gameObject.getFaceName());
74 
75  // set face by text change
76  gameObject.setAttributeString("face1", "face1");
77  Assert.assertNull(gameObject.getFaceName());
78  gameObject.setAttributeString("face", "face2");
79  Assert.assertEquals("face2", gameObject.getFaceName());
80  gameObject.setAttributeString("face2", "face3");
81  Assert.assertEquals("face2", gameObject.getFaceName());
82 
83  // reset object text ==> face reverts to archetype face
84  gameObject.setObjectText("");
85  Assert.assertNull(gameObject.getFaceName());
86 
87  // set face by text change
88  gameObject.setObjectText("abc 1\n" + "face face4\n" + "def 2\n");
89  Assert.assertEquals("face4", gameObject.getFaceName());
90 
91  // unset face by text change
92  gameObject.setObjectText("abc 1\n" + "def 2\n");
93  Assert.assertNull(gameObject.getFaceName());
94 
95  // set face to archetype face
96  gameObject.setObjectText("abc 1\n" + "face arch_face\n" + "def 2\n");
97  Assert.assertNull(gameObject.getFaceName());
98  }
99 
103  @Test
104  public void testSetFaceName2() {
105  final AnimationObjects animationObjects = new TestAnimationObjects();
106  final FaceObjectProviders faceObjectProviders = newFaceObjectProviders();
107  final TestArchetype archetype = newArchetype("arch", "face arch_face", faceObjectProviders, animationObjects);
108  final GameObject<TestGameObject, TestMapArchObject, TestArchetype> gameObject = newGameObject(archetype, "test", faceObjectProviders, animationObjects);
109 
110  Assert.assertNull(gameObject.getFaceName()); // default face
111  gameObject.setObjectText("face face1\n");
112  Assert.assertEquals("face1", gameObject.getFaceName());
113  gameObject.setObjectText("face face2\n");
114  Assert.assertEquals("face2", gameObject.getFaceName());
115  }
116 
121  @Test
122  public void testSetAttributeString() {
123  final AnimationObjects animationObjects = new TestAnimationObjects();
124  final FaceObjectProviders faceObjectProviders = newFaceObjectProviders();
125  final TestArchetype archetype = newArchetype("arch", "key1 value1\n" + "key2 value2\n", faceObjectProviders, animationObjects);
126 
127  final BaseObject<?, ?, ?, ?> gameObject = new TestGameObject(archetype, faceObjectProviders, animationObjects);
128 
129  Assert.assertEquals("value1", gameObject.getAttributeString("key1"));
130  Assert.assertEquals("value1", gameObject.getAttributeString("key1", true));
131  Assert.assertEquals("", gameObject.getAttributeString("key1", false));
132  Assert.assertEquals("value2", gameObject.getAttributeString("key2"));
133  Assert.assertEquals("value2", gameObject.getAttributeString("key2", true));
134  Assert.assertEquals("", gameObject.getAttributeString("key2", false));
135  Assert.assertEquals("", gameObject.getAttributeString("key3"));
136  Assert.assertEquals("", gameObject.getAttributeString("key3", true));
137  Assert.assertEquals("", gameObject.getAttributeString("key3", false));
138  Assert.assertEquals("", gameObject.getObjectText());
139 
140  gameObject.setAttributeString("key3", "value3");
141 
142  Assert.assertEquals("value1", gameObject.getAttributeString("key1"));
143  Assert.assertEquals("value1", gameObject.getAttributeString("key1", true));
144  Assert.assertEquals("", gameObject.getAttributeString("key1", false));
145  Assert.assertEquals("value2", gameObject.getAttributeString("key2"));
146  Assert.assertEquals("value2", gameObject.getAttributeString("key2", true));
147  Assert.assertEquals("", gameObject.getAttributeString("key2", false));
148  Assert.assertEquals("value3", gameObject.getAttributeString("key3"));
149  Assert.assertEquals("value3", gameObject.getAttributeString("key3", true));
150  Assert.assertEquals("value3", gameObject.getAttributeString("key3", false));
151  Assert.assertEquals("key3 value3\n", gameObject.getObjectText());
152 
153  gameObject.setAttributeString("key2", "VALUE2");
154 
155  Assert.assertEquals("value1", gameObject.getAttributeString("key1"));
156  Assert.assertEquals("value1", gameObject.getAttributeString("key1", true));
157  Assert.assertEquals("", gameObject.getAttributeString("key1", false));
158  Assert.assertEquals("VALUE2", gameObject.getAttributeString("key2"));
159  Assert.assertEquals("VALUE2", gameObject.getAttributeString("key2", true));
160  Assert.assertEquals("VALUE2", gameObject.getAttributeString("key2", false));
161  Assert.assertEquals("value3", gameObject.getAttributeString("key3"));
162  Assert.assertEquals("value3", gameObject.getAttributeString("key3", true));
163  Assert.assertEquals("value3", gameObject.getAttributeString("key3", false));
164  Assert.assertEquals("key3 value3\n" + "key2 VALUE2\n", gameObject.getObjectText());
165 
166  gameObject.setAttributeString("key3", "");
167 
168  Assert.assertEquals("value1", gameObject.getAttributeString("key1"));
169  Assert.assertEquals("value1", gameObject.getAttributeString("key1", true));
170  Assert.assertEquals("", gameObject.getAttributeString("key1", false));
171  Assert.assertEquals("VALUE2", gameObject.getAttributeString("key2"));
172  Assert.assertEquals("VALUE2", gameObject.getAttributeString("key2", true));
173  Assert.assertEquals("VALUE2", gameObject.getAttributeString("key2", false));
174  Assert.assertEquals("", gameObject.getAttributeString("key3"));
175  Assert.assertEquals("", gameObject.getAttributeString("key3", true));
176  Assert.assertEquals("", gameObject.getAttributeString("key3", false));
177  Assert.assertEquals("key2 VALUE2\n", gameObject.getObjectText());
178 
179  gameObject.setAttributeString("key2", "value2");
180 
181  Assert.assertEquals("value1", gameObject.getAttributeString("key1"));
182  Assert.assertEquals("value1", gameObject.getAttributeString("key1", true));
183  Assert.assertEquals("", gameObject.getAttributeString("key1", false));
184  Assert.assertEquals("value2", gameObject.getAttributeString("key2"));
185  Assert.assertEquals("value2", gameObject.getAttributeString("key2", true));
186  Assert.assertEquals("", gameObject.getAttributeString("key2", false));
187  Assert.assertEquals("", gameObject.getAttributeString("key3"));
188  Assert.assertEquals("", gameObject.getAttributeString("key3", true));
189  Assert.assertEquals("", gameObject.getAttributeString("key3", false));
190  Assert.assertEquals("", gameObject.getObjectText());
191  }
192 
196  @Test
197  public void testDirection1() {
198  final AnimationObjects animationObjects = new TestAnimationObjects();
199  final FaceObjectProviders faceObjectProviders = newFaceObjectProviders();
200  final TestArchetype archetype = newArchetype("arch", null, faceObjectProviders, animationObjects);
201  final GameObject<TestGameObject, TestMapArchObject, TestArchetype> gameObject = newGameObject(archetype, "test", faceObjectProviders, animationObjects);
202  checkDirection(gameObject, 0);
203  gameObject.setAttributeString("direction", "3");
204  checkDirection(gameObject, 3);
205  gameObject.removeAttribute("direction");
206  checkDirection(gameObject, 0);
207  gameObject.setObjectText("direction 3");
208  checkDirection(gameObject, 3);
209  }
210 
214  @Test
215  public void testDirection2() {
216  final AnimationObjects animationObjects = new TestAnimationObjects();
217  final FaceObjectProviders faceObjectProviders = newFaceObjectProviders();
218  final TestArchetype archetype = newArchetype("arch", "direction 2", faceObjectProviders, animationObjects);
219  final GameObject<TestGameObject, TestMapArchObject, TestArchetype> gameObject = newGameObject(archetype, "test", faceObjectProviders, animationObjects);
220  checkDirection(gameObject, 2);
221  gameObject.setAttributeString("direction", "3");
222  checkDirection(gameObject, 3);
223  gameObject.removeAttribute("direction");
224  checkDirection(gameObject, 2);
225  }
226 
230  @Test
231  public void testDirection3() {
232  final AnimationObjects animationObjects = new TestAnimationObjects();
233  final FaceObjectProviders faceObjectProviders = newFaceObjectProviders();
234  final TestArchetype archetype1 = newArchetype("arch", "direction 1", faceObjectProviders, animationObjects);
235  final TestArchetype archetype2 = newArchetype("arch", "direction 2", faceObjectProviders, animationObjects);
236  final GameObject<TestGameObject, TestMapArchObject, TestArchetype> gameObject = newGameObject(archetype1, "test", faceObjectProviders, animationObjects);
237  checkDirection(gameObject, 1);
238  gameObject.setArchetype(archetype2);
239  checkDirection(gameObject, 2);
240  gameObject.setAttributeString("direction", "4");
241  checkDirection(gameObject, 4);
242  gameObject.setArchetype(archetype1);
243  checkDirection(gameObject, 4);
244  gameObject.removeAttribute("direction");
245  checkDirection(gameObject, 1);
246  }
247 
254  private static void checkDirection(@NotNull final BaseObject<?, ?, ?, ?> gameObject, final int direction) {
255  Assert.assertEquals(direction, gameObject.getDirection());
256  Assert.assertEquals(direction, gameObject.getAttributeInt("direction"));
257  }
258 
262  @Test
263  public void testType1() {
264  final AnimationObjects animationObjects = new TestAnimationObjects();
265  final FaceObjectProviders faceObjectProviders = newFaceObjectProviders();
266  final TestArchetype archetype = newArchetype("arch", null, faceObjectProviders, animationObjects);
267  final GameObject<TestGameObject, TestMapArchObject, TestArchetype> gameObject = newGameObject(archetype, "test", faceObjectProviders, animationObjects);
268  checkType(gameObject, 0);
269  gameObject.setAttributeString("type", "3");
270  checkType(gameObject, 3);
271  gameObject.removeAttribute("type");
272  checkType(gameObject, 0);
273  gameObject.setObjectText("type 3");
274  checkType(gameObject, 3);
275  }
276 
280  @Test
281  public void testType2() {
282  final AnimationObjects animationObjects = new TestAnimationObjects();
283  final FaceObjectProviders faceObjectProviders = newFaceObjectProviders();
284  final TestArchetype archetype = newArchetype("arch", "type 2", faceObjectProviders, animationObjects);
285  final GameObject<TestGameObject, TestMapArchObject, TestArchetype> gameObject = newGameObject(archetype, "test", faceObjectProviders, animationObjects);
286  checkType(gameObject, 2);
287  gameObject.setAttributeString("type", "3");
288  checkType(gameObject, 3);
289  gameObject.removeAttribute("type");
290  checkType(gameObject, 2);
291  }
292 
296  @Test
297  public void testType3() {
298  final AnimationObjects animationObjects = new TestAnimationObjects();
299  final FaceObjectProviders faceObjectProviders = newFaceObjectProviders();
300  final TestArchetype archetype1 = newArchetype("arch", "type 1", faceObjectProviders, animationObjects);
301  final TestArchetype archetype2 = newArchetype("arch", "type 2", faceObjectProviders, animationObjects);
302  final GameObject<TestGameObject, TestMapArchObject, TestArchetype> gameObject = newGameObject(archetype1, "test", faceObjectProviders, animationObjects);
303  checkType(gameObject, 1);
304  gameObject.setArchetype(archetype2);
305  checkType(gameObject, 2);
306  gameObject.setAttributeString("type", "4");
307  checkType(gameObject, 4);
308  gameObject.setArchetype(archetype1);
309  checkType(gameObject, 4);
310  gameObject.removeAttribute("type");
311  checkType(gameObject, 1);
312  }
313 
320  private static void checkType(@NotNull final BaseObject<?, ?, ?, ?> gameObject, final int type) {
321  Assert.assertEquals(type, gameObject.getTypeNo());
322  Assert.assertEquals(type, gameObject.getAttributeInt(BaseObject.TYPE));
323  }
324 
328  @Test
329  public void testName1() {
330  final AnimationObjects animationObjects = new TestAnimationObjects();
331  final FaceObjectProviders faceObjectProviders = newFaceObjectProviders();
332  final TestArchetype archetype = newArchetype("arch", null, faceObjectProviders, animationObjects);
333  final BaseObject<?, ?, ?, ?> gameObject = new TestGameObject(archetype, faceObjectProviders, animationObjects);
334  checkName(gameObject, "arch", "");
335  gameObject.setAttributeString("name", "3");
336  checkName(gameObject, "3", "3");
337  gameObject.removeAttribute("name");
338  checkName(gameObject, "arch", "");
339  gameObject.setObjectText("name 3");
340  checkName(gameObject, "3", "3");
341  }
342 
346  @Test
347  public void testName2() {
348  final AnimationObjects animationObjects = new TestAnimationObjects();
349  final FaceObjectProviders faceObjectProviders = newFaceObjectProviders();
350  final TestArchetype archetype = newArchetype("arch", "name 2", faceObjectProviders, animationObjects);
351  final BaseObject<?, ?, ?, ?> gameObject = new TestGameObject(archetype, faceObjectProviders, animationObjects);
352  checkName(gameObject, "2", "2");
353  gameObject.setAttributeString("name", "3");
354  checkName(gameObject, "3", "3");
355  gameObject.removeAttribute("name");
356  checkName(gameObject, "2", "2");
357  }
358 
362  @Test
363  public void testName3() {
364  final AnimationObjects animationObjects = new TestAnimationObjects();
365  final FaceObjectProviders faceObjectProviders = newFaceObjectProviders();
366  final TestArchetype archetype1 = newArchetype("arch", "name 1", faceObjectProviders, animationObjects);
367  final TestArchetype archetype2 = newArchetype("arch", "name 2", faceObjectProviders, animationObjects);
368  final GameObject<TestGameObject, TestMapArchObject, TestArchetype> gameObject = new TestGameObject(archetype1, faceObjectProviders, animationObjects);
369  checkName(gameObject, "1", "1");
370  gameObject.setArchetype(archetype2);
371  checkName(gameObject, "2", "2");
372  gameObject.setAttributeString("name", "4");
373  checkName(gameObject, "4", "4");
374  gameObject.setArchetype(archetype1);
375  checkName(gameObject, "4", "4");
376  gameObject.removeAttribute("name");
377  checkName(gameObject, "1", "1");
378  }
379 
384  @Test
385  public void testSetAttributeInt1() {
386  final AnimationObjects animationObjects = new TestAnimationObjects();
387  final FaceObjectProviders faceObjectProviders = newFaceObjectProviders();
388  final TestArchetype archetype1 = newArchetype("arch", "a 1\nb 0\nc 2", faceObjectProviders, animationObjects);
389  final BaseObject<?, ?, ?, ?> gameObject = new TestGameObject(archetype1, faceObjectProviders, animationObjects);
390  Assert.assertEquals("", gameObject.getAttributeString("a", false));
391  Assert.assertEquals("", gameObject.getAttributeString("b", false));
392  Assert.assertEquals("", gameObject.getAttributeString("c", false));
393  Assert.assertEquals("", gameObject.getAttributeString("d", false));
394 
395  gameObject.setAttributeInt("a", 1);
396  gameObject.setAttributeInt("b", 0);
397  gameObject.setAttributeInt("c", 2);
398  gameObject.setAttributeInt("d", 0);
399  Assert.assertEquals("", gameObject.getAttributeString("a", false));
400  Assert.assertEquals("", gameObject.getAttributeString("b", false));
401  Assert.assertEquals("", gameObject.getAttributeString("c", false));
402  Assert.assertEquals("", gameObject.getAttributeString("d", false));
403 
404  gameObject.setAttributeInt("a", 0);
405  gameObject.setAttributeInt("b", 1);
406  gameObject.setAttributeInt("c", 0);
407  gameObject.setAttributeInt("d", 2);
408  Assert.assertEquals("0", gameObject.getAttributeString("a", false));
409  Assert.assertEquals("1", gameObject.getAttributeString("b", false));
410  Assert.assertEquals("0", gameObject.getAttributeString("c", false));
411  Assert.assertEquals("2", gameObject.getAttributeString("d", false));
412 
413  gameObject.setAttributeInt("a", 1);
414  gameObject.setAttributeInt("b", 0);
415  gameObject.setAttributeInt("c", 2);
416  gameObject.setAttributeInt("d", 0);
417  Assert.assertEquals("", gameObject.getAttributeString("a", false));
418  Assert.assertEquals("", gameObject.getAttributeString("b", false));
419  Assert.assertEquals("", gameObject.getAttributeString("c", false));
420  Assert.assertEquals("", gameObject.getAttributeString("d", false));
421  }
422 
427  @Test
428  public void testToString1() {
429  final AnimationObjects animationObjects = new TestAnimationObjects();
430  final FaceObjectProviders faceObjectProviders = newFaceObjectProviders();
431  final TestArchetype archetype1 = newArchetype("arch", "level 10", faceObjectProviders, animationObjects);
432  final BaseObject<?, ?, ?, ?> gameObject = new TestGameObject(archetype1, faceObjectProviders, animationObjects);
433  gameObject.setAttributeString("name", "Name");
434  gameObject.setAttributeString("title", "Title");
435 
436  Assert.assertEquals("format", gameObject.toString("format"));
437  Assert.assertEquals("Name TitleNameName TitleTitle", gameObject.toString("${NAME}${name}${NAME}${title}${other}"));
438  Assert.assertEquals("", gameObject.toString("${other:abc}"));
439  Assert.assertEquals("abc", gameObject.toString("${name:abc}"));
440  Assert.assertEquals("abc", gameObject.toString("${level:abc}"));
441  Assert.assertEquals("test", gameObject.toString("te${other: 1${other}2 }st"));
442  Assert.assertEquals("te 1Name2 st", gameObject.toString("te${name: 1${name}2 }st"));
443  Assert.assertEquals("te 1102 st", gameObject.toString("te${level: 1${level}2 }st"));
444  }
445 
450  @Test
452  final InsertionMode topmostInsertionMode = new TopmostInsertionMode();
453  final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false);
454  final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapModelCreator.newMapModel(1, 1);
455  mapModel.beginTransaction("test");
456  try {
457  mapModelCreator.addGameObjectToMap(mapModel, "floor", "1", 0, 0, topmostInsertionMode);
458  } finally {
459  mapModel.endTransaction();
460  }
461  final TestGameObject gameObject = mapModel.getMapSquare(new Point(0, 0)).iterator().next();
462 
463  mapModel.resetModified();
464  mapModel.beginTransaction("test");
465  try {
466  gameObject.setObjectText("a 1\nb 2\n");
467  } finally {
468  mapModel.endTransaction();
469  }
470  Assert.assertTrue(mapModel.isModified());
471 
472  mapModel.resetModified();
473  mapModel.beginTransaction("test");
474  try {
475  gameObject.setObjectText("b 2\na 1\n");
476  } finally {
477  mapModel.endTransaction();
478  }
479  Assert.assertFalse(mapModel.isModified());
480  }
481 
489  private static void checkName(@NotNull final BaseObject<?, ?, ?, ?> gameObject, @NotNull final String name, @NotNull final String nameAttribute) {
490  Assert.assertEquals(name, gameObject.getObjName());
491  Assert.assertEquals(nameAttribute, gameObject.getAttributeString(BaseObject.NAME));
492  }
493 
503  @NotNull
504  private static TestArchetype newArchetype(@NotNull final String archetypeName, @Nullable final String objectText, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects) {
505  final TestArchetype archetype = new TestDefaultArchetype(archetypeName, faceObjectProviders, animationObjects);
506  if (objectText != null) {
507  archetype.setObjectText(objectText);
508  }
509  return archetype;
510  }
511 
521  @NotNull
522  private static GameObject<TestGameObject, TestMapArchObject, TestArchetype> newGameObject(@NotNull final TestArchetype archetype, @NotNull final String name, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects) {
523  final GameObject<TestGameObject, TestMapArchObject, TestArchetype> gameObject = new TestGameObject(archetype, faceObjectProviders, animationObjects);
524  gameObject.setAttributeString(BaseObject.NAME, name);
525  return gameObject;
526  }
527 
533  final FaceObjects faceObjects = new TestFaceObjects();
534  assert resourceIcons != null;
535  return new FaceObjectProviders(0, faceObjects, resourceIcons);
536  }
537 
538 }
net.sf.gridarta.model.archetype.TestArchetype
An Archetype implementation for testing purposes.
Definition: TestArchetype.java:30
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.archetype.TestDefaultArchetype
An Archetype implementation for testing purposes.
Definition: TestDefaultArchetype.java:32
net.sf.gridarta.model.baseobject.AbstractBaseObjectTest.testDirection2
void testDirection2()
Checks that caching the "direction" attribute does work.
Definition: AbstractBaseObjectTest.java:215
net.sf.gridarta.model.baseobject.AbstractBaseObjectTest
Regression tests for AbstractBaseObject.
Definition: AbstractBaseObjectTest.java:47
net.sf.gridarta.model.baseobject.AbstractBaseObjectTest.newGameObject
static GameObject< TestGameObject, TestMapArchObject, TestArchetype > newGameObject(@NotNull final TestArchetype archetype, @NotNull final String name, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects)
Creates a new game object instance.
Definition: AbstractBaseObjectTest.java:522
net.sf.gridarta.model.mapmodel.MapModel.resetModified
void resetModified()
Resets the modified flag to false.
net.sf.gridarta
Base package of all Gridarta classes.
net.sf.gridarta.model.mapmodel.MapModel.endTransaction
void endTransaction()
End a transaction.
net.sf.gridarta.model.anim.AnimationObjects
AnimationObjects is a container for AnimationObjects.
Definition: AnimationObjects.java:30
net.sf.gridarta.model.baseobject.AbstractBaseObjectTest.testType1
void testType1()
Checks that caching the "type" attribute does work.
Definition: AbstractBaseObjectTest.java:263
net.sf.gridarta.model.gameobject.TestGameObject
A GameObject implementation for testing purposes.
Definition: TestGameObject.java:34
net.sf.gridarta.model.baseobject.BaseObject.getObjectText
String getObjectText()
Returns the object text of this GameObject as String.
net.sf
net.sf.gridarta.model.mapmodel.MapModel.beginTransaction
void beginTransaction(@NotNull String name)
Starts a new transaction.
net.sf.gridarta.model.mapmodel
Definition: AboveFloorInsertionMode.java:20
net.sf.gridarta.model.mapmodel.TestMapModelCreator
Helper class for regression tests to create MapModel instances.
Definition: TestMapModelCreator.java:63
net.sf.gridarta.model.baseobject.AbstractBaseObjectTest.checkName
static void checkName(@NotNull final BaseObject<?, ?, ?, ?> gameObject, @NotNull final String name, @NotNull final String nameAttribute)
Checks that the BaseObject#NAME attribute of a {} contains the expected value.
Definition: AbstractBaseObjectTest.java:489
net.sf.gridarta.model.baseobject.AbstractBaseObjectTest.newFaceObjectProviders
FaceObjectProviders newFaceObjectProviders()
Creates a new FaceObjectProviders instance.
Definition: AbstractBaseObjectTest.java:532
net.sf.gridarta.model.archetype
Definition: AbstractArchetype.java:20
net.sf.gridarta.model.face.FaceObjectProviders
Provider for faces of GameObjects and Archetypes.
Definition: FaceObjectProviders.java:46
net.sf.gridarta.model.gameobject.GameObject
Reflects a game object (object on a map).
Definition: GameObject.java:36
net.sf.gridarta.model.baseobject.AbstractBaseObjectTest.newArchetype
static TestArchetype newArchetype(@NotNull final String archetypeName, @Nullable final String objectText, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects)
Creates a new TestArchetype instance.
Definition: AbstractBaseObjectTest.java:504
net.sf.gridarta.model.baseobject.BaseObject.NAME
String NAME
The attribute name of the object's name.
Definition: BaseObject.java:60
net.sf.gridarta.model.anim.TestAnimationObjects
An AnimationObjects for regression tests.
Definition: TestAnimationObjects.java:26
net.sf.gridarta.model.mapmodel.MapModel.isModified
boolean isModified()
Return whether the map has been modified from the on-disk state.
net.sf.gridarta.model.baseobject.AbstractBaseObjectTest.testType2
void testType2()
Checks that caching the "type" attribute does work.
Definition: AbstractBaseObjectTest.java:281
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.TestMapModelCreator.newMapModel
MapModel< TestGameObject, TestMapArchObject, TestArchetype > newMapModel(final int w, final int h)
Creates a new MapModel instance.
Definition: TestMapModelCreator.java:168
net.sf.gridarta.model.baseobject.AbstractBaseObjectTest.testSetFaceName1
void testSetFaceName1()
Checks that setting the face name does work.
Definition: AbstractBaseObjectTest.java:59
net.sf.gridarta.model.baseobject.AbstractBaseObjectTest.testType3
void testType3()
Checks that caching the "type" attribute does work.
Definition: AbstractBaseObjectTest.java:297
net.sf.gridarta.model.face.FaceObjects
FaceObjects is a container for FaceObjects.
Definition: FaceObjects.java:31
net.sf.gridarta.model.baseobject.AbstractBaseObjectTest.checkDirection
static void checkDirection(@NotNull final BaseObject<?, ?, ?, ?> gameObject, final int direction)
Checks that the "direction" attribute of a GameObject contains the expected value.
Definition: AbstractBaseObjectTest.java:254
net.sf.gridarta.model.baseobject.AbstractBaseObjectTest.testSetAttributeInt1
void testSetAttributeInt1()
Checks that AbstractBaseObject#setAttributeInt(String, int) works as expected.
Definition: AbstractBaseObjectTest.java:385
net.sf.gridarta.model.mapmodel.InsertionMode
Insertion modes.
Definition: InsertionMode.java:33
net.sf.gridarta.model.baseobject.BaseObject.toString
String toString(@NotNull String format)
Returns a string representation of this game object.
net.sf.gridarta.model.baseobject.BaseObject<?, ?, ?, ?>
net.sf.gridarta.model.baseobject.Attributes.removeAttribute
void removeAttribute(@NotNull String attributeName)
Removes the String of an archetype attribute from the objectText.
net.sf.gridarta.model.baseobject.AbstractBaseObjectTest.testSetFaceName2
void testSetFaceName2()
Checks that a custom face may be changed.
Definition: AbstractBaseObjectTest.java:104
net.sf.gridarta.model.baseobject.BaseObject.setAttributeString
void setAttributeString(@NotNull String attributeName, @NotNull String value)
Sets the String of an archetype attribute in the objectText.
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.baseobject.BaseObject.getFaceName
String getFaceName()
Returns the name of the face of this Archetype or GameObject.
net.sf.gridarta.model
net.sf.gridarta.model.baseobject.AbstractBaseObjectTest.testName2
void testName2()
Checks that caching the "name" attribute does work.
Definition: AbstractBaseObjectTest.java:347
net.sf.gridarta.model.baseobject.AbstractBaseObjectTest.testToString1
void testToString1()
Checks that AbstractBaseObject#toString(String) works as expected.
Definition: AbstractBaseObjectTest.java:428
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.face
The face is the appearance of an object.
Definition: AbstractFaceObjects.java:20
net.sf.gridarta.model.baseobject.AbstractBaseObjectTest.testName1
void testName1()
Checks that caching the "name" attribute does work.
Definition: AbstractBaseObjectTest.java:329
net.sf.gridarta.model.anim
Gridarta can handle frame information of animations and allow the selection of an animation using a t...
Definition: AbstractAnimationObjects.java:20
net.sf.gridarta.model.baseobject.AbstractBaseObjectTest.resourceIcons
final ResourceIcons resourceIcons
The ResourceIcons instance.
Definition: AbstractBaseObjectTest.java:53
net.sf.gridarta.model.baseobject.AbstractBaseObjectTest.testDirection3
void testDirection3()
Checks that caching the "direction" attribute does work.
Definition: AbstractBaseObjectTest.java:231
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.utils.ResourceIcons
Creates ImageIcon instances from resources.
Definition: ResourceIcons.java:46
net.sf.gridarta.model.baseobject.AbstractBaseObjectTest.testSetAttributeString
void testSetAttributeString()
Checks that GameObject#setAttributeString(String, String) does work.
Definition: AbstractBaseObjectTest.java:122
net.sf.gridarta.model.baseobject.BaseObject.getAttributeString
String getAttributeString(@NotNull String attributeName, boolean queryArchetype)
Returns the requested attribute value of this GameObject as {}.
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.AbstractBaseObjectTest.testSetObjectTextAttributeOrdering
void testSetObjectTextAttributeOrdering()
Checks that BaseObject#setObjectText(String) ignores attribute ordering.
Definition: AbstractBaseObjectTest.java:451
net.sf.gridarta.model.baseobject.BaseObject.setObjectText
void setObjectText(@NotNull String objectText)
Sets.
net.sf.gridarta.model.mapmodel.TopmostInsertionMode
Insert topmost.
Definition: TopmostInsertionMode.java:31
net.sf.gridarta.model.baseobject.AbstractBaseObjectTest.testDirection1
void testDirection1()
Checks that caching the "direction" attribute does work.
Definition: AbstractBaseObjectTest.java:197
net.sf.gridarta.utils
Definition: ActionBuilderUtils.java:20
net.sf.gridarta.model.baseobject.AbstractBaseObjectTest.testName3
void testName3()
Checks that caching the "name" attribute does work.
Definition: AbstractBaseObjectTest.java:363
net.sf.gridarta.model.baseobject.AbstractBaseObjectTest.checkType
static void checkType(@NotNull final BaseObject<?, ?, ?, ?> gameObject, final int type)
Checks that the BaseObject#TYPE attribute of a GameObject contains the expected value.
Definition: AbstractBaseObjectTest.java:320
net.sf.gridarta.model.gameobject.GameObject.setArchetype
void setArchetype(@NotNull R archetype)
Set the Archetype of this GameObject.
net.sf.gridarta.model.face.TestFaceObjects
A FaceObjects for regression tests.
Definition: TestFaceObjects.java:30