Gridarta Editor
MapArchObjectParserTest.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.var.crossfire.model.io;
21 
22 import java.io.BufferedReader;
23 import java.io.IOException;
24 import java.io.StringReader;
25 import net.sf.gridarta.utils.Size2D;
27 import org.junit.Assert;
28 import org.junit.Test;
29 
34 
39  @SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
40  @Test
41  public void testLoadFirstLoad() throws IOException {
43  final BufferedReader reader = new BufferedReader(new StringReader("arch map\nfirst_load 1234\nend\n"));
44  final MapArchObject mapArchObject = new MapArchObject();
45  parser.load(reader, mapArchObject);
46  Assert.assertEquals(1234, mapArchObject.getFirstLoad());
47  }
48 
53  @SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
54  @Test
55  public void testLoadResetGroup1() throws IOException {
57  final BufferedReader reader = new BufferedReader(new StringReader("arch map\nreset_group xyz\nend\n"));
58  final MapArchObject mapArchObject = new MapArchObject();
59  parser.load(reader, mapArchObject);
60  Assert.assertEquals("xyz", mapArchObject.getResetGroup());
61  }
62 
67  @SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
68  @Test
69  public void testLoadResetGroup2() throws IOException {
71  final BufferedReader reader = new BufferedReader(new StringReader("arch map\nend\n"));
72  final MapArchObject mapArchObject = new MapArchObject();
73  parser.load(reader, mapArchObject);
74  Assert.assertEquals("", mapArchObject.getResetGroup());
75  }
76 
81  @SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
82  @Test
83  public void testLoadObsoleteAttributes1() throws IOException {
85  final BufferedReader reader = new BufferedReader(new StringReader("arch map\nx 2\ny 3\nhp 4\nsp 5\nweight 6\nvalue 7\nlevel 8\ninvisible 9\nstand_still 1\nend\n"));
86  final MapArchObject mapArchObject = new MapArchObject();
87  parser.load(reader, mapArchObject);
88  Assert.assertEquals(new Size2D(2, 3), mapArchObject.getMapSize());
89  Assert.assertEquals(4, mapArchObject.getEnterX());
90  Assert.assertEquals(5, mapArchObject.getEnterY());
91  Assert.assertEquals(6, mapArchObject.getResetTimeout());
92  Assert.assertEquals(7, mapArchObject.getSwapTime());
93  Assert.assertEquals(8, mapArchObject.getDifficulty());
94  Assert.assertEquals(9, mapArchObject.getDarkness());
95  Assert.assertTrue(mapArchObject.isFixedReset());
96  }
97 
98 }
net.sf.gridarta.var.crossfire.model.maparchobject.MapArchObject.getResetGroup
String getResetGroup()
Returns the reset group.
Definition: MapArchObject.java:640
net.sf.gridarta
Base package of all Gridarta classes.
net.sf.gridarta.var.crossfire.model.io.MapArchObjectParserTest.testLoadObsoleteAttributes1
void testLoadObsoleteAttributes1()
Checks that the obsolete map attributes can be parsed.
Definition: MapArchObjectParserTest.java:83
net.sf
net.sf.gridarta.model.maparchobject.AbstractMapArchObject.getEnterY
int getEnterY()
Definition: AbstractMapArchObject.java:254
net.sf.gridarta.model.maparchobject.AbstractMapArchObject.isFixedReset
boolean isFixedReset()
Definition: AbstractMapArchObject.java:335
net.sf.gridarta.model.maparchobject.AbstractMapArchObject.getSwapTime
int getSwapTime()
Definition: AbstractMapArchObject.java:305
net.sf.gridarta.var
net.sf.gridarta.model.maparchobject.AbstractMapArchObject.getEnterX
int getEnterX()
Definition: AbstractMapArchObject.java:239
net.sf.gridarta.var.crossfire.model.io.MapArchObjectParserTest.testLoadFirstLoad
void testLoadFirstLoad()
Checks that the "first_load" attribute can be parsed.
Definition: MapArchObjectParserTest.java:41
net.sf.gridarta.var.crossfire.model.io.MapArchObjectParserTest.testLoadResetGroup1
void testLoadResetGroup1()
Checks that the "reset_group" attribute can be parsed.
Definition: MapArchObjectParserTest.java:55
net.sf.gridarta.model.maparchobject.AbstractMapArchObject.getDifficulty
int getDifficulty()
Definition: AbstractMapArchObject.java:320
net
net.sf.gridarta.model.io.MapArchObjectParser
Interface for classes that read or write MapArchObject instances.
Definition: MapArchObjectParser.java:33
net.sf.gridarta.var.crossfire.model.maparchobject.MapArchObject
MapArchObject contains the specific meta data about a map that is stored in the map-arch,...
Definition: MapArchObject.java:39
net.sf.gridarta.var.crossfire.model.io.MapArchObjectParserTest.testLoadResetGroup2
void testLoadResetGroup2()
Checks that the "reset_group" attribute can be parsed.
Definition: MapArchObjectParserTest.java:69
net.sf.gridarta.var.crossfire
Main package of Gridarta4Crossfire, contains all classes specific to the Crossfire version of the Gri...
net.sf.gridarta.model.maparchobject.AbstractMapArchObject.getMapSize
Size2D getMapSize()
Definition: AbstractMapArchObject.java:204
net.sf.gridarta.model.maparchobject.AbstractMapArchObject.getResetTimeout
int getResetTimeout()
Definition: AbstractMapArchObject.java:290
net.sf.gridarta.var.crossfire.model.io.MapArchObjectParserTest
Regression tests for MapArchObjectParser.
Definition: MapArchObjectParserTest.java:33
net.sf.gridarta.var.crossfire.model
net.sf.gridarta.model.maparchobject.AbstractMapArchObject.getDarkness
int getDarkness()
Definition: AbstractMapArchObject.java:350
net.sf.gridarta.model.io
Reading and writing of maps, handling of paths.
Definition: AbstractAnimationObjectsReader.java:20
net.sf.gridarta.model
net.sf.gridarta.var.crossfire.model.io.MapArchObjectParser
A net.sf.gridarta.model.io.MapArchObjectParser for Crossfire map arch object instances.
Definition: MapArchObjectParser.java:43
net.sf.gridarta.var.crossfire.model.maparchobject
Definition: DefaultMapArchObjectFactory.java:20
net.sf.gridarta.var.crossfire.model.maparchobject.MapArchObject.getFirstLoad
int getFirstLoad()
Returns the timestamp the Crossfire server has loaded this map.
Definition: MapArchObject.java:618
net.sf.gridarta.utils.Size2D
The class Size2D represents a 2d rectangular area.
Definition: Size2D.java:30
net.sf.gridarta.utils
Definition: ActionBuilderUtils.java:20