Spaces:
Sleeping

byte-vortex commited on
Commit
34f275d
Β·
verified Β·
1 Parent(s): 37c626f

Deploy Myco from CI

Browse files
Files changed (1) hide show
  1. ui/gradio_app.py +36 -1
ui/gradio_app.py CHANGED
@@ -18,11 +18,16 @@ from ui.renderers import (
18
  dex_markdown, forest_scene, game_intro_markdown,
19
  game_status_markdown, hero_markdown, home_forest_markdown,
20
  mushroom_card, play_hook_markdown, progress_markdown,
21
- world_map_markdown, myco_talking_markdown
22
  )
23
 
24
  from ui.interface import render_shroom_tab
25
 
 
 
 
 
 
26
  EMPTY_COLLECTION = None
27
  START_POSITION = (1, 1)
28
 
@@ -396,6 +401,36 @@ def build_app():
396
  with gr.Tab("πŸ„ Myco"):
397
  render_shroom_tab()
398
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
399
  # ── Event wiring ──
400
  start_play_button.click(open_play_tab, outputs=[tabs])
401
 
 
18
  dex_markdown, forest_scene, game_intro_markdown,
19
  game_status_markdown, hero_markdown, home_forest_markdown,
20
  mushroom_card, play_hook_markdown, progress_markdown,
21
+ world_map_markdown, myco_talking_markdown, EMPTY_DEX
22
  )
23
 
24
  from ui.interface import render_shroom_tab
25
 
26
+ import copy
27
+ import re
28
+ from ui.demo_roam import STATE, _STATE_LOCK # adjust path if your STATE is elsewhere
29
+
30
+
31
  EMPTY_COLLECTION = None
32
  START_POSITION = (1, 1)
33
 
 
401
  with gr.Tab("πŸ„ Myco"):
402
  render_shroom_tab()
403
 
404
+
405
+ # --- polling helpers ---
406
+ def _get_scene_html():
407
+ """Return forest_scene HTML using a shallow copy of STATE."""
408
+ with _STATE_LOCK:
409
+ state_copy = copy.deepcopy(STATE)
410
+ state_for_renderer = {
411
+ "active_mushrooms": state_copy.get("active_mushrooms", []),
412
+ "score_total": state_copy.get("score_total", 0),
413
+ "health": state_copy.get("health", 3),
414
+ "event_emoji": "✨",
415
+ "event_title": state_copy.get("thought", ""),
416
+ "mystery_title": "The Wrong Memory",
417
+ "picked": "No",
418
+ "game_over": "No",
419
+ }
420
+ return forest_scene(state_for_renderer, state_copy.get("collection", []), state_copy.get("position"))
421
+
422
+ def poll_scene():
423
+ """Bound to the scene HTML component via demo.load."""
424
+ return _get_scene_html()
425
+
426
+ def poll_myco_bubble_html():
427
+ """Return the HTML for the Myco speech bubble (cleaned)."""
428
+ with _STATE_LOCK:
429
+ raw = STATE.get("thought", "")
430
+ # myco_talking_markdown will parse/clean raw blocks or plain text
431
+ return myco_talking_markdown(raw)
432
+
433
+
434
  # ── Event wiring ──
435
  start_play_button.click(open_play_tab, outputs=[tabs])
436