package com.github.dtschust.zork.types; import com.github.dtschust.zork.Zork; import com.github.dtschust.zork.ZorkCondition; import com.github.dtschust.zork.parser.ZorkGame; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; /* Creature*/ public class ZorkCreature extends ZorkObject { public final Set vulnerability = new HashSet<>(); public final List conditions = new ArrayList<>(); public final List print = new ArrayList<>(); public final List action = new ArrayList<>(); public ZorkCreature(String name, String description) { super(name, description); } /* Evaluate the success of an attack*/ public boolean attack(ZorkGame game, String weapon) { if (!vulnerability.contains(weapon)) { return false; } for (ZorkCondition condition : conditions) { if (!condition.evaluate(game)) { return false; } } return true; } }