/// <reference path="PersonStat.ts" />
interface SkillBearer {
    getSkill (attr : Skill) : number;
    setSkill (attr : Skill, value : number) : void;
}

class Skill extends PersonStat {
    public defaultValue : number = 0;
    public maxValue : number = 5;

    public constructor (id : string, description? : string | Say | ((value : number) => string | Say)) {
        super(id, description);
        Skill.Skills[id] = this;
    }

    private static Skills : {[id : string] : Skill} = {};

    public static getSkills () {
        let skills = [];
        for (let key in Skill.Skills) {
            skills.push(Skill.Skills[key]);
        }
        skills.sort((a : Skill, b : Skill) => {
            let na = a.id.toUpperCase();
            let nb = b.id.toUpperCase();
            if (na > nb) return 1;
            if (na < nb) return -1;
            return 0;
        });
        return skills;
    }

    public static getSkill (id : string) {
        return Skill.Skills[id];
    }
}

module Skills {
    export let Survival = new Skill(
    "Survival",
    (value) => {
            switch (value) {
                case 5: return "";
                case 4: return "";
                case 3: return "";
                case 2: return "";
                case 1: return "Alert Chihuahua";
            }
        }
    );
}