AIPickShiny.ts 896 B

123456789101112131415161718192021222324
  1. /// <reference path="../AI.ts" />
  2. module AIRules {
  3. export var PickShiny = AI.rules.createAndAddRule({
  4. name : "Pick Shinies",
  5. firstPriority : AIRules.PRIORITY_ACTING_ON_PLACE,
  6. conditions : (runner : RulebookRunner<Person>) => {
  7. let person = runner.noun;
  8. return person.AI.picksShinies;
  9. },
  10. code : (runner : RulebookRunner<Person>) => {
  11. let person = runner.noun;
  12. let room = person.getRoom();
  13. let visibleThings = room.getContainedAndVisibleTo(person);
  14. if (visibleThings.length > 0) {
  15. for (let i = 0; i < visibleThings.length; i++) {
  16. if (!visibleThings[i].fixedInPlace && visibleThings[i].getShiny()) {
  17. return new ActionTake(person, visibleThings[i]);
  18. }
  19. }
  20. }
  21. }
  22. });
  23. }