MediaWiki:ClassSpellGroupOverrides.js: Difference between revisions
From EQOA Sandstorm Wiki
Jump to navigationJump to search
DevRenodor (talk | contribs) No edit summary |
DevRenodor (talk | contribs) No edit summary |
||
| Line 149: | Line 149: | ||
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" | |||
}, | |||
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; | ||
} | |||
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); | |||
spell | if (!pathLabel) return; | ||
spell.spellPath = | |||
classCode = getSpellClassCode(spell); | |||
classRules = pathLabelRules[classCode] || {}; | |||
path = classRules[pathLabel]; | |||
if (!path) return; | |||
spell.spellGroup = "ClassPath"; | |||
spell.spellPath = path; | |||
}); | }); | ||
| Line 179: | Line 312: | ||
document.querySelectorAll('[data-eqoa-spell-path-list]').forEach(function (box) { | document.querySelectorAll('[data-eqoa-spell-path-list]').forEach(function (box) { | ||
box.innerHTML = | box.innerHTML = | ||
'<div class="eqoa-spell-list__title">' + | '<div class="eqoa-spell-list__title">' + | ||
( | (box.getAttribute('data-spell-group') === 'ExemplarPath' ? 'Exemplar Path Choice' : 'Class Path Choice') + | ||
'</div>' + | '</div>' + | ||
'<div class="eqoa-spell-list__loading">Loading spells...</div>'; | '<div class="eqoa-spell-list__loading">Loading spells...</div>'; | ||
Revision as of 01:03, 5 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"
}
};
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"
},
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;
}
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);