20 package net.sf.gridarta.model.io;
22 import java.io.BufferedReader;
23 import java.io.IOException;
24 import java.util.Formatter;
28 import org.jetbrains.annotations.NotNull;
29 import org.jetbrains.annotations.Nullable;
38 protected boolean parseLine(@NotNull
final String line, @NotNull
final TestMapArchObject mapArchObject, @NotNull
final BufferedReader reader) {
43 public void save(@NotNull
final Appendable appendable, @NotNull
final TestMapArchObject mapArchObject, @Nullable
final MapFile mapFile)
throws IOException {
44 final Formatter format =
new Formatter(appendable);
45 appendable.append(
"arch map\n");
46 if (!mapArchObject.getMapName().isEmpty()) {
47 format.format(
"name %s\n", mapArchObject.getMapName());
49 if (mapArchObject.getSwapTime() != 0) {
50 format.format(
"swap_time %d\n", mapArchObject.getSwapTime());
52 if (mapArchObject.getResetTimeout() != 0) {
53 format.format(
"reset_timeout %d\n", mapArchObject.getResetTimeout());
55 if (mapArchObject.isFixedReset()) {
56 appendable.append(
"fixed_resettime 1\n");
58 if (mapArchObject.getDifficulty() != 0) {
59 format.format(
"difficulty %d\n", mapArchObject.getDifficulty());
61 if (mapArchObject.getDarkness() != 0) {
62 format.format(
"darkness %d\n", mapArchObject.getDarkness());
64 format.format(
"width %d\n", mapArchObject.getMapSize().getWidth());
65 format.format(
"height %d\n", mapArchObject.getMapSize().getHeight());
66 if (mapArchObject.getEnterX() != 0) {
67 format.format(
"enter_x %d\n", mapArchObject.getEnterX());
69 if (mapArchObject.getEnterY() != 0) {
70 format.format(
"enter_y %d\n", mapArchObject.getEnterY());
72 if (!mapArchObject.getText().trim().isEmpty()) {
73 format.format(
"msg\n" +
"%s\n" +
"endmsg\n", mapArchObject.getText().trim());
75 if (mapArchObject.isOutdoor()) {
76 appendable.append(
"outdoor 1\n");
79 if (!mapArchObject.getTilePath(direction).isEmpty()) {
80 format.format(
"tile_path_%d %s\n", direction.ordinal() + 1, mapArchObject.getTilePath(direction));
83 appendable.append(
"end\n");
Abstract base class for classes implementing MapArchObjectParsers.
boolean parseLine(@NotNull final String line, @NotNull final TestMapArchObject mapArchObject, @NotNull final BufferedReader reader)
A MapArchObject implementation for testing purposes.
Base package of all Gridarta classes.
A MapArchObjectParser for regression tests.
void save(@NotNull final Appendable appendable, @NotNull final TestMapArchObject mapArchObject, @Nullable final MapFile mapFile)
The location of a map file with a map directory.