/// /// /// /// import player = WorldState.player; class ActionRest extends Action { public static check = new Rulebook("Check Rest"); public static carry = new Rulebook("Carry out Rest"); private waiting = false; public constructor (actor : Thing, ...nouns : Array) { super(actor, ...nouns); this.requiresNoun = true; this.requiresVisibility = true; } public getCommandText () { return "rest on " + ( this.getNoun(0)).getPrintedName(); } public static carryRest = ActionRest.carry.createAndAddRule({ name : "Rest - Restful Moment", code : async (runner : RulebookRunner) => { let actor = runner.noun.actor; if (actor instanceof Person) { let bodyparts = > actor.getParts(Bodypart); bodyparts.forEach(bodypart => { bodypart.regenerate(); }); let action = runner.noun; if (WorldState.isPlayer(actor)) { if (action.waiting || (WorldState.player.getHealthOnScale() <= 9 && await Controls.askForConsent("Rest until fully healed?"))) { if (WorldState.player.getHealthOnScale() <= 9) { TurnSequence.repeatedAction = action; action.waiting = true; } else { action.waiting = false; } } if (action.waiting) { runner.noun.say.add("You keep resting on ", Say.Mention(runner.noun.getNoun(0)), "."); } else { runner.noun.say.add("You decide to rest on ", Say.Mention(runner.noun.getNoun(0)), "."); } } else { runner.noun.say.add(Say.Mention(action.actor), " rests on ", Say.Mention(action.getNoun(0)), "."); } } } }); } Elements.HyperlinkHandler.HyperlinkingRulebook.addRule(new Rule( { name : "Hyperlink - Rest", firstPriority : Rule.PRIORITY_HIGHEST, code : (rulebook : RulebookRunner) => { let thing = rulebook.noun; if (thing instanceof RestingStuff && thing.isVisibleTo(WorldState.player)) { Elements.HyperlinkHandler.addAvailableAction("Rest", new ActionRest(WorldState.player, thing)); } } } ));