package com.github.dtschust.zork;
import java.util.List;
/*Trigger*/
public class ZorkTrigger {
private final List<ZorkCondition> conditions;
private final List<ZorkCommand> commands;
public final List<String> print;
public final List<String> action;
/* By default, "single" */
public final String type;
public boolean hasCommand() {
return !this.commands.isEmpty();
}
public ZorkTrigger(final String type,
final List<ZorkCondition> conditions,
final List<ZorkCommand> commands,
final List<String> print,
final List<String> action) {
this.conditions = conditions;
this.commands = commands;
this.print = print;
this.action = action;
this.type = type;
public boolean evaluate(Zork zork) {
if (!commands.stream().allMatch(c -> c.matchesInput(zork.userInput))) {
return false;
return conditions.stream().allMatch(c -> c.evaluate(zork.game));