-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHadesRandomizer.js
More file actions
209 lines (179 loc) · 9.15 KB
/
HadesRandomizer.js
File metadata and controls
209 lines (179 loc) · 9.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
const GAME_DATA = {
weapons: [
...["Zagreus", "Nemesis", "Poseidon", "Arthur"].map(a => ({ cat: 'Stygius', catV: 'Stygius, the Blade of the Underworld', type: 'Sword', aspect: a })),
...["Zagreus", "Achilles", "Hades", "Guan Yu"].map(a => ({ cat: 'Varatha', catV: 'Varatha, the Eternal Spear', type: 'Spear', aspect: a })),
...["Zagreus", "Chaos", "Zeus", "Beowulf"].map(a => ({ cat: 'Aegis', catV: 'Aegis, the Shield of Chaos', type: 'Shield', aspect: a })),
...["Zagreus", "Chiron", "Hera", "Rama"].map(a => ({ cat: 'Coronacht', catV: 'Coronacht, the Heart-Seeking Bow', type: 'Bow', aspect: a })),
...["Zagreus", "Talos", "Demeter", "Gilgamesh"].map(a => ({ cat: 'Twin Fists', catV: 'Twin Fists of Malphon', type: 'Fists', aspect: a })),
...["Zagreus", "Eris", "Hestia", "Lucifer"].map(a => ({ cat: 'Exagryph', catV: 'Exagryph, the Adamant Rail', type: 'Rail', aspect: a }))
],
companions: ["Battie", "Mort", "Rib", "Shady", "Fidi", "Antos"],
keepsakes: [
{ s: "Cerberus", v: "Cerberus' Old Spiked Collar" },
{ s: "Achilles", v: "Achilles' Myrmidon Bracer" },
{ s: "Nyx", v: "Nyx's Black Shawl" },
{ s: "Thanatos", v: "Thanatos' Pierced Butterfly" },
{ s: "Charon", v: "Charon's Bone Hourglass" },
{ s: "Hypnos", v: "Hypnos' Chthonic Coin Purse" },
{ s: "Megaera", v: "Megaera's Skull Earring" },
{ s: "Orpheus", v: "Orpheus' Distant Memory" },
{ s: "Dusa", v: "Dusa's Harpy Feather Duster" },
{ s: "Skelly", v: "Skelly's Lucky Tooth" },
{ s: "Zeus", v: "Zeus' Thunder Signet" },
{ s: "Poseidon", v: "Poseidon's Conch Shell" },
{ s: "Athena", v: "Athena's Owl Pendant" },
{ s: "Aphrodite", v: "Aphrodite's Eternal Rose" },
{ s: "Ares", v: "Ares' Blood-Filled Vial" },
{ s: "Artemis", v: "Artemis' Adamant Arrowhead" },
{ s: "Dionysus", v: "Dionysus' Overflowing cup" },
{ s: "Hermes", v: "Hermes' Lambent Plume" },
{ s: "Demeter", v: "Demeter's Frostbitten Horn" },
{ s: "Chaos", v: "Chaos' Cosmic Egg" },
{ s: "Sisyphus", v: "Sisyphus' Shattered Shackle" },
{ s: "Eurydice", v: "Eurydice's Evergreen Acorn" },
{ s: "Patroclus", v: "Patroclus' Broken Spearpoint" },
{ s: "Persephone", v: "Persephone's Pom Blossom" },
{ s: "Hades", v: "Hades' Sigil of the Dead" }
],
mirror: [
[{ s: "ShPr", v: "Shadow Presence" }, { s: "FiPr", v: "Fiery Presence" }],
[{ s: "ChVi", v: "Chthonic Vitality" }, { s: "DaRe", v: "Dark Regeneration" }],
[{ s: "DeDe", v: "Death Defiance" }, { s: "StDe", v: "Stubborn Defiance" }],
[{ s: "GrRe", v: "Greater Reflex" }, { s: "RuRe", v: "Ruthless Reflex" }],
[{ s: "BoBl", v: "Boiling Blood" }, { s: "AbBl", v: "Abyssal Blood" }],
[{ s: "InSo", v: "Infernal Soul" }, { s: "StSo", v: "Stygian Soul" }],
[{ s: "DePo", v: "Deep Pockets" }, { s: "GoTo", v: "Golden Touch" }],
[{ s: "ThSk", v: "Thick Skin" }, { s: "HiCo", v: "High Confidence" }],
[{ s: "PrSt", v: "Privileged Status" }, { s: "FaFa", v: "Family Favorite" }],
[{ s: "OlFa", v: "Olympian Favor" }, { s: "DaFo", v: "Dark Foresight" }],
[{ s: "GoPr", v: "Gods' Pride" }, { s: "GoLe", v: "Gods' Legacy" }],
[{ s: "FaAu", v: "Fated Authority" }, { s: "FaPe", v: "Fated Persuasion" }]
],
pact: [
{ v: "Hard Labor", s: "HL", m: 5 }, { v: "Lasting Consequences", s: "LC", m: 4 },
{ v: "Convenience Fee", s: "CF", m: 2 }, { v: "Jury Summons", s: "JS", m: 3 },
{ v: "Extreme Measures", s: "EM", m: 4 }, { v: "Calisthenics Program", s: "CP", m: 2 },
{ v: "Benefits Package", s: "BP", m: 2 }, { v: "Middle Management", s: "MM", m: 1 },
{ v: "Underworld Customs", s: "UC", m: 1 }, { v: "Forced Overtime", s: "FO", m: 2 },
{ v: "Heightened Security", s: "HS", m: 1 }, { v: "Routine Inspection", s: "RI", m: 4 },
{ v: "Damage Control", s: "DC", m: 2 }, { v: "Approval Process", s: "AP", m: 2 },
{ v: "Tight Deadline", s: "TD", m: 3 }
]
};
let currentRun = {
weapon: null,
keepsakes: [],
companion: null,
mirror: [],
pact: []
};
function initUI() {
const ws = document.getElementById('panel-weapons');
GAME_DATA.weapons.forEach((w, i) => {
ws.insertAdjacentHTML('beforeend', `<label><input type="checkbox" class="chk-wep" data-idx="${i}" checked> ${w.cat}: ${w.aspect}</label>`);
});
const ks = document.getElementById('panel-keepsakes');
GAME_DATA.keepsakes.forEach((k, i) => {
ks.insertAdjacentHTML('beforeend', `<label><input type="checkbox" class="chk-keep" data-idx="${i}" checked> ${k.s}</label>`);
});
const cs = document.getElementById('panel-companions');
GAME_DATA.companions.forEach(c => {
cs.insertAdjacentHTML('beforeend', `<label><input type="checkbox" class="chk-comp" value="${c}" checked> ${c}</label>`);
});
const ms = document.getElementById('panel-mirror');
GAME_DATA.mirror.forEach((m, i) => {
ms.insertAdjacentHTML('beforeend', `
<div class="mirror-row">
<label class="m-red"><input type="checkbox" id="mirror-${i}-red" checked> ${m[0].v}</label>
<label class="m-green"><input type="checkbox" id="mirror-${i}-green" checked> ${m[1].v}</label>
</div>
`);
});
const ps = document.getElementById('panel-pact');
GAME_DATA.pact.forEach((p, i) => {
ps.insertAdjacentHTML('beforeend', `
<label class="pact-row">
<input type="number" id="pact-${i}" value="${p.m}" min="0" max="${p.m}"> ${p.v}
</label>
`);
});
}
function randomize() {
const activeWeapons = Array.from(document.querySelectorAll('.chk-wep:checked')).map(cb => GAME_DATA.weapons[cb.dataset.idx]);
currentRun.weapon = activeWeapons[Math.floor(Math.random() * activeWeapons.length)] || null;
const activeKeepsakes = Array.from(document.querySelectorAll('.chk-keep:checked')).map(cb => GAME_DATA.keepsakes[cb.dataset.idx]);
currentRun.keepsakes = [];
let currentlyEquipped = null;
const bannedKeepsakes = new Set();
for (let i = 0; i < 4; i++) {
const validPool = activeKeepsakes.filter(k => !bannedKeepsakes.has(k.s));
if (validPool.length === 0) break;
const rIdx = Math.floor(Math.random() * validPool.length);
const picked = validPool[rIdx];
if (currentlyEquipped && picked.s !== currentlyEquipped.s) {
bannedKeepsakes.add(currentlyEquipped.s);
}
currentRun.keepsakes.push(picked);
currentlyEquipped = picked;
}
const activeComps = Array.from(document.querySelectorAll('.chk-comp:checked')).map(cb => cb.value);
currentRun.companion = activeComps[Math.floor(Math.random() * activeComps.length)] || null;
currentRun.mirror = GAME_DATA.mirror.map((row, i) => {
const red = document.getElementById(`mirror-${i}-red`).checked;
const green = document.getElementById(`mirror-${i}-green`).checked;
if (red && green) return Math.random() > 0.5 ? row[0] : row[1];
if (red) return row[0];
if (green) return row[1];
return null;
}).filter(Boolean);
const pactPool = [];
GAME_DATA.pact.forEach((p, i) => {
const maxVal = parseInt(document.getElementById(`pact-${i}`).value) || 0;
for (let j = 0; j < maxVal; j++) pactPool.push(p);
});
for (let i = pactPool.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[pactPool[i], pactPool[j]] = [pactPool[j], pactPool[i]];
}
currentRun.pact = pactPool;
renderRun();
}
function renderRun() {
const isVerbose = document.getElementById('opt-verbose').checked;
let wRes = 'None';
if (currentRun.weapon) {
wRes = isVerbose
? `${currentRun.weapon.catV}: Aspect of ${currentRun.weapon.aspect}`
: `${currentRun.weapon.type}: ${currentRun.weapon.aspect}`;
}
const kRes = currentRun.keepsakes.map(k => isVerbose ? k.v : k.s).join(', ') || 'None';
const cRes = currentRun.companion || 'None';
const mRes = currentRun.mirror.map(m => isVerbose ? m.v : m.s).join(', ') || 'None';
const pRes = currentRun.pact.map(p => isVerbose ? p.v : p.s).join(', ') || 'None';
document.getElementById('res-weapon').textContent = wRes;
document.getElementById('res-keepsakes').textContent = kRes;
document.getElementById('res-companion').textContent = cRes;
document.getElementById('res-mirror').textContent = mRes;
document.getElementById('res-pact').textContent = pRes;
}
document.addEventListener('DOMContentLoaded', () => {
initUI();
randomize();
document.getElementById('opt-verbose').addEventListener('change', renderRun);
document.getElementById('btn-randomize').addEventListener('click', randomize);
document.getElementById('btn-checkall').addEventListener('click', () => {
document.querySelectorAll('.panel-body input[type="checkbox"]').forEach(cb => cb.checked = true);
});
document.getElementById('btn-uncheckall').addEventListener('click', () => {
document.querySelectorAll('.panel-body input[type="checkbox"]').forEach(cb => cb.checked = false);
});
document.querySelectorAll('.header-buttons button').forEach(btn => {
btn.addEventListener('click', (e) => e.stopPropagation());
});
document.getElementById('btn-pact-reset').addEventListener('click', () => {
GAME_DATA.pact.forEach((p, i) => document.getElementById(`pact-${i}`).value = p.m);
});
document.getElementById('btn-pact-zero').addEventListener('click', () => {
GAME_DATA.pact.forEach((p, i) => document.getElementById(`pact-${i}`).value = 0);
});
});