ActionStand.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /// <reference path="../Action.ts" />
  2. /// <reference path="../Rule.ts" />
  3. /// <reference path="../Rulebook.ts" />
  4. /// <reference path="../Things/Person.ts" />
  5. class ActionStand extends Action {
  6. public static check = new Rulebook<ActionStand>("Check Stand");
  7. public static carry = new Rulebook<ActionStand>("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 = ActionStand.check.createAndAddRule({
  17. name : "Stand - Can stand?",
  18. code : (rulebook) => {
  19. // TODO: Check if being held down
  20. // TODO: Check if incapacitated
  21. }
  22. });
  23. public static carryStand = ActionStand.carry.createAndAddRule({
  24. name : "Stand - Rise up!",
  25. code : (runner : RulebookRunner<ActionStand>) => {
  26. let actor = runner.noun.actor;
  27. if (actor instanceof Person) {
  28. actor.stance = PersonStance.STANDING;
  29. if (actor == WorldState.player) {
  30. runner.noun.say.add("You get up.");
  31. } else {
  32. runner.noun.say.add(runner.noun.actor, " rises up.");
  33. }
  34. }
  35. }
  36. });
  37. }
  38. Elements.HyperlinkHandler.CommonActionsRulebook.addRule(new Rule(
  39. {
  40. name : "Hyperlink - Stand up!",
  41. firstPriority : Rule.PRIORITY_MEDIUM,
  42. code : (rulebook : RulebookRunner<void>) => {
  43. if (WorldState.player.stance == PersonStance.ALLFOURS) {
  44. Elements.HyperlinkHandler.addCommonAction("Get up", new ActionStand(WorldState.player));
  45. }
  46. }
  47. }
  48. ));