Minor cleanups

This commit is contained in:
Claudio Maggioni 2022-11-22 11:32:57 +01:00
parent 718e736032
commit 9564a205dc
8 changed files with 13 additions and 21 deletions

View file

@ -19,6 +19,7 @@ import static com.github.dtschust.zork.Zork.Type.*;
public class Zork {
ZorkGame game;
Scanner source = new Scanner(System.in);
public Zork(String filename) {
game = new ZorkReader(filename).build();

View file

@ -2,7 +2,7 @@ package com.github.dtschust.zork;
/* Special Command condition */
public class ZorkCommand {
public final String commandName;
private final String commandName;
public ZorkCommand(String command) {
this.commandName = command;

View file

@ -2,7 +2,7 @@ package com.github.dtschust.zork;
/* Generic condition*/
public abstract class ZorkCondition {
public final String object;
protected final String object;
protected ZorkCondition(String object) {
this.object = object;

View file

@ -10,13 +10,13 @@ import java.util.Set;
public class ZorkGame {
public final Set<String> inventory = new HashSet<>();
protected boolean running = false;
protected String currentRoom;
protected ZorkMap<ZorkRoom> rooms = new ZorkMap<>();
protected ZorkMap<ZorkItem> items = new ZorkMap<>();
protected ZorkMap<ZorkContainer> containers = new ZorkMap<>();
protected ZorkMap<ZorkCreature> creatures = new ZorkMap<>();
protected HashMap<String, Type> objectLookup = new HashMap<>();
private final ZorkMap<ZorkRoom> rooms = new ZorkMap<>();
private final ZorkMap<ZorkItem> items = new ZorkMap<>();
private final ZorkMap<ZorkContainer> containers = new ZorkMap<>();
private final ZorkMap<ZorkCreature> creatures = new ZorkMap<>();
private final HashMap<String, Type> objectLookup = new HashMap<>();
private boolean running = false;
private String currentRoom;
public ZorkRoom getCurrentRoom() {
return rooms.get(currentRoom);

View file

@ -1,12 +1,13 @@
package com.github.dtschust.zork.parser;
import com.github.dtschust.zork.parser.dom.Elements;
import org.w3c.dom.CharacterData;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
public final class DOMUtils {
private DOMUtils() {

View file

@ -6,7 +6,6 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.List;
import java.util.RandomAccess;
import java.util.stream.Collectors;

View file

@ -3,7 +3,6 @@ package com.github.dtschust.zork.repl.actions;
import com.github.dtschust.zork.ZorkGame;
import com.github.dtschust.zork.repl.Action;
import com.github.dtschust.zork.types.ZorkDirection;
import com.github.dtschust.zork.types.ZorkRoom;
import java.util.List;
import java.util.Optional;

View file

@ -9,14 +9,6 @@ public enum ZorkDirection {
SOUTH("south", "s"),
WEST("west", "w");
public String getLongName() {
return longName;
}
public String getShortName() {
return shortName;
}
private final String longName;
private final String shortName;