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);
|
||||
}
|
||||
|
||||
.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
|
||||
ueber die globale "button"-Regel auf ihre Textbreite (width: fit-content)
|
||||
und wirken dadurch unterschiedlich gross - deshalb hier explizit 100%. */
|
||||
|
|
|
|||
|
|
@ -23,18 +23,23 @@
|
|||
var selectedClass = null;
|
||||
var selectedGroup = null; // null = automatisch zuteilen
|
||||
|
||||
function makeGroupButton(label, value, isSelected) {
|
||||
function makeGroupButton(label, value, isSelected, isLocked) {
|
||||
var btn = document.createElement('button');
|
||||
btn.type = 'button';
|
||||
btn.className = 'group-picker-option' + (isSelected ? ' selected' : '');
|
||||
btn.textContent = label;
|
||||
btn.className = 'group-picker-option' + (isSelected ? ' selected' : '') + (isLocked ? ' locked' : '');
|
||||
btn.textContent = isLocked ? label + ' 🔒' : label;
|
||||
btn.setAttribute('data-group', value === null ? '' : String(value));
|
||||
btn.addEventListener('click', function () {
|
||||
selectedGroup = value;
|
||||
groupPicker.querySelectorAll('.group-picker-option').forEach(function (b) {
|
||||
b.classList.toggle('selected', b === btn);
|
||||
if (isLocked) {
|
||||
btn.disabled = true;
|
||||
btn.title = 'Diese Gruppe ist gesperrt und kann nicht ausgewählt werden.';
|
||||
} else {
|
||||
btn.addEventListener('click', function () {
|
||||
selectedGroup = value;
|
||||
groupPicker.querySelectorAll('.group-picker-option').forEach(function (b) {
|
||||
b.classList.toggle('selected', b === btn);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
return btn;
|
||||
}
|
||||
|
||||
|
|
@ -49,15 +54,26 @@
|
|||
} catch (e) {
|
||||
groups = [];
|
||||
}
|
||||
var lockedGroups = [];
|
||||
try {
|
||||
lockedGroups = JSON.parse(card.getAttribute('data-locked-groups') || '[]');
|
||||
} catch (e) {
|
||||
lockedGroups = [];
|
||||
}
|
||||
var myGroup = card.getAttribute('data-my-group') || '';
|
||||
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.appendChild(makeGroupButton('Automatisch', null, selectedGroup === null));
|
||||
groupPicker.appendChild(makeGroupButton('Automatisch', null, selectedGroup === null, false));
|
||||
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) {
|
||||
btn.classList.toggle('selected', btn.getAttribute('data-class') === selectedClass);
|
||||
|
|
|
|||
|
|
@ -32,8 +32,12 @@ try {
|
|||
$signups = is_array($raid['signups'] ?? null) ? $raid['signups'] : [];
|
||||
$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';
|
||||
$matchedWish = true;
|
||||
$wishRejectReason = null; // 'locked' | 'full'
|
||||
$requestGroup = null;
|
||||
|
||||
if (!$wantsAuto) {
|
||||
|
|
@ -42,14 +46,26 @@ try {
|
|||
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;
|
||||
} else {
|
||||
$requestGroup = null; // Bot automatisch zuteilen lassen
|
||||
$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);
|
||||
$assignedGroup = (int) ($assigned['group'] ?? 0);
|
||||
|
||||
|
|
@ -62,7 +78,10 @@ try {
|
|||
'matched_wish' => true,
|
||||
]);
|
||||
} 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.', [
|
||||
'group' => $assignedGroup,
|
||||
'matched_wish' => false,
|
||||
|
|
|
|||
|
|
@ -150,6 +150,7 @@ include __DIR__ . '/includes/header.php';
|
|||
<div class="panel raid-card<?= $isArchived ? ' panel-archived' : '' ?>"
|
||||
data-raid-id="<?= $raidId ?>"
|
||||
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-group="<?= $mySignupGroupNumber ?? '' ?>">
|
||||
<div class="raid-header">
|
||||
|
|
|
|||
Loading…
Reference in a new issue