/// <reference path="PersonStat.ts" />
interface AttributeBearer {
    getStat (attr : Attribute) : number;
    setStat (attr : Attribute, value : number) : void;
}

class Attribute extends PersonStat {
    public defaultValue : number = 2;
    public maxValue : number = 5;

    public constructor (id : string, description? : string | Say | ((value : number) => string | Say), defValue? :number, maxValue?:number) {
        super(id, description);
        if (defValue != undefined) {
            this.defaultValue = defValue;
        }

        if (maxValue != undefined) {
            this.maxValue = maxValue;
        }

        Attribute.Attributes[id] = this;
    }

    private static Attributes : {[id : string] : Attribute} = {};

    public static getAttributes () {
        let attributes = [];
        for (let key in Attribute.Attributes) {
            attributes.push(Attribute.Attributes[key]);
        }
        return attributes;
    }

    public static getAttribute (id : string) {
        return Attribute.Attributes[id];
    }
}

module Attributes {
    export let Strength = new Attribute(
        "Strength",
        value => {
            switch (value) {
                case 5: return "Hercules' Bigger Cousin";
                case 4: return ("Circus Strong" + ((<Humanoid> WorldState.player).isMale() ? "man" : "woman"));
                case 3: return "Beach Bully";
                case 2: return ("Average " + ((<Humanoid> WorldState.player).isMale() ? "Joe" : "Jane"));
                case 1: return "Wet Noodle";
                default: return "Out of bounds.";
            }
        }
    );
    export let Agility = new Attribute(
        "Agility",
        value => {
            switch (value) {
                case 5: return "Catlike";
                case 4: return "Gymnast";
                case 3: return "Accurate";
                case 2: return "Common";
                case 1: return "Accident-prone";
                default: return "Out of bounds.";
            }
        }
    );

    export let Intelligence = new Attribute(
        "Intelligence",
        value => {
            switch (value) {
                case 5: return "Genius";
                case 4: return "Gifted";
                case 3: return "Knowledgeable";
                case 2: return "Normal";
                case 1: return "Door";
                default: return "Out of bounds.";
            }
        }
    );

    export let Charm = new Attribute(
        "Charm",
        value => {
            switch (value) {
                case 5: return ((<Humanoid> WorldState.player).isMale() ? "Casanova" : "Seductress");
                case 4: return "Diplomat";
                case 3: return ("Cheery Sales" + ((<Humanoid> WorldState.player).isMale() ? "man" : "woman"));
                case 2: return "Not even trying";
                case 1: return "Unpleasant";
                default: return "Out of bounds.";
            }
        }
    );

    export let Corruption = new Attribute(
        "Corruption",
        value => {
            return "Not defined"
        },
        0, 100
    );


    export let GenderIdentity = new Attribute(
        "Gender Identity",
        value => {
            if (value >= 75) {
                return "You strongly feel, and act, like a woman.";
            } else if (value >= 60) {
                return "You feel, and act, like a woman.";
            } else if (value >= 40) {
                return "You don't feel nor act like any particular gender.";
            } else if (value >= 20) {
                return "You feel, and act, like a man.";
            } else {
                return "You strongly feel, and act, like a man.";
            }
        },
        50, 100
    );


    export let Degeneration = new Attribute(
        "Degeneration",
        value => {
            if (value >= 75) {
                return "Sex is about the only thing on your mind, and you don't even try to hide it anymore.";
            } else if (value >= 60) {
                return "Sometimes you can't hide how naughty you'd like to be.";
            } else if (value >= 40) {
                return "";
            } else if (value >= 20) {
                return "Your composure is prudish and calm.";
            } else {
                return "You have the composure of a saint.";
            }
        },
        30, 100
    );
}