|
@@ -2,10 +2,14 @@
|
|
/// <reference path="../Rule.ts" />
|
|
/// <reference path="../Rule.ts" />
|
|
/// <reference path="../Rulebook.ts" />
|
|
/// <reference path="../Rulebook.ts" />
|
|
/// <reference path="../Things/Person.ts" />
|
|
/// <reference path="../Things/Person.ts" />
|
|
|
|
+import player = WorldState.player;
|
|
|
|
+
|
|
class ActionRest extends Action {
|
|
class ActionRest extends Action {
|
|
public static check = new Rulebook<ActionRest>("Check Rest");
|
|
public static check = new Rulebook<ActionRest>("Check Rest");
|
|
public static carry = new Rulebook<ActionRest>("Carry out Rest");
|
|
public static carry = new Rulebook<ActionRest>("Carry out Rest");
|
|
|
|
|
|
|
|
+ private waiting = false;
|
|
|
|
+
|
|
public constructor (actor : Thing, ...nouns : Array<any>) {
|
|
public constructor (actor : Thing, ...nouns : Array<any>) {
|
|
super(actor, ...nouns);
|
|
super(actor, ...nouns);
|
|
this.requiresNoun = true;
|
|
this.requiresNoun = true;
|
|
@@ -18,13 +22,30 @@ class ActionRest extends Action {
|
|
|
|
|
|
public static carryRest = ActionRest.carry.createAndAddRule({
|
|
public static carryRest = ActionRest.carry.createAndAddRule({
|
|
name : "Rest - Restful Moment",
|
|
name : "Rest - Restful Moment",
|
|
- code : (runner : RulebookRunner<ActionRest>) => {
|
|
|
|
|
|
+ code : async (runner : RulebookRunner<ActionRest>) => {
|
|
let actor = runner.noun.actor;
|
|
let actor = runner.noun.actor;
|
|
if (actor instanceof Person) {
|
|
if (actor instanceof Person) {
|
|
- // TODO: Run the Rulebook responsible for healing on the person. Resting = 2x healing.
|
|
|
|
|
|
+ let bodyparts = <Array<Bodypart>> actor.getParts(Bodypart);
|
|
|
|
+
|
|
|
|
+ bodyparts.forEach(bodypart => {
|
|
|
|
+ bodypart.regenerate();
|
|
|
|
+ });
|
|
let action = runner.noun;
|
|
let action = runner.noun;
|
|
if (WorldState.isPlayer(actor)) {
|
|
if (WorldState.isPlayer(actor)) {
|
|
- runner.noun.say.add("You decide to rest for a bit on ", Say.Mention(runner.noun.getNoun(0)), ".");
|
|
|
|
|
|
+ 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 {
|
|
} else {
|
|
runner.noun.say.add(Say.Mention(action.actor), " rests on ", Say.Mention(action.getNoun(0)), ".");
|
|
runner.noun.say.add(Say.Mention(action.actor), " rests on ", Say.Mention(action.getNoun(0)), ".");
|
|
}
|
|
}
|