20 package net.sf.gridarta.model.artifact;
22 import java.io.IOException;
30 import org.junit.Assert;
31 import org.junit.Test;
50 final StringBuilder artifacts =
new StringBuilder();
51 artifacts.append(
"artifact art\n");
52 artifacts.append(
"def_arch base\n");
53 artifacts.append(
"Object obj\n");
54 artifacts.append(
"sp 3\n");
55 artifacts.append(
"end\n");
58 Assert.assertFalse(errorView.
hasErrors());
61 Assert.assertEquals(
"sp 3\nname base\n", archetype.
getObjectText());
75 final StringBuilder artifacts =
new StringBuilder();
76 artifacts.append(
"artifact horn_fools\n");
77 artifacts.append(
"def_arch horn\n");
78 artifacts.append(
"Object obj\n");
79 artifacts.append(
"title of fools\n");
80 artifacts.append(
"end\n");
82 Assert.assertEquals(
"horn of fools", parser.
getArchetype(
"horn_fools").getBestName());
96 final StringBuilder artifacts =
new StringBuilder();
97 artifacts.append(
"artifact horn_fools\n");
98 artifacts.append(
"def_arch horn\n");
99 artifacts.append(
"Object obj\n");
100 artifacts.append(
"title of fools\n");
101 artifacts.append(
"end\n");
103 Assert.assertEquals(
"horn2 of fools", parser.
getArchetype(
"horn_fools").getBestName());
117 final StringBuilder artifacts =
new StringBuilder();
118 artifacts.append(
"artifact horn_fools\n");
119 artifacts.append(
"def_arch horn\n");
120 artifacts.append(
"Object obj\n");
121 artifacts.append(
"title of fools\n");
122 artifacts.append(
"end\n");
124 Assert.assertEquals(
"base_horn of fools", parser.
getArchetype(
"horn_fools").getBestName());
138 final StringBuilder artifacts =
new StringBuilder();
139 artifacts.append(
"artifact horn_fools\n");
140 artifacts.append(
"def_arch horn\n");
141 artifacts.append(
"Object obj\n");
142 artifacts.append(
"name special_horn\n");
143 artifacts.append(
"title of fools\n");
144 artifacts.append(
"end\n");
146 Assert.assertEquals(
"special_horn of fools", parser.
getArchetype(
"horn_fools").getBestName());
159 parser.
addArchetype(
"note",
"face note.101",
"layer 3",
"identified 1",
"type 8",
"material 1",
"value 8",
"weight 75",
"level 1",
"exp 10");
160 final StringBuilder artifacts =
new StringBuilder();
161 artifacts.append(
"Allowed none\n");
162 artifacts.append(
"chance 1\n");
163 artifacts.append(
"artifact my_notebook_item\n");
164 artifacts.append(
"def_arch note\n");
165 artifacts.append(
"Object\n");
166 artifacts.append(
"name A notebook\n");
167 artifacts.append(
"msg\n");
168 artifacts.append(
"This should be giving a false positive for duplicate attributes.\n");
169 artifacts.append(
"endmsg\n");
170 artifacts.append(
"end\n");
172 Assert.assertEquals(
"A notebook", parser.
getArchetype(
"my_notebook_item").getBestName());
185 parser.
addArchetype(
"note",
"face note.101",
"name note",
"layer 3",
"identified 1",
"type 8",
"material 1",
"value 8",
"weight 75",
"level 1",
"exp 10");
186 final StringBuilder artifacts =
new StringBuilder();
187 artifacts.append(
"Allowed none\n");
188 artifacts.append(
"chance 1\n");
189 artifacts.append(
"artifact my_notebook_item\n");
190 artifacts.append(
"def_arch note\n");
191 artifacts.append(
"Object\n");
192 artifacts.append(
"name A notebook\n");
193 artifacts.append(
"msg\n");
194 artifacts.append(
"This should be giving a false positive for duplicate attributes.\n");
195 artifacts.append(
"endmsg\n");
196 artifacts.append(
"end\n");
198 Assert.assertEquals(
"A notebook", parser.
getArchetype(
"my_notebook_item").getBestName());
void testMissingObject()
Checks that a missing "object" line is detected.
int getArchetypeCount()
Returns the number of defined archetypes.
void parseArtifacts(@NotNull final String artifacts)
Parses artifacts definitions.
void testDefaultName2()
Checks that an artifact definition inherits the def_arch archetype's name by default.
void testDefaultName3()
Checks that an artifact definition inherits the def_arch archetype's name by default.
Regression tests for ArtifactParser.
void testDefaultName1()
Checks that an artifact definition inherits the def_arch archetype's name by default.
A MapArchObject implementation for testing purposes.
Base package of all Gridarta classes.
boolean hasErrors
Whether errors have been collected.
An Exception indicating that an Archetype name is not unique.
void addArchetype(@NotNull final String archetypeName, @NotNull final String... attributes)
Adds a new archetype.
GameObjects are the objects based on Archetypes found on maps.
void testDefaultName4()
Checks that an artifact definition inherits the def_arch archetype's name by default.
Archetype< TestGameObject, TestMapArchObject, TestArchetype > getArchetype(@NotNull final String archetypeName)
Returns an Archetype by name.
Exception thrown if an Archetype does not exist.
void testDefaultName5b()
Checks for spurious error messages when setting an artifact's name when the base archetype doesn't ha...
Parser for artifacts definitions.
An Archetype implementation for testing purposes.
String getObjectText()
Returns the object text of this GameObject as String.
A GameObject implementation for testing purposes.
boolean hasWarnings
Whether warnings have been collected.
An ErrorView suitable for unit tests.
void testDefaultName5a()
Checks for spurious error messages when setting an artifact's name when the base archetype doesn't ha...