Skip to content

Commit 071cacb

Browse files
committed
WORKDAMMIT
1 parent 290aec3 commit 071cacb

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

script.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ function randomizeServant(index) {
154154
//simulation button function:
155155
function saveParticipantsAndStartSimulation() {
156156
let masterContainers = document.querySelectorAll(".master");
157+
let servantSelections = document.querySelectorAll(".servant-selection");
157158
let participants = [];
158159

159160
masterContainers.forEach((masterContainer, index) => {
@@ -163,15 +164,9 @@ function saveParticipantsAndStartSimulation() {
163164
let name = nameInput ? nameInput.value.trim() || `Master ${index + 1}` : `Master ${index + 1}`;
164165
let pictureUrl = pictureEl ? pictureEl.src : "";
165166

166-
// ✅ Find the NEXT .servant-selection block after the master container
167-
let servantSelectionBlock = masterContainer.nextElementSibling;
168-
let servantDropdown = null;
169-
170-
if (servantSelectionBlock && servantSelectionBlock.classList.contains("servant-selection")) {
171-
servantDropdown = servantSelectionBlock.querySelector(".servant-select");
172-
} else {
173-
console.warn(`No .servant-selection found for master index ${index}`);
174-
}
167+
// ✅ Get the servant-selection block at the same index
168+
let servantSelectionBlock = servantSelections[index];
169+
let servantDropdown = servantSelectionBlock ? servantSelectionBlock.querySelector(".servant-select") : null;
175170

176171
let servantId = "Unknown";
177172
let servantName = "Unknown";
@@ -190,6 +185,8 @@ function saveParticipantsAndStartSimulation() {
190185
} else {
191186
console.warn(`No selected option in servant dropdown for master index ${index}`);
192187
}
188+
} else {
189+
console.warn(`No servant dropdown found for master index ${index}`);
193190
}
194191

195192
let masterData = {

0 commit comments

Comments
 (0)