1
1

ActionDropDown.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /// <reference path="../Action.ts" />
  2. /// <reference path="../Rule.ts" />
  3. /// <reference path="../Rulebook.ts" />
  4. /// <reference path="../Things/Person.ts" />
  5. class ActionDropDown extends Action {
  6. public static check = new Rulebook<ActionDropDown>("Check Stand");
  7. public static carry = new Rulebook<ActionDropDown>("Carry out Stand");
  8. public constructor (actor : Thing, ...nouns : Array<any>) {
  9. super(actor, ...nouns);
  10. this.requiresNoun = false;
  11. this.requiresVisibility = false;
  12. }
  13. public getCommandText () {
  14. return "stand up"
  15. }
  16. public static checkStand = ActionDropDown.check.createAndAddRule({
  17. name : "Stand - Can get down?",
  18. code : (rulebook) => {
  19. // TODO: Check if being held up
  20. }
  21. });
  22. public static carryStand = ActionDropDown.carry.createAndAddRule({
  23. name : "Stand - Go doggy",
  24. code : (runner : RulebookRunner<ActionDropDown>) => {
  25. let actor = runner.noun.actor;
  26. if (actor instanceof Person) {
  27. actor.stance = PersonStance.ALLFOURS;
  28. if (actor == WorldState.player) {
  29. runner.noun.say.add("You get down on all fours.");
  30. } else {
  31. runner.noun.say.add(runner.noun.actor, " gets down.");
  32. }
  33. }
  34. }
  35. });
  36. }
  37. Elements.HyperlinkHandler.CommonActionsRulebook.addRule(new Rule(
  38. {
  39. name : "Hyperlink - Stand up!",
  40. firstPriority : Rule.PRIORITY_MEDIUM,
  41. code : (rulebook : RulebookRunner<void>) => {
  42. if (WorldState.player.stance != PersonStance.ALLFOURS) {
  43. Elements.HyperlinkHandler.addCommonAction("Get down", new ActionDropDown(WorldState.player));
  44. }
  45. }
  46. }
  47. ));