/// <reference path="../Action.ts" />
/// <reference path="../Rule.ts" />
/// <reference path="../Rulebook.ts" />
/// <reference path="../Things/Person.ts" />
class ActionDropDown extends Action {
    public static check = new Rulebook<ActionDropDown>("Check Stand");
    public static carry = new Rulebook<ActionDropDown>("Carry out Stand");

    public constructor (actor : Thing, ...nouns : Array<any>) {
        super(actor, ...nouns);
        this.requiresNoun = false;
        this.requiresVisibility = false;
    }

    public getCommandText () {
        return "stand up"
    }

    public static checkStand = ActionDropDown.check.createAndAddRule({
        name : "Stand - Can get down?",
        code : (rulebook) => {
            // TODO: Check if being held up
        }
    });

    public static carryStand = ActionDropDown.carry.createAndAddRule({
        name : "Stand - Go doggy",
        code : (runner : RulebookRunner<ActionDropDown>) => {
            let actor = runner.noun.actor;
            if (actor instanceof Person) {
                actor.stance = PersonStance.ALLFOURS;

                if (actor == WorldState.player) {
                    runner.noun.say.add("You get down on all fours.");
                } else {
                    runner.noun.say.add(runner.noun.actor, " gets down.");
                }
            }
        }
    });
}

Elements.HyperlinkHandler.CommonActionsRulebook.addRule(new Rule(
    {
        name : "Hyperlink - Stand up!",
        firstPriority : Rule.PRIORITY_MEDIUM,
        code : (rulebook : RulebookRunner<void>) => {
            if (WorldState.player.stance != PersonStance.ALLFOURS) {
                Elements.HyperlinkHandler.addCommonAction("Get down", new ActionDropDown(WorldState.player));
            }
        }
    }
));