/// <reference path="../Humanoid.ts" />
class OrcDebugger extends Humanoid {
    public static nameModifier = new Shuffler([
        "Ugly", "Muscular", "Veiny", "Angry", "Sad", "Smart", "Agile", "Short", "Bulging", "Intense", "Smouldering"
    ]);
    public static counter = 1;
    public constructor () {
        super({
            isMale: true,
            name : (() => {
                let nameMod = OrcDebugger.nameModifier.getOne();
                if (nameMod == undefined) {
                    nameMod = (OrcDebugger.counter++).toString();
                }
                return nameMod + " Orc";
            })(),
            unique : true,
            description : "This is one extremely ugly fellow."
        });

        this.AI.wanderer = true;
        this.AI.picksShinies = true;
    }
}

ActionTalk.carry.createAndAddRule({
    name : "Talking to the orc",
    firstPriority : ActionTalk.PRIORITY_GLOBAL_DIALOGUE,
    priority : ActionTalk.PRIORITY_COMMON_DIALOGUE,
    conditions : (runner : RulebookRunner<ActionTalk>) => {
        return runner.noun.getNoun(0) instanceof OrcDebugger;
    },
    code : (runner : RulebookRunner<ActionTalk>) => {
        let orc = <OrcDebugger> runner.noun.getNoun(0);
        //await DialogueTrees.CompilableTest.execute();
        let result = Dice.testAgainstRoll(
            {name: "Charm + 2", value : WorldState.player.getStat(Attributes.Charm) + 2},
            {name: "Orc's wits + 2", value : orc.getStat(Attributes.Intelligence) + 2}
        );

        if (result > 0) {
            Elements.CurrentTurnHandler.printAsContent(new Say("You win!"));
        } else {
            Elements.CurrentTurnHandler.printAsContent(new Say("You lose."));
        }
        return true;
    }
});