package com.github.dtschust.zork; import java.util.List; /*Trigger*/ public class ZorkTrigger { private final List conditions; private final List commands; public final List print; public final List action; /* By default, "single" */ public final String type; public boolean hasCommand() { return !this.commands.isEmpty(); } public ZorkTrigger(final String type, final List conditions, final List commands, final List print, final List 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)); } }