/// <reference path="../../Bodypart.ts" />
/// <reference path="../../Humanoid/Humanoid.ts" />
/// <reference path="../SexStick.ts" />
/// <reference path="../SexHole.ts" />
/// <reference path="../../../Measure.ts" />
class HumanoidSkin extends Bodypart {
    public sorenessWeight = 0;
    public genderWeight = Bodypart.WEIGHT_MEDIUM;
    public slots : Array<number> = [
        Humanoid.SLOT_FACE, Humanoid.SLOT_NECK, Humanoid.SLOT_SHOULDERS,
        Humanoid.SLOT_ARMS, Humanoid.SLOT_HANDS, Humanoid.SLOT_UPPER_CHEST,
        Humanoid.SLOT_MIDRIFF, Humanoid.SLOT_WAIST, Humanoid.SLOT_BACK,
        Humanoid.SLOT_HIPS, Humanoid.SLOT_BUTT, Humanoid.SLOT_LEG_UPPER,
        Humanoid.SLOT_LEG_LOWER
    ];

    public skinSoftness = 5; // 0 to 10, 0 being rough and 10 being silky
    public skinHairiness = 2; // 0 to 10, 10 being literal gorilla and 0 being smooth everywhere, 1~2 probably some armpit or something

    public constructor (options? : ThingOptions) {
        super(options);
        this.addGetAlterations((thing) => {
            return {
                Softness : this.skinSoftness,
                Hairiness : this.skinHairiness
            }
        });

        this.addSetAlterations((thing, changes) => {
            this.skinSoftness = changes.Softness;
            this.skinHairiness = changes.Hairiness;
        });
    }

    public getSluttiness () {
        return this.getGenderValue();
    }

    public getDescription () {
        let owner = <Person> this.getPartOne();
        let green = (owner.getStat(Attributes.Corruption) > 50);

        let say = new Say("Your skin is ");

        if (this.skinSoftness > 7) {
            say.add("perfectly smooth");
        } else if (this.skinSoftness > 4) {
            say.add("smooth");
        } else {
            say.add("rough");
        }

        say.add(" and ");

        if (this.skinHairiness > 8) {
            say.add("hairy, like a gorilla's")
        } else if (this.skinHairiness > 6) {
            say.add("hairy")
        } else if (this.skinHairiness > 3) {
            say.add("somewhat hairless");
        } else {
            say.add("completely hairless");
        }

        say.add(".");

        if (green) {
            say.add(" The taint of your corruption has turned your skin green, like an orc's.")
        }

        return say;
    }

    public getGenderValue () {
        let softnessRank = this.skinSoftness * 100;
        let hairinessRank = 1000 - (this.skinHairiness * 100);

        return (softnessRank + hairinessRank) / 20;
    }

    public arrangeGenderValue (genderValue : number) {
        let ideal = genderValue / 10;
        this.skinHairiness= 10 - Math.round(ideal);
        this.skinSoftness  = Math.round(ideal);
        (<Humanoid> this.getPartOne()).invalidateCaches();
    }
}