///
module AIRules {
export var PickShiny = AI.rules.createAndAddRule({
name : "Pick Shinies",
firstPriority : AIRules.PRIORITY_ACTING_ON_PLACE,
conditions : (runner : RulebookRunner) => {
let person = runner.noun;
return person.AI.picksShinies;
},
code : (runner : RulebookRunner) => {
let person = runner.noun;
let room = person.getRoom();
let visibleThings = room.getContainedAndVisibleTo(person);
if (visibleThings.length > 0) {
for (let i = 0; i < visibleThings.length; i++) {
if (!visibleThings[i].fixedInPlace && visibleThings[i].getShiny()) {
return new ActionTake(person, visibleThings[i]);
}
}
}
}
});
}