ActionTalk.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /// <reference path="../Action.ts" />
  2. /// <reference path="../../../Elements/Modules/HyperlinkHandler.ts" />
  3. /// <reference path="../../../Elements/Classes/Say/SayHeSheIt.ts" />
  4. class ActionTalk extends Action {
  5. public static PRIORITY_SITUATION_DIALOGUE = 9;
  6. public static PRIORITY_POSSESSION_DIALOGUE = 7;
  7. public static PRIORITY_LOCATION_DIALOGUE = 5;
  8. public static PRIORITY_COMMON_DIALOGUE = 3;
  9. public static PRIORITY_GLOBAL_DIALOGUE = 1;
  10. public static check: Rulebook<ActionTalk> = new Rulebook("Check Talking");
  11. public static carry: Rulebook<ActionTalk> = new Rulebook("Carry out Talking");
  12. public static defaultCarryTalkingRule = ActionTalk.carry.createAndAddRule({
  13. name : "Talking - Doesn't want to talk",
  14. firstPriority : -1,
  15. priority : -1,
  16. code : (rulebook : RulebookRunner<ActionTake>) => {
  17. let action = <ActionGo> rulebook.noun;
  18. //let actor = action.actor;
  19. let thing = (<Thing>action.getNoun(0));
  20. if (thing instanceof Person) {
  21. action.say = new Say("It doesn't look like ", new SayHeSheIt(thing), " wants to talk.");
  22. } else {
  23. action.say = new Say("How are you going to talk to that?")
  24. }
  25. }
  26. });
  27. public getCommandText () {
  28. return "talk to " + (this.getNoun(0) != undefined ? this.getNoun(0).getPrintedName() : "");
  29. }
  30. }
  31. Elements.HyperlinkHandler.HyperlinkingRulebook.addRule(new Rule(
  32. {
  33. name : "Hyperlink - Talk",
  34. firstPriority : Rule.PRIORITY_HIGHEST,
  35. code : (rulebook : RulebookRunner<Thing>) => {
  36. let thing = <Thing> rulebook.noun;
  37. if (thing instanceof Person && thing.getRoom() == WorldState.player.getRoom()) {
  38. Elements.HyperlinkHandler.addAvailableAction("Talk", new ActionTalk(WorldState.player, thing));
  39. }
  40. }
  41. }
  42. ));