1
1

ActionExamine.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /// <reference path="../Action.ts" />
  2. /// <reference path="../Rule.ts" />
  3. /// <reference path="../Rulebook.ts" />
  4. /// <reference path="../../../Elements/Classes/Say/SayBold.ts" />
  5. class ActionExamine extends Action {
  6. public requiresTurn = false;
  7. public static check = new Rulebook<ActionExamine>("Check Examining");
  8. public static carry = new Rulebook<ActionExamine>("Carry out Examining");
  9. /**
  10. * Needs to return a string explaining what the player will do if he does this action.
  11. * For instance, ActionTaking should return something like return "take " + this.nouns[0].getName(),
  12. * which would read as "take thing".
  13. * remember that things implement PRINTABLE interface, so you can get their names.
  14. * @returns {Say}
  15. */
  16. public getCommandText () {
  17. if (this.getNoun(0) == WorldState.player) {
  18. return "examine myself";
  19. }
  20. return "examine " + (this.getNoun(0) != undefined ? this.getNoun(0).getPrintedName() : "");
  21. }
  22. public static PrintDescriptionOfExaminedThingRule = ActionExamine.carry.createAndAddRule({
  23. name : "Examine - Print Description of Examined Thing",
  24. code : (rulebook) => {
  25. let action = rulebook.noun;
  26. let noun = action.getNoun(0);
  27. if (noun instanceof Thing && (<Thing> noun).image != undefined) {
  28. action.say.add((<Thing> noun).image, Say.PARAGRAPH_BREAK);
  29. }
  30. action.say.add((<Thing> action.getNoun(0)).getPrintedDescription());
  31. }
  32. });
  33. }
  34. Elements.HyperlinkHandler.CommonActionsRulebook.addRule(new Rule({
  35. name : "Look at me!",
  36. firstPriority : Rule.PRIORITY_LOWEST,
  37. priority : Rule.PRIORITY_HIGH,
  38. code : (rulebook : RulebookRunner<void>) => {
  39. Elements.HyperlinkHandler.addCommonAction("Inspect", new ActionExamine(WorldState.player, WorldState.player));
  40. }
  41. }));