MediaWiki:ClassSpellGroupOverrides.js: Difference between revisions

From EQOA Sandstorm Wiki
Jump to navigationJump to search
No edit summary
No edit summary
 
(12 intermediate revisions by the same user not shown)
Line 1: Line 1:
window.EQOA_SPELL_GROUP_OVERRIDES = {
window.EQOA_SPELL_GROUP_OVERRIDES = {
  "Shining Bastion": {
    "Shining Bastion": {
    "spellGroup": "ClassPath",
        spellGroup: "ClassPath",
    "spellPath": "1"
        spellPath: "1"
  },
    },
{
    "Gleaming Bastion": {
  "Gleaming Bastion": {
        spellGroup: "ClassPath",
    "spellGroup": "ClassPath",
        spellPath: "1"
    "spellPath": "1"
    },
  },
    "Hallowed Bastion": {
{
        spellGroup: "ClassPath",
  "Hallowed Bastion": {
        spellPath: "1"
    "spellGroup": "ClassPath",
    },
    "spellPath": "1"
    "Sacred Bastion": {
  },
        spellGroup: "ClassPath",
{
        spellPath: "1"
  "Sacred Bastion": {
    },
    "spellGroup": "ClassPath",
    "Blessed Bastion": {
    "spellPath": "1"
        spellGroup: "ClassPath",
  },
        spellPath: "1"
{
    },
  "Blessed Bastion": {
    "Ozmo's Careful Teasing": {
    "spellGroup": "ClassPath",
        spellGroup: "ClassPath",
    "spellPath": "1"
        spellPath: "1"
  },
    },
{
    "Ozmo's Infuriating Jeer": {
  "Ozmo's Careful Teasing": {
        spellGroup: "ClassPath",
    "spellGroup": "ClassPath",
        spellPath: "1"
    "spellPath": "1"
     },
  },
  "Ozmo's Infuriating Jeer": {
    "spellGroup": "ClassPath",
    "spellPath": "1"
  },
  "Celestial Light": {
    "spellGroup": "ClassPath",
     "spellPath": "1"
  },


    "Clay Barrier": {
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    "Marble Barrier": {
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    "Granite Barrier": {
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    "Iron Barrier": {
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    "Steel Barrier": {
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    "Talimus's Adamantine Barrier": {
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    "Talimus's Diamond Barrier": {
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    "Celestial Light": {
        spellGroup: "ClassPath",
        spellPath: "both"
    },


    "Alesthenies' Mercy": {
        spellGroup: "ExemplarPath",
        spellPath: "1"
    },
    "Zarakiel's Blessing": {
        spellGroup: "ExemplarPath",
        spellPath: "2"
    },
    "Zarakiel's Favor": {
        spellGroup: "ExemplarPath",
        spellPath: "2"
    },
    "Zarakiel's Fervor": {
        spellGroup: "ExemplarPath",
        spellPath: "2"
    },
    "Zarakiel's Touch": {
        spellGroup: "ExemplarPath",
        spellPath: "2"
    },


  "Clay Barrier": {
    "Power Dance": {
    "spellGroup": "ClassPath",
        spellGroup: "ClassPath",
    "spellPath": "2"
        spellPath: "1"
  },
    },
  "Marble Barrier": {
    "Power Twist": {
    "spellGroup": "ClassPath",
        spellGroup: "ClassPath",
    "spellPath": "2"
        spellPath: "1"
  },
    },
  "Granite Barrier": {
    "Power Jig": {
    "spellGroup": "ClassPath",
        spellGroup: "ClassPath",
    "spellPath": "2"
        spellPath: "1"
  },
    },
  "Iron Barrier": {
    "Power Vibe": {
    "spellGroup": "ClassPath",
        spellGroup: "ClassPath",
    "spellPath": "2"
        spellPath: "1"
  },
    },
  "Steel Barrier": {
    "Power Groove": {
    "spellGroup": "ClassPath",
        spellGroup: "ClassPath",
    "spellPath": "2"
        spellPath: "1"
  },
    },
  "Talimus's Adamantine Barrier": {
    "Celedonicus' Grand Finale": {
    "spellGroup": "ClassPath",
        spellGroup: "ClassPath",
    "spellPath": "2"
        spellPath: "1"
  },
    },
  "Talimus's Diamond Barrier": {
    "Celedonicus' Inspiring Performance": {
    "spellGroup": "ClassPath",
        spellGroup: "ClassPath",
    "spellPath": "2"
        spellPath: "1"
  },
     },
  "Celestial Light": {
    "spellGroup": "ClassPath",
     "spellPath": "2"
  },


    "Sweeping Flurry": {
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    "Flowing Flurry": {
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    "Fluid Flurry": {
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    "Decisive Flurry": {
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    "Elegant Flurry": {
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    "Pulsing Flurry": {
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    "Staccato Flurry": {
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    "Pandemonium": {
        spellGroup: "ClassPath",
        spellPath: "both"
    },
    "One Hundred Hand Punch I": {
        spellGroup: "ExemplarPath",
        spellPath: "1"
    },
    "Fierce Strike: Flowing Form": {
        spellGroup: "ExemplarPath",
        spellPath: "2"
    },
};


  "Alesthenies' Mercy": {
window.EQOA_EXTRA_PATH_SPELLS = [
     "spellGroup": "ExemplarPath",
    {
     "spellPath": "1"
        name: "Frozen Mark",
  },
        description: "Pet Path Ability - Pet Buff INT and Offensive Proc",
  "Zarakiel's Blessing": {
        classes: ["MAG"],
     "spellGroup": "ExemplarPath",
        classNames: ["Magician"],
     "spellPath": "2"
        level: 20,
  },
        spellGroup: "ClassPath",
     "Zarakiel's Favor": {
        spellPath: "1"
     "spellGroup": "ExemplarPath",
    },
     "spellPath": "2"
    {
  },
        name: "Burning Mark",
  "Zarakiel's Fervor": {
        description: "Pet Path Ability - Pet Buff INT abd Offensive Proc",
  "spellGroup": "ExemplarPath",
        classes: ["MAG"],
  "spellPath": "2"
        classNames: ["Magician"],
  },
        level: 30,
  "Zarakiel's Touch": {
        spellGroup: "ClassPath",
  "spellGroup": "ExemplarPath",
        spellPath: "1"
  "spellPath": "2"
    },
  }
     {
}
        name: "Earthen Mark",
};
        description: "Pet Path Ability - Pet Buff INT and Offensive Proc",
        classes: ["MAG"],
        classNames: ["Magician"],
        level: 40,
        spellGroup: "ClassPath",
        spellPath: "1"
    },
     {
        name: "Elemental Mark",
        description: "Pet Path Ability - Pet Buff INT and Offensive Proc",
        classes: ["MAG"],
        classNames: ["Magician"],
        level: 49,
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    {
        name: "Shocking Mark",
        description: "Pet Path Ability - Pet Buff INT and Offensive Proc",
        classes: ["MAG"],
        classNames: ["Magician"],
        level: 49,
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    {
        name: "Magi'Kot's Good Breeding",
        description: "Pet Path Ability - Pet Buff INT and Offensive Proc",
        classes: ["MAG"],
        classNames: ["Magician"],
        level: 60,
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    {
        name: "Magi'Kot's Sacrificial Training",
        description: "Pet Path Ability - Pet Buff INT and Offensive Proc",
        classes: ["MAG"],
        classNames: ["Magician"],
        level: 60,
        spellGroup: "ClassPath",
        spellPath: "1"
    },
 
     {
        name: "Summon: Lesser Stone",
        description: "Stone Path Ability",
        classes: ["MAG"],
        classNames: ["Magician"],
        level: 20,
        spellGroup: "ClassPath",
        spellPath: "2"
    },
     {
        name: "Summon: Stone",
        description: "Stone Path Ability",
        classes: ["MAG"],
        classNames: ["Magician"],
        level: 30,
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    {
        name: "Summon: Greater Stone",
        description: "Stone Path Ability",
        classes: ["MAG"],
        classNames: ["Magician"],
        level: 40,
        spellGroup: "ClassPath",
        spellPath: "2"
    },
     {
        name: "Summon: Superior Stone",
        description: "Stone Path Ability",
        classes: ["MAG"],
        classNames: ["Magician"],
        level: 49,
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    {
        name: "Summon: Grand Stone",
        description: "Stone Path Ability",
        classes: ["MAG"],
        classNames: ["Magician"],
        level: 49,
        spellGroup: "ClassPath",
        spellPath: "2"
     },
    {
        name: "Summon: Ancient Stone",
        description: "Stone Path Ability",
        classes: ["MAG"],
        classNames: ["Magician"],
        level: 60,
        spellGroup: "ClassPath",
        spellPath: "2"
    },
     {
        name: "Summon: Primeval Stone",
        description: "Stone Path Ability",
        classes: ["MAG"],
        classNames: ["Magician"],
        level: 60,
        spellGroup: "ClassPath",
        spellPath: "2"
    },
 
    {
        name: "Spiritual Guide",
        description: "Pet Path - SHA Pet Summon",
        classes: ["SHA"],
        classNames: ["Shaman"],
        level: 20,
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    {
        name: "Spiritual Guard",
        description: "Pet Path - SHA Pet Summon",
        classes: ["SHA"],
        classNames: ["Shaman"],
        level: 30,
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    {
        name: "Spiritual Hunter",
        description: "Pet Path - SHA Pet Summon",
        classes: ["SHA"],
        classNames: ["Shaman"],
        level: 40,
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    {
        name: "Spiritual Slayer",
        description: "Pet Path - SHA Pet Summon",
        classes: ["SHA"],
        classNames: ["Shaman"],
        level: 49,
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    {
        name: "Spiritual Warrior",
        description: "Pet Path - SHA Pet Summon",
        classes: ["SHA"],
        classNames: ["Shaman"],
        level: 49,
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    {
        name: "Yalgima's Fearsome Companion",
        description: "Pet Path - SHA Pet Summon",
        classes: ["SHA"],
        classNames: ["Shaman"],
        level: 60,
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    {
        name: "Yalgima's Menacing Defender",
        description: "Pet Path - SHA Pet Summon",
        classes: ["SHA"],
        classNames: ["Shaman"],
        level: 60,
        spellGroup: "ClassPath",
        spellPath: "1"
    }
];


function applyEqoaSpellGroupOverrides() {
function applyEqoaSpellGroupOverrides() {
     var spells = window.EQOA_GENERATED_SPELLS || [];
     var spells = window.EQOA_GENERATED_SPELLS || [];
     var overrides = window.EQOA_SPELL_GROUP_OVERRIDES || {};
     var overrides = window.EQOA_SPELL_GROUP_OVERRIDES || {};
    var pathLabelRules = {
        ALC: {
            "knack": "1",
            "aoe": "2",
            "epic aoe": "2",
            "epicaoe": "2"
        },
        BRD: {
            "power": "1",
            "combat": "2"
        },
        CL: {
            "heal": "1",
            "epic heal": "1",
            "epicheal": "1",
            "resist": "2",
            "epic resist": "2",
            "epicresist": "2",
            "aoe epic resist": "2",
            "aoeepic resist": "2"
        },
        DRD: {
            "heal": "1",
            "epic heal": "1",
            "epicheal": "1",
            "flame": "2",
            "epic flame": "2",
            "epicflame": "2"
        },
        ENC: {
            "mind": "1",
            "epic mind": "1",
            "epicmind": "1",
            "boon": "2",
            "epic boon": "2",
            "epicboon": "2"
        },
        MAG: {
            "pet": "1",
            "stone": "2"
        },
        MNK: {
            "stance": "1",
            "strike": "2"
        },
        NEC: {
            "blood": "1",
            "power": "2"
        },
        PAL: {
            "taunt": "1"
        },
        RAN: {
            "bow": "1",
            "blade": "2"
        },
        RGE: {
            "avoidance": "1",
            "wound": "2"
        },
        SHA: {
            "pet": "1",
            "debuff": "2"
        },
        SK: {
            "taunt": "1",
            "blood": "2"
        },
        WAR: {
            "taunt": "1",
            "health": "2"
        },
        WIZ: {
            "power": "1",
            "clash": "2"
        }
    };


     if (!spells.length) {
     if (!spells.length) {
         setTimeout(applyEqoaSpellGroupOverrides, 250);
         setTimeout(applyEqoaSpellGroupOverrides, 250);
         return;
         return;
    }
    (window.EQOA_EXTRA_PATH_SPELLS || []).forEach(function (extraSpell) {
        var exists = spells.some(function (spell) {
            return String(spell.name || '').toLowerCase() === String(extraSpell.name || '').toLowerCase();
        });
        if (!exists) {
            spells.push(extraSpell);
        }
    });
    function normalizePathLabel(value) {
        return String(value || '')
            .toLowerCase()
            .replace(/broken/g, '')
            .replace(/choice/g, '')
            .replace(/reward/g, '')
            .replace(/spell/g, '')
            .replace(/ability/g, '')
            .replace(/path/g, '')
            .replace(/[^a-z0-9]+/g, ' ')
            .replace(/\s+/g, ' ')
            .trim();
    }
    function getSpellClassCode(spell) {
        var classes = spell.classes || [];
        if (!classes.length) return '';
        return String(classes[0] || '').toUpperCase();
    }
    function getPathLabelFromDescription(description) {
        var text = String(description || '');
        var match;
        match = text.match(/([A-Za-z ]+?)\s+Broken\s+Path/i);
        if (match && match[1]) return normalizePathLabel(match[1]);
        match = text.match(/([A-Za-z ]+?)\s+Path/i);
        if (match && match[1]) return normalizePathLabel(match[1]);
        match = text.match(/60\s+Epic\s+([A-Za-z ]+?)\s+Path/i);
        if (match && match[1]) return normalizePathLabel(match[1]);
        return '';
     }
     }


     spells.forEach(function (spell) {
     spells.forEach(function (spell) {
         var override = overrides[spell.name];
         var override = overrides[spell.name];
        var classCode;
        var pathLabel;
        var classRules;
        var path;
        if (override) {
            spell.spellGroup = override.spellGroup || spell.spellGroup || 'Base';
            spell.spellPath = override.spellPath || spell.spellPath || '';
            return;
        }
        pathLabel = getPathLabelFromDescription(spell.description);
        if (!pathLabel) return;


         if (!override) return;
         classCode = getSpellClassCode(spell);
        classRules = pathLabelRules[classCode] || {};
        path = classRules[pathLabel];


         spell.spellGroup = override.spellGroup || spell.spellGroup || 'Base';
        if (!path) return;
         spell.spellPath = override.spellPath || spell.spellPath || '';
 
         spell.spellGroup = "ClassPath";
         spell.spellPath = path;
     });
     });


     window.EQOA_SPELL_GROUP_OVERRIDES_APPLIED = true;
     window.EQOA_SPELL_GROUP_OVERRIDES_APPLIED = true;


     if (typeof initEqoaSpellLists === 'function') {
     document.querySelectorAll('[data-eqoa-spell-list]').forEach(function (box) {
        document.querySelectorAll('[data-eqoa-spell-list]').forEach(function (box) {
        box.classList.remove('eqoa-spell-list-ready');
            box.classList.remove('eqoa-spell-list-ready');
 
        box.querySelectorAll('.eqoa-spell-toolbar, .eqoa-spell-list-table, .eqoa-spell-empty').forEach(function (el) {
            el.remove();
         });
         });


        if (!box.querySelector('.eqoa-spell-list__loading')) {
            box.insertAdjacentHTML('beforeend', '<div class="eqoa-spell-list__loading">Loading spells...</div>');
        }
    });
    document.querySelectorAll('[data-eqoa-spell-path-list]').forEach(function (box) {
        box.innerHTML =
            '<div class="eqoa-spell-list__title">' +
                (box.getAttribute('data-spell-group') === 'ExemplarPath' ? 'Exemplar Path Choice' : 'Class Path Choice') +
            '</div>' +
            '<div class="eqoa-spell-list__loading">Loading spells...</div>';
    });
    if (typeof initEqoaSpellLists === 'function') {
         initEqoaSpellLists();
         initEqoaSpellLists();
     }
     }
Line 134: Line 545:
setTimeout(applyEqoaSpellGroupOverrides, 500);
setTimeout(applyEqoaSpellGroupOverrides, 500);
setTimeout(applyEqoaSpellGroupOverrides, 1500);
setTimeout(applyEqoaSpellGroupOverrides, 1500);
setTimeout(applyEqoaSpellGroupOverrides, 3000);

Latest revision as of 01:18, 6 June 2026

window.EQOA_SPELL_GROUP_OVERRIDES = {
    "Shining Bastion": {
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    "Gleaming Bastion": {
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    "Hallowed Bastion": {
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    "Sacred Bastion": {
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    "Blessed Bastion": {
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    "Ozmo's Careful Teasing": {
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    "Ozmo's Infuriating Jeer": {
        spellGroup: "ClassPath",
        spellPath: "1"
    },

    "Clay Barrier": {
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    "Marble Barrier": {
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    "Granite Barrier": {
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    "Iron Barrier": {
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    "Steel Barrier": {
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    "Talimus's Adamantine Barrier": {
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    "Talimus's Diamond Barrier": {
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    "Celestial Light": {
        spellGroup: "ClassPath",
        spellPath: "both"
    },

    "Alesthenies' Mercy": {
        spellGroup: "ExemplarPath",
        spellPath: "1"
    },
    "Zarakiel's Blessing": {
        spellGroup: "ExemplarPath",
        spellPath: "2"
    },
    "Zarakiel's Favor": {
        spellGroup: "ExemplarPath",
        spellPath: "2"
    },
    "Zarakiel's Fervor": {
        spellGroup: "ExemplarPath",
        spellPath: "2"
    },
    "Zarakiel's Touch": {
        spellGroup: "ExemplarPath",
        spellPath: "2"
    },

    "Power Dance": {
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    "Power Twist": {
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    "Power Jig": {
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    "Power Vibe": {
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    "Power Groove": {
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    "Celedonicus' Grand Finale": {
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    "Celedonicus' Inspiring Performance": {
        spellGroup: "ClassPath",
        spellPath: "1"
    },

    "Sweeping Flurry": {
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    "Flowing Flurry": {
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    "Fluid Flurry": {
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    "Decisive Flurry": {
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    "Elegant Flurry": {
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    "Pulsing Flurry": {
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    "Staccato Flurry": {
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    "Pandemonium": {
        spellGroup: "ClassPath",
        spellPath: "both"
    },
    "One Hundred Hand Punch I": {
        spellGroup: "ExemplarPath",
        spellPath: "1"
    },
    "Fierce Strike: Flowing Form": {
        spellGroup: "ExemplarPath",
        spellPath: "2"
    },
};

window.EQOA_EXTRA_PATH_SPELLS = [
    {
        name: "Frozen Mark",
        description: "Pet Path Ability - Pet Buff INT and Offensive Proc",
        classes: ["MAG"],
        classNames: ["Magician"],
        level: 20,
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    {
        name: "Burning Mark",
        description: "Pet Path Ability - Pet Buff INT abd Offensive Proc",
        classes: ["MAG"],
        classNames: ["Magician"],
        level: 30,
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    {
        name: "Earthen Mark",
        description: "Pet Path Ability - Pet Buff INT and Offensive Proc",
        classes: ["MAG"],
        classNames: ["Magician"],
        level: 40,
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    {
        name: "Elemental Mark",
        description: "Pet Path Ability - Pet Buff INT and Offensive Proc",
        classes: ["MAG"],
        classNames: ["Magician"],
        level: 49,
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    {
        name: "Shocking Mark",
        description: "Pet Path Ability - Pet Buff INT and Offensive Proc",
        classes: ["MAG"],
        classNames: ["Magician"],
        level: 49,
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    {
        name: "Magi'Kot's Good Breeding",
        description: "Pet Path Ability - Pet Buff INT and Offensive Proc",
        classes: ["MAG"],
        classNames: ["Magician"],
        level: 60,
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    {
        name: "Magi'Kot's Sacrificial Training",
        description: "Pet Path Ability - Pet Buff INT and Offensive Proc",
        classes: ["MAG"],
        classNames: ["Magician"],
        level: 60,
        spellGroup: "ClassPath",
        spellPath: "1"
    },

    {
        name: "Summon: Lesser Stone",
        description: "Stone Path Ability",
        classes: ["MAG"],
        classNames: ["Magician"],
        level: 20,
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    {
        name: "Summon: Stone",
        description: "Stone Path Ability",
        classes: ["MAG"],
        classNames: ["Magician"],
        level: 30,
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    {
        name: "Summon: Greater Stone",
        description: "Stone Path Ability",
        classes: ["MAG"],
        classNames: ["Magician"],
        level: 40,
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    {
        name: "Summon: Superior Stone",
        description: "Stone Path Ability",
        classes: ["MAG"],
        classNames: ["Magician"],
        level: 49,
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    {
        name: "Summon: Grand Stone",
        description: "Stone Path Ability",
        classes: ["MAG"],
        classNames: ["Magician"],
        level: 49,
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    {
        name: "Summon: Ancient Stone",
        description: "Stone Path Ability",
        classes: ["MAG"],
        classNames: ["Magician"],
        level: 60,
        spellGroup: "ClassPath",
        spellPath: "2"
    },
    {
        name: "Summon: Primeval Stone",
        description: "Stone Path Ability",
        classes: ["MAG"],
        classNames: ["Magician"],
        level: 60,
        spellGroup: "ClassPath",
        spellPath: "2"
    },

    {
        name: "Spiritual Guide",
        description: "Pet Path - SHA Pet Summon",
        classes: ["SHA"],
        classNames: ["Shaman"],
        level: 20,
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    {
        name: "Spiritual Guard",
        description: "Pet Path - SHA Pet Summon",
        classes: ["SHA"],
        classNames: ["Shaman"],
        level: 30,
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    {
        name: "Spiritual Hunter",
        description: "Pet Path - SHA Pet Summon",
        classes: ["SHA"],
        classNames: ["Shaman"],
        level: 40,
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    {
        name: "Spiritual Slayer",
        description: "Pet Path - SHA Pet Summon",
        classes: ["SHA"],
        classNames: ["Shaman"],
        level: 49,
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    {
        name: "Spiritual Warrior",
        description: "Pet Path - SHA Pet Summon",
        classes: ["SHA"],
        classNames: ["Shaman"],
        level: 49,
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    {
        name: "Yalgima's Fearsome Companion",
        description: "Pet Path - SHA Pet Summon",
        classes: ["SHA"],
        classNames: ["Shaman"],
        level: 60,
        spellGroup: "ClassPath",
        spellPath: "1"
    },
    {
        name: "Yalgima's Menacing Defender",
        description: "Pet Path - SHA Pet Summon",
        classes: ["SHA"],
        classNames: ["Shaman"],
        level: 60,
        spellGroup: "ClassPath",
        spellPath: "1"
    }
];

function applyEqoaSpellGroupOverrides() {
    var spells = window.EQOA_GENERATED_SPELLS || [];
    var overrides = window.EQOA_SPELL_GROUP_OVERRIDES || {};

    var pathLabelRules = {
        ALC: {
            "knack": "1",
            "aoe": "2",
            "epic aoe": "2",
            "epicaoe": "2"
        },
        BRD: {
            "power": "1",
            "combat": "2"
        },
        CL: {
            "heal": "1",
            "epic heal": "1",
            "epicheal": "1",
            "resist": "2",
            "epic resist": "2",
            "epicresist": "2",
            "aoe epic resist": "2",
            "aoeepic resist": "2"
        },
        DRD: {
            "heal": "1",
            "epic heal": "1",
            "epicheal": "1",
            "flame": "2",
            "epic flame": "2",
            "epicflame": "2"
        },
        ENC: {
            "mind": "1",
            "epic mind": "1",
            "epicmind": "1",
            "boon": "2",
            "epic boon": "2",
            "epicboon": "2"
        },
        MAG: {
            "pet": "1",
            "stone": "2"
        },
        MNK: {
            "stance": "1",
            "strike": "2"
        },
        NEC: {
            "blood": "1",
            "power": "2"
        },
        PAL: {
            "taunt": "1"
        },
        RAN: {
            "bow": "1",
            "blade": "2"
        },
        RGE: {
            "avoidance": "1",
            "wound": "2"
        },
        SHA: {
            "pet": "1",
            "debuff": "2"
        },
        SK: {
            "taunt": "1",
            "blood": "2"
        },
        WAR: {
            "taunt": "1",
            "health": "2"
        },
        WIZ: {
            "power": "1",
            "clash": "2"
        }
    };

    if (!spells.length) {
        setTimeout(applyEqoaSpellGroupOverrides, 250);
        return;
    }

    (window.EQOA_EXTRA_PATH_SPELLS || []).forEach(function (extraSpell) {
        var exists = spells.some(function (spell) {
            return String(spell.name || '').toLowerCase() === String(extraSpell.name || '').toLowerCase();
        });

        if (!exists) {
            spells.push(extraSpell);
        }
    });

    function normalizePathLabel(value) {
        return String(value || '')
            .toLowerCase()
            .replace(/broken/g, '')
            .replace(/choice/g, '')
            .replace(/reward/g, '')
            .replace(/spell/g, '')
            .replace(/ability/g, '')
            .replace(/path/g, '')
            .replace(/[^a-z0-9]+/g, ' ')
            .replace(/\s+/g, ' ')
            .trim();
    }

    function getSpellClassCode(spell) {
        var classes = spell.classes || [];

        if (!classes.length) return '';

        return String(classes[0] || '').toUpperCase();
    }

    function getPathLabelFromDescription(description) {
        var text = String(description || '');
        var match;

        match = text.match(/([A-Za-z ]+?)\s+Broken\s+Path/i);
        if (match && match[1]) return normalizePathLabel(match[1]);

        match = text.match(/([A-Za-z ]+?)\s+Path/i);
        if (match && match[1]) return normalizePathLabel(match[1]);

        match = text.match(/60\s+Epic\s+([A-Za-z ]+?)\s+Path/i);
        if (match && match[1]) return normalizePathLabel(match[1]);

        return '';
    }

    spells.forEach(function (spell) {
        var override = overrides[spell.name];
        var classCode;
        var pathLabel;
        var classRules;
        var path;

        if (override) {
            spell.spellGroup = override.spellGroup || spell.spellGroup || 'Base';
            spell.spellPath = override.spellPath || spell.spellPath || '';
            return;
        }

        pathLabel = getPathLabelFromDescription(spell.description);

        if (!pathLabel) return;

        classCode = getSpellClassCode(spell);
        classRules = pathLabelRules[classCode] || {};
        path = classRules[pathLabel];

        if (!path) return;

        spell.spellGroup = "ClassPath";
        spell.spellPath = path;
    });

    window.EQOA_SPELL_GROUP_OVERRIDES_APPLIED = true;

    document.querySelectorAll('[data-eqoa-spell-list]').forEach(function (box) {
        box.classList.remove('eqoa-spell-list-ready');

        box.querySelectorAll('.eqoa-spell-toolbar, .eqoa-spell-list-table, .eqoa-spell-empty').forEach(function (el) {
            el.remove();
        });

        if (!box.querySelector('.eqoa-spell-list__loading')) {
            box.insertAdjacentHTML('beforeend', '<div class="eqoa-spell-list__loading">Loading spells...</div>');
        }
    });

    document.querySelectorAll('[data-eqoa-spell-path-list]').forEach(function (box) {
        box.innerHTML =
            '<div class="eqoa-spell-list__title">' +
                (box.getAttribute('data-spell-group') === 'ExemplarPath' ? 'Exemplar Path Choice' : 'Class Path Choice') +
            '</div>' +
            '<div class="eqoa-spell-list__loading">Loading spells...</div>';
    });

    if (typeof initEqoaSpellLists === 'function') {
        initEqoaSpellLists();
    }

    if (typeof initEqoaSpellPathLists === 'function') {
        initEqoaSpellPathLists();
    }
}

mw.hook('wikipage.content').add(applyEqoaSpellGroupOverrides);
document.addEventListener('DOMContentLoaded', applyEqoaSpellGroupOverrides);
setTimeout(applyEqoaSpellGroupOverrides, 500);
setTimeout(applyEqoaSpellGroupOverrides, 1500);
setTimeout(applyEqoaSpellGroupOverrides, 3000);