class Skill extends Initializing{

    label: 'Label Missing';

    hidden: false;

    e2s = Skill.e2sFunction();
    s2e = Skill.s2eFunction();

    //#region Static
        static get(skillId:string):Skill{
            const constantData = setup.skills[skillId];
            if(!constantData)
                return new NullSkill();
            return new Skill().init(constantData);
        }

        static e2sFunction(factorEvery10Levels=2,factor=100){
            return function(n:number){
                const base = factorEvery10Levels ** 0.1;
                n += factor;
                return Math.floor(Math.logBase(n/100,base));
            }
        }

        static s2eFunction(factorEvery10Levels=2,factor=100){
            return function(n:number):number{
                const base = factorEvery10Levels ** 0.1;
                return Math.ceil(Math.pow(base,n) * factor) - factor;
            }
        }
    //#endregion

    experience2Skill(experience:number){return this.e2s(experience);}
    skill2Experience(skillLevel:number){return this.s2e(skillLevel);}

    skillGain(skillData: SkillOfCharacter, requestedExperienceIncrease:number):number{
        let experienceEffectiveGain = 0;
        const todaysStartExperience = skillData.experienceHistory.last();
        const todaysStartLevel = this.experience2Skill(todaysStartExperience);
        const experienceRequiredToAdvanceOneLevel = this.skill2Experience(todaysStartLevel + 1) - this.skill2Experience(todaysStartLevel);
        const experienceWithoutPenalty = experienceRequiredToAdvanceOneLevel;

        let experienceGainedSoFarToday = skillData.experience - todaysStartExperience;
        const experienceToGainWithoutPenaltyLeft = Math.max(0,experienceWithoutPenalty - experienceGainedSoFarToday);

        const experienceToGainWithoutPenalty = Math.min(requestedExperienceIncrease,experienceToGainWithoutPenaltyLeft);
        experienceEffectiveGain += experienceToGainWithoutPenalty;
        experienceGainedSoFarToday += experienceToGainWithoutPenalty;
        requestedExperienceIncrease -= experienceToGainWithoutPenalty;

        const requestedTotalExperienceIncrease = experienceGainedSoFarToday + requestedExperienceIncrease;
        const factorOfBeingOverTarget = requestedTotalExperienceIncrease / experienceWithoutPenalty;

        const experienceGainWithPenalty = Math.ceil(requestedExperienceIncrease / factorOfBeingOverTarget);

        experienceEffectiveGain += experienceGainWithPenalty;

        return experienceEffectiveGain;
    }
}

class NullSkill extends Skill{

}

setup.Skill = Skill;

setup.skills = {};

setup.skills.agility = {
    label: 'Agility',
    hidden: true
}

setup.skills.charisma = {
    label: 'Charisma',
    hidden: true
}

setup.skills.chess = {
    label: 'Chess',
    e2s: Skill.e2sFunction(2.5),
    s2e: Skill.s2eFunction(2.5)
}

setup.skills.computer = {
    label: 'Computer'
}

setup.skills.dance = {
    label: 'Dancing'
}

setup.skills.gaming = {
    label: 'Gaming',
    e2s: Skill.e2sFunction(1.5),
    s2e: Skill.s2eFunction(1.5)
}

setup.skills.highHeels = {
    label: 'High Heels',
    e2s: Skill.e2sFunction(1.5),
    s2e: Skill.s2eFunction(1.5),
    image: 'pc/skills/highHeels.webp',
    description: 'The art of walking in shoes with high heels. This includes a physical component, as your feet get used to being forced into an unnatural pose. Also, you learn how to walk in high heels in a way that both looks well and goes easy on your feet. Finally, you learn little tricks, such as the clever use of plasters, silicone inserts and how to make even to most uncomfortable shoes bearable. The most effective way to increase this skill is to practice in slightly too high shoes in front of a mirror at your home, but just wearing them outdoors also increases the skill a little bit. Wearing too high heels will hurt your feet and you might be forced to rest if the pain gets unbearable. Wearing way too high heels might be impossible until your increase you skill further.',
    descibtionByLevel:{
        0: 'Your experience in walking in high heels is minimal to non-existing. You can wear no shoes with heels wihtout your feet hurting. Wearing 1 inch high heels gracefully is possible, but your feet would start to hurt after a while. 2 inches high heels are the highest shoes you\'d be able to wear, but your struggle to do so would be obvious.',
        1: 'You have walked in shoes with low heels a few times. You could wear 1 inch high heels the whole day long wihtout your feet hurting. Wearing 2 inches high heels gracefully is also possible, but your feet would start to hurt after a while. 3 inches high heels are the highest shoes you\'d be able to wear, but your struggle to do so would be obvious.',
        2: 'You could wear 2 inches high heels the whole day long wihtout your feet hurting. Wearing 3 inches high heels gracefully is also possible, but your feet would start to hurt after a while. 4 inches high heels are the highest shoes you\'d be able to wear, but your struggle to do so would be obvious.',
        3: 'You could wear 3 inches high heels the whole day long wihtout your feet hurting. Wearing 4 inches high heels gracefully is also possible, but your feet would start to hurt after a while. 5 inches high heels are the highest shoes you\'d be able to wear, but your struggle to do so would be obvious.',
        4: 'You are proficient at wearing high heels. You could wear 4 inches high heels the whole day long wihtout your feet hurting. Wearing 5 inches high heels gracefully is also possible, but your feet would start to hurt after a while. 6 inches high heels are the highest shoes you\'d be able to wear, but your struggle to do so would be obvious.',
        5: 'You are a specialist at wearing high heels. You could wear 4 inches high heels the whole day long wihtout your feet hurting. Wearing 5 inches high heels gracefully is also possible, but your feet would start to hurt after a while. 7 inches high heels are the highest shoes you\'d be able to wear, but your struggle to do so would be obvious.',
        6: 'You are a professional at wearing high heels. You could wear 5 inches high heels the whole day long wihtout your feet hurting. Wearing 6 inches high heels gracefully is also possible, but your feet would start to hurt after a while. 7 inches high heels are the highest shoes you\'d be able to wear, but your struggle to do so would be obvious.',
        7: 'You are a expert at wearing high heels. You could wear 6 inches high heels the whole day long wihtout your feet hurting. Wearing 7 inches high heels gracefully is also possible, but your feet would start to hurt after a while. You could wear even higher shoes, but your struggle to do so would be obvious.',
        8: 'You are a master at wearing high heels. You could wear 7 inches high heels the whole day long wihtout your feet hurting. You can wear even higher shoes gracefully, but your feet would start to hurt after a while.',
        9: 'You are a renowned master at wearing high heels. You could wear any shoes gracefully the whole day without your feet hurting.',
        10: 'You are a famous master at wearing high heels. You could wear any shoes more gracefully than almost everyone the whole day without your feet hurting.',
    }
}

setup.skills.iceskating = {
    label: 'Iceskating',
    hidden: true
}

setup.skills.inhibition = {
    label: 'Inhibition'
}

setup.skills.intelligence = {
    label: 'Intelligence',
    hidden: true
}

setup.skills.people = {
    label: 'People',
    hidden: true
}

setup.skills.perception = {
    label: 'Perception',
    hidden: true
}

setup.skills.persuasion = {
    label: 'Persuasion',
    hidden: true
}

setup.skills.reaction = {
    label: 'Reaction',
    hidden: true
}

setup.skills.spirit = {
    label: 'Spirit',
    hidden: true
}

setup.skills.strength = {
    label: 'Strength',
    hidden: true
}

setup.skills.vitality = {
    label: 'Vitality',
    hidden: true
}

setup.skills.webcam = {
    label: 'Webcam Girl',
    e2s: Skill.e2sFunction(1.5),
    s2e: Skill.s2eFunction(1.5)
}