Block joining locked groups and fall back to the bench when none are open
The Wunschgruppe picker let members select a locked group, and the signup endpoint didn't check locked_groups at all, so the wish could still go through. Locked groups are now passed to the frontend and rendered disabled with a lock icon, and the server rejects a locked group the same way it already rejects a role-capped one. When every group is locked (or the raid has none), the signup is now assigned straight to the Ersatzbank instead of relying on the bot's own auto-assign to skip locked groups. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
b839146219
commit
73b670a305
4 changed files with 62 additions and 13 deletions
|
|
@ -735,6 +735,19 @@ input:focus, select:focus, textarea:focus {
|
||||||
box-shadow: 0 0 0 1px rgba(201, 162, 39, 0.4);
|
box-shadow: 0 0 0 1px rgba(201, 162, 39, 0.4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.group-picker-option.locked,
|
||||||
|
.group-picker-option:disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: not-allowed;
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.group-picker-option.locked:hover,
|
||||||
|
.group-picker-option:disabled:hover {
|
||||||
|
border-color: var(--border);
|
||||||
|
transform: none;
|
||||||
|
}
|
||||||
|
|
||||||
/* Grid-Zellen sind gleich breit (1fr), aber Buttons schrumpfen sich sonst
|
/* Grid-Zellen sind gleich breit (1fr), aber Buttons schrumpfen sich sonst
|
||||||
ueber die globale "button"-Regel auf ihre Textbreite (width: fit-content)
|
ueber die globale "button"-Regel auf ihre Textbreite (width: fit-content)
|
||||||
und wirken dadurch unterschiedlich gross - deshalb hier explizit 100%. */
|
und wirken dadurch unterschiedlich gross - deshalb hier explizit 100%. */
|
||||||
|
|
|
||||||
|
|
@ -23,18 +23,23 @@
|
||||||
var selectedClass = null;
|
var selectedClass = null;
|
||||||
var selectedGroup = null; // null = automatisch zuteilen
|
var selectedGroup = null; // null = automatisch zuteilen
|
||||||
|
|
||||||
function makeGroupButton(label, value, isSelected) {
|
function makeGroupButton(label, value, isSelected, isLocked) {
|
||||||
var btn = document.createElement('button');
|
var btn = document.createElement('button');
|
||||||
btn.type = 'button';
|
btn.type = 'button';
|
||||||
btn.className = 'group-picker-option' + (isSelected ? ' selected' : '');
|
btn.className = 'group-picker-option' + (isSelected ? ' selected' : '') + (isLocked ? ' locked' : '');
|
||||||
btn.textContent = label;
|
btn.textContent = isLocked ? label + ' 🔒' : label;
|
||||||
btn.setAttribute('data-group', value === null ? '' : String(value));
|
btn.setAttribute('data-group', value === null ? '' : String(value));
|
||||||
btn.addEventListener('click', function () {
|
if (isLocked) {
|
||||||
selectedGroup = value;
|
btn.disabled = true;
|
||||||
groupPicker.querySelectorAll('.group-picker-option').forEach(function (b) {
|
btn.title = 'Diese Gruppe ist gesperrt und kann nicht ausgewählt werden.';
|
||||||
b.classList.toggle('selected', b === btn);
|
} else {
|
||||||
|
btn.addEventListener('click', function () {
|
||||||
|
selectedGroup = value;
|
||||||
|
groupPicker.querySelectorAll('.group-picker-option').forEach(function (b) {
|
||||||
|
b.classList.toggle('selected', b === btn);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
return btn;
|
return btn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -49,15 +54,26 @@
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
groups = [];
|
groups = [];
|
||||||
}
|
}
|
||||||
|
var lockedGroups = [];
|
||||||
|
try {
|
||||||
|
lockedGroups = JSON.parse(card.getAttribute('data-locked-groups') || '[]');
|
||||||
|
} catch (e) {
|
||||||
|
lockedGroups = [];
|
||||||
|
}
|
||||||
var myGroup = card.getAttribute('data-my-group') || '';
|
var myGroup = card.getAttribute('data-my-group') || '';
|
||||||
selectedGroup = myGroup === '' ? null : parseInt(myGroup, 10);
|
selectedGroup = myGroup === '' ? null : parseInt(myGroup, 10);
|
||||||
|
// Eine bereits gewaehlte, aber inzwischen gesperrte Gruppe zaehlt nicht mehr als Auswahl.
|
||||||
|
if (selectedGroup && lockedGroups.indexOf(selectedGroup) !== -1) {
|
||||||
|
selectedGroup = null;
|
||||||
|
}
|
||||||
|
|
||||||
groupPicker.innerHTML = '';
|
groupPicker.innerHTML = '';
|
||||||
groupPicker.appendChild(makeGroupButton('Automatisch', null, selectedGroup === null));
|
groupPicker.appendChild(makeGroupButton('Automatisch', null, selectedGroup === null, false));
|
||||||
groups.forEach(function (name, index) {
|
groups.forEach(function (name, index) {
|
||||||
groupPicker.appendChild(makeGroupButton(name, index + 1, selectedGroup === index + 1));
|
var groupNumber = index + 1;
|
||||||
|
groupPicker.appendChild(makeGroupButton(name, groupNumber, selectedGroup === groupNumber, lockedGroups.indexOf(groupNumber) !== -1));
|
||||||
});
|
});
|
||||||
groupPicker.appendChild(makeGroupButton('Ersatzbank', 0, selectedGroup === 0));
|
groupPicker.appendChild(makeGroupButton('Ersatzbank', 0, selectedGroup === 0, false));
|
||||||
|
|
||||||
modal.querySelectorAll('.class-picker-option').forEach(function (btn) {
|
modal.querySelectorAll('.class-picker-option').forEach(function (btn) {
|
||||||
btn.classList.toggle('selected', btn.getAttribute('data-class') === selectedClass);
|
btn.classList.toggle('selected', btn.getAttribute('data-class') === selectedClass);
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,12 @@ try {
|
||||||
$signups = is_array($raid['signups'] ?? null) ? $raid['signups'] : [];
|
$signups = is_array($raid['signups'] ?? null) ? $raid['signups'] : [];
|
||||||
$discordId = (int) $user['discord_id'];
|
$discordId = (int) $user['discord_id'];
|
||||||
|
|
||||||
|
$lockedGroups = is_array($raid['locked_groups'] ?? null) ? array_map('intval', $raid['locked_groups']) : [];
|
||||||
|
$openGroups = $maxGroups >= 1 ? array_values(array_diff(range(1, $maxGroups), $lockedGroups)) : [];
|
||||||
|
|
||||||
$wantsAuto = $groupRaw === null || $groupRaw === '' || $groupRaw === 'auto';
|
$wantsAuto = $groupRaw === null || $groupRaw === '' || $groupRaw === 'auto';
|
||||||
$matchedWish = true;
|
$matchedWish = true;
|
||||||
|
$wishRejectReason = null; // 'locked' | 'full'
|
||||||
$requestGroup = null;
|
$requestGroup = null;
|
||||||
|
|
||||||
if (!$wantsAuto) {
|
if (!$wantsAuto) {
|
||||||
|
|
@ -42,14 +46,26 @@ try {
|
||||||
json_response(false, 'Ungültige Gruppe ausgewählt.');
|
json_response(false, 'Ungültige Gruppe ausgewählt.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (raid_wish_is_sensible($signups, $discordId, $class, $desiredGroup)) {
|
if ($desiredGroup > 0 && in_array($desiredGroup, $lockedGroups, true)) {
|
||||||
|
$requestGroup = null; // Gesperrte Gruppe: wie eine nicht erfuellbare Wunschgruppe behandeln
|
||||||
|
$matchedWish = false;
|
||||||
|
$wishRejectReason = 'locked';
|
||||||
|
} elseif (raid_wish_is_sensible($signups, $discordId, $class, $desiredGroup)) {
|
||||||
$requestGroup = $desiredGroup;
|
$requestGroup = $desiredGroup;
|
||||||
} else {
|
} else {
|
||||||
$requestGroup = null; // Bot automatisch zuteilen lassen
|
$requestGroup = null; // Bot automatisch zuteilen lassen
|
||||||
$matchedWish = false;
|
$matchedWish = false;
|
||||||
|
$wishRejectReason = 'full';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ist keine einzige Gruppe offen (alle gesperrt oder der Raid hat gar keine
|
||||||
|
// Gruppen), landet man deterministisch auf der Ersatzbank, statt auf eine
|
||||||
|
// automatische Zuteilung in eine gesperrte Gruppe zu hoffen.
|
||||||
|
if ($requestGroup === null && empty($openGroups)) {
|
||||||
|
$requestGroup = 0;
|
||||||
|
}
|
||||||
|
|
||||||
$assigned = raid_signup($raidId, $discordId, (string) $user['discord_username'], $class, $requestGroup);
|
$assigned = raid_signup($raidId, $discordId, (string) $user['discord_username'], $class, $requestGroup);
|
||||||
$assignedGroup = (int) ($assigned['group'] ?? 0);
|
$assignedGroup = (int) ($assigned['group'] ?? 0);
|
||||||
|
|
||||||
|
|
@ -62,7 +78,10 @@ try {
|
||||||
'matched_wish' => true,
|
'matched_wish' => true,
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
json_response(true, 'Deine Wunschgruppe war schon voll besetzt für diese Rolle, daher wurdest du automatisch zugeteilt: '
|
$reasonText = $wishRejectReason === 'locked'
|
||||||
|
? 'Deine Wunschgruppe ist gesperrt'
|
||||||
|
: 'Deine Wunschgruppe war schon voll besetzt für diese Rolle';
|
||||||
|
json_response(true, $reasonText . ', daher wurdest du automatisch zugeteilt: '
|
||||||
. $assignedGroupLabel . '. Melde dich gerne beim Raid-Lead, falls du eine Anpassung möchtest.', [
|
. $assignedGroupLabel . '. Melde dich gerne beim Raid-Lead, falls du eine Anpassung möchtest.', [
|
||||||
'group' => $assignedGroup,
|
'group' => $assignedGroup,
|
||||||
'matched_wish' => false,
|
'matched_wish' => false,
|
||||||
|
|
|
||||||
|
|
@ -150,6 +150,7 @@ include __DIR__ . '/includes/header.php';
|
||||||
<div class="panel raid-card<?= $isArchived ? ' panel-archived' : '' ?>"
|
<div class="panel raid-card<?= $isArchived ? ' panel-archived' : '' ?>"
|
||||||
data-raid-id="<?= $raidId ?>"
|
data-raid-id="<?= $raidId ?>"
|
||||||
data-groups='<?= e(json_encode($groupNames, JSON_UNESCAPED_UNICODE)) ?>'
|
data-groups='<?= e(json_encode($groupNames, JSON_UNESCAPED_UNICODE)) ?>'
|
||||||
|
data-locked-groups='<?= e(json_encode($lockedGroups)) ?>'
|
||||||
data-my-class="<?= e((string) ($mySignup['class'] ?? '')) ?>"
|
data-my-class="<?= e((string) ($mySignup['class'] ?? '')) ?>"
|
||||||
data-my-group="<?= $mySignupGroupNumber ?? '' ?>">
|
data-my-group="<?= $mySignupGroupNumber ?? '' ?>">
|
||||||
<div class="raid-header">
|
<div class="raid-header">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue