This repository has been archived on 2022-12-21. You can view files and clone it, but cannot push or open issues or pull requests.
sdm03/src/main/java/com/github/dtschust/zork/types/ZorkContainer.java

50 lines
1.2 KiB
Java

package com.github.dtschust.zork.types;
import com.github.dtschust.zork.ZorkTrigger;
import java.util.*;
/* Container*/
public class ZorkContainer extends ZorkObject {
public final Set<String> item;
private final List<String> accepts;
private boolean open;
public ZorkContainer(final String name,
final String description,
final boolean open,
final String status,
final Collection<String> items,
final Collection<String> accepts,
final Collection<ZorkTrigger> triggers) {
super(name, description, status, triggers);
this.open = open;
this.item = new HashSet<>(items);
this.accepts = new ArrayList<>(accepts);
}
public void addItem(final String item) {
this.item.add(item);
}
public void removeItem(final String item) {
this.item.remove(item);
}
public boolean containsItem(final String item) {
return this.item.contains(item);
}
public boolean isEmpty() {
return this.item.isEmpty();
}
public boolean isOpen() {
return open;
}
public void open() {
open = true;
}
}