37 lines
1.0 KiB
Java
37 lines
1.0 KiB
Java
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<String> vulnerability = new HashSet<>();
|
|
public final List<ZorkCondition> conditions = new ArrayList<>();
|
|
public final List<String> print = new ArrayList<>();
|
|
public final List<String> 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;
|
|
}
|
|
}
|