2022-11-19 09:46:28 +00:00
|
|
|
package com.github.dtschust.zork.types;
|
2022-11-16 15:18:00 +00:00
|
|
|
|
2022-11-21 21:29:36 +00:00
|
|
|
import com.github.dtschust.zork.ZorkTrigger;
|
|
|
|
|
|
|
|
import java.util.*;
|
2022-11-16 15:18:00 +00:00
|
|
|
|
|
|
|
/* Container*/
|
2022-11-16 16:18:19 +00:00
|
|
|
public class ZorkContainer extends ZorkObject {
|
2022-11-21 21:29:36 +00:00
|
|
|
public final Set<String> item;
|
|
|
|
private final List<String> accepts;
|
|
|
|
private boolean open;
|
2022-11-16 15:18:00 +00:00
|
|
|
|
2022-11-21 21:29:36 +00:00
|
|
|
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);
|
2022-11-16 15:18:00 +00:00
|
|
|
}
|
2022-11-20 13:11:58 +00:00
|
|
|
|
2022-11-21 21:29:36 +00:00
|
|
|
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();
|
|
|
|
}
|
2022-11-20 13:11:58 +00:00
|
|
|
|
2022-11-21 16:10:08 +00:00
|
|
|
public boolean isOpen() {
|
2022-11-20 13:11:58 +00:00
|
|
|
return open;
|
|
|
|
}
|
2022-11-21 16:10:08 +00:00
|
|
|
|
|
|
|
public void open() {
|
2022-11-20 13:11:58 +00:00
|
|
|
open = true;
|
|
|
|
}
|
2022-11-16 15:18:00 +00:00
|
|
|
}
|