/// <reference path="../AI.ts" />
module AIRules {
    export var PickShiny = AI.rules.createAndAddRule({
        name : "Pick Shinies",
        firstPriority : AIRules.PRIORITY_ACTING_ON_PLACE,
        conditions : (runner : RulebookRunner<Person>) => {
            let person = runner.noun;
            return person.AI.picksShinies;
        },
        code : (runner : RulebookRunner<Person>) => {
            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]);
                    }
                }
            }
        }
    });
}