MCPcopy Create free account
hub / github.com/dedsec1121fk/DedSec / build_pool

Function build_pool

Scripts/Games/Buzz.py:367–388  ·  view source on GitHub ↗

Strict category matching. - If category != 'ALL': questions MUST be from that category. - Difficulty filter applies inside the chosen category. If it yields 0 questions, we fall back to ALL difficulty *within the same category* (never to the whole DB).

(db: List[dict], category: str, difficulty: str)

Source from the content-addressed store, hash-verified

365
366# -------------------- Quiz core --------------------
367def build_pool(db: List[dict], category: str, difficulty: str) -> List[dict]:
368 """Strict category matching.
369 - If category != 'ALL': questions MUST be from that category.
370 - Difficulty filter applies inside the chosen category. If it yields 0 questions, we fall back to ALL difficulty
371 *within the same category* (never to the whole DB).
372 """
373 if difficulty not in DIFFICULTIES:
374 difficulty = "ALL"
375
376 if category == "ALL":
377 pool = list(db)
378 else:
379 pool = [q for q in db if q.get("category") == category]
380
381 if not pool:
382 return []
383
384 if difficulty == "ALL":
385 return pool
386
387 filtered = [q for q in pool if q.get("difficulty") == difficulty]
388 return filtered if filtered else pool
389
390def judge_answer(q: dict, user: str) -> bool:
391 qtype = q.get("type","text")

Callers 8

Buzz.pyFile · 0.70
mode_quickfireFunction · 0.70
mode_category_marathonFunction · 0.70
mode_duelFunction · 0.70
mode_survivalFunction · 0.70
mode_time_attackFunction · 0.70
mode_high_stakesFunction · 0.70
mode_practiceFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected