Spaces:
Sleeping
Sleeping
Doodle Duel Deploy commited on
Commit ·
d2fcbcb
1
Parent(s): b1f8028
Deploy Doodle Duel to HF Space
Browse files
app.py
CHANGED
|
@@ -217,29 +217,16 @@ def on_timer(s, request: gr.Request):
|
|
| 217 |
Outputs everything EXCEPT the canvas, so the timer never disturbs drawing."""
|
| 218 |
if s is None:
|
| 219 |
return (s, *([gr.skip()] * (N_RENDER - 1)))
|
| 220 |
-
status_before = s.status
|
| 221 |
game.tick_time(s) # countdown / timeout, no network
|
| 222 |
-
changed = s.status != status_before # e.g. round just timed out
|
| 223 |
if s.status == "drawing":
|
| 224 |
sid = _sid(request)
|
| 225 |
if _claim_guess(sid):
|
| 226 |
-
before = (len(s.guess_log), len(s.reason_log), s.status)
|
| 227 |
try:
|
| 228 |
game.poll_guess(s, s.last_canvas)
|
| 229 |
finally:
|
| 230 |
_release_guess(sid)
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
if changed:
|
| 234 |
-
# A guess landed or the round ended — refresh everything but the canvas.
|
| 235 |
-
return (s, *full[:-1])
|
| 236 |
-
# Plain countdown tick: refresh ONLY the topbar clock. Critically, do NOT
|
| 237 |
-
# write `st` here. The timer runs concurrently, so a stale tick that read an
|
| 238 |
-
# old state would otherwise clobber state just set by a button click (e.g.
|
| 239 |
-
# overwrite the "choosing" state back to "idle", hiding the word buttons).
|
| 240 |
-
# Skipping every other output also avoids the per-second DOM churn that was
|
| 241 |
-
# dropping pointer events mid-stroke and drawing a stray line on the canvas.
|
| 242 |
-
return (gr.skip(), full[0], *([gr.skip()] * (N_RENDER - 2)))
|
| 243 |
|
| 244 |
|
| 245 |
def on_hint(s, canvas, request: gr.Request):
|
|
|
|
| 217 |
Outputs everything EXCEPT the canvas, so the timer never disturbs drawing."""
|
| 218 |
if s is None:
|
| 219 |
return (s, *([gr.skip()] * (N_RENDER - 1)))
|
|
|
|
| 220 |
game.tick_time(s) # countdown / timeout, no network
|
|
|
|
| 221 |
if s.status == "drawing":
|
| 222 |
sid = _sid(request)
|
| 223 |
if _claim_guess(sid):
|
|
|
|
| 224 |
try:
|
| 225 |
game.poll_guess(s, s.last_canvas)
|
| 226 |
finally:
|
| 227 |
_release_guess(sid)
|
| 228 |
+
*other_outs, _ = render(s) # drop the trailing canvas update
|
| 229 |
+
return (s, *other_outs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
|
| 231 |
|
| 232 |
def on_hint(s, canvas, request: gr.Request):
|