AIPickShiny.ts 838 B

1234567891011121314151617181920212223
  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 visibleThings = person.AI.newNoticed;
  13. if (visibleThings.length > 0) {
  14. for (let i = 0; i < visibleThings.length; i++) {
  15. if (!visibleThings[i].fixedInPlace && visibleThings[i].getShiny()) {
  16. return new ActionTake(person, visibleThings[i]);
  17. }
  18. }
  19. }
  20. }
  21. });
  22. }