package com.github.dtschust.zork.types; import com.github.dtschust.zork.Zork; import com.github.dtschust.zork.ZorkTrigger; import java.util.*; /* Room*/ public class ZorkRoom extends ZorkObject implements HasSetOfCollectable { private final String type; private final Map border; private final Set container; private final Set item; private final Set creature; public ZorkRoom(final String name, final String description, final String type, final String status, final Collection triggers, final Map borders, final Collection containers, final Collection items, final Collection creatures) { super(name, description, status, triggers); this.type = type; this.border = new HashMap<>(borders); this.container = new HashSet<>(containers); this.item = new HashSet<>(items); this.creature = new HashSet<>(creatures); } @Override public Set getSetFromType(Zork.Type type) { switch (type) { case CONTAINER: return getContainer(); case CREATURE: return getCreature(); case ITEM: return getItem(); default: throw new IllegalStateException("Unexpected value: " + type); } } public boolean isExit() { return "exit".equals(type); } public void removeBorderingRoom(String roomName) { for (final ZorkDirection d : this.border.keySet()) { if (this.border.get(d).equals(roomName)) { this.border.remove(d); } } } public Optional getBorderingRoom(ZorkDirection border) { return Optional.ofNullable(this.border.get(border)); } public Set getContainer() { return container; } public Set getItem() { return item; } public Set getCreature() { return creature; } }