/**
 * SkillSystem — thin wrapper around ContentLoader for skill definitions.
 * Player state is managed in-memory here.
 */
class SkillSystem {
    constructor(contentLoader) {
        this.loader      = contentLoader;
        this.playerSkills = new Map(); // userId -> player data
    }

    getAllSkills()            { return this.loader.getAllSkills(); }
    getSkill(id)             { return this.loader.getSkill(id); }
    getSkillsByCategory(cat) { return this.loader.getSkillsByCategory(cat); }

    initializePlayerData(userId) {
        if (this.playerSkills.has(userId)) return this.playerSkills.get(userId);
        const defaultUnlocked = this.loader.getAllSkills()
            .filter(s => s.defaultUnlocked)
            .map(s => s.id);
        const skills = {};
        for (const id of defaultUnlocked) skills[id] = { level: 1, experience: 0 };
        const data = { skillPoints: 0, skills, unlockedSkills: new Set(defaultUnlocked) };
        this.playerSkills.set(userId, data);
        return data;
    }

    getPlayerSkills(userId)  { return this.initializePlayerData(userId); }
}
module.exports = SkillSystem;
