Fixed Reset Button
This commit is contained in:
Binary file not shown.
27
main.py
27
main.py
@@ -209,33 +209,6 @@ async def api_bot_control(req: BotControl):
|
||||
return {"status": "ok", "bot_running": STATE.bot_running}
|
||||
|
||||
|
||||
# ============================================================
|
||||
# Reset Groups Endpoint
|
||||
# ============================================================
|
||||
|
||||
@app.post("/api/reset_groups")
|
||||
async def reset_groups():
|
||||
# Load existing data
|
||||
data = load_json("assigned_groups.json")
|
||||
|
||||
# Clear group assignments
|
||||
for g in data["groups"].values():
|
||||
g.clear()
|
||||
|
||||
# Reset friendly assigned_group
|
||||
for f in data["friendly_members"]:
|
||||
f["assigned_group"] = None
|
||||
|
||||
# Reset enemy assigned_group
|
||||
for e in data["enemy_members"]:
|
||||
e["assigned_group"] = None
|
||||
|
||||
# Save back to file
|
||||
save_json("assigned_groups.json", data)
|
||||
|
||||
return { "success": True }
|
||||
|
||||
|
||||
# ============================================================
|
||||
# Discord Bot Setup
|
||||
# ============================================================
|
||||
|
||||
@@ -226,16 +226,24 @@ async function clearAssignmentsOnServer() {
|
||||
// ---------------------------
|
||||
function ensureMainListContains(member, kind) {
|
||||
const container = kind === "friendly" ? friendlyContainer : enemyContainer;
|
||||
// If member is not in any group zone, ensure it's in the main list (append if not present)
|
||||
const parent = member.domElement?.parentElement;
|
||||
const isInDropZone = parent && parent.classList && parent.classList.contains("drop-zone");
|
||||
if (!isInDropZone) {
|
||||
|
||||
// Detect group zone: ids like "group-1-friendly" or "group-2-enemy"
|
||||
const isInGroupZone = parent && typeof parent.id === "string" && /^group-\d+-/.test(parent.id);
|
||||
|
||||
// If member has no parent yet, or is in a group zone, ensure it ends up in the main list
|
||||
if (!parent || isInGroupZone) {
|
||||
// If it's already in the right container, nothing to do
|
||||
if (member.domElement && member.domElement.parentElement !== container) {
|
||||
// remove from previous parent (if any) and append to main list
|
||||
const prev = member.domElement.parentElement;
|
||||
if (prev) prev.removeChild(member.domElement);
|
||||
container.appendChild(member.domElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function applyAssignmentsToDOM(assignments) {
|
||||
if (!assignments) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user