byte-vortex commited on
Commit
8b79beb
·
verified ·
1 Parent(s): 2654aee

Deploy Myco from CI

Browse files
Files changed (5) hide show
  1. game/engine.py +187 -4
  2. tests/test_myco_core.py +57 -0
  3. ui/gradio_app.py +25 -3
  4. ui/renderers.py +45 -8
  5. ui/styles.py +20 -0
game/engine.py CHANGED
@@ -17,6 +17,76 @@ RARITY_CLUES = {
17
  "Legendary": "The whole clearing goes quiet; this mushroom is hiding part of the Elder Map.",
18
  }
19
  POISONOUS_MUSHROOMS = {"Ghost Gill", "Pepper Pixie", "Ruby Knuckle", "Clockwork Chanterelle"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
 
22
  def choose_mushroom(catalog=None):
@@ -35,6 +105,8 @@ def discover_mushroom(collection=None, catalog=None):
35
  discovery_count = len(current_collection)
36
  current = mushroom.to_dict()
37
  current["poison"] = "Yes" if _is_poisonous(current) else "No"
 
 
38
  current["clue"] = _mystery_clue(current, discovery_count)
39
  current["secret"] = _secret_signal(current, discovery_count)
40
  message = _discovery_reaction(current, discovery_count)
@@ -69,16 +141,23 @@ def _discovery_reaction(current, collection_count):
69
  prompt = (
70
  f"The player just discovered {mushroom.name}. "
71
  f"Rarity: {mushroom.rarity}. Clue: {current.get('clue', 'No clue yet')}. "
72
- "React as Myco, make the discovery feel mysterious, and invite them to ask, study, collect, or avoid eating it."
 
 
 
73
  )
74
  answer = _hf_companion_answer(prompt, current)
75
  if answer:
76
  return answer
77
 
78
  return (
79
- f"We found a {mushroom.name}! Myco kneels beside it and whispers: "
80
- f"{current.get('clue', 'the forest is trying to tell us something')} "
81
- f"Ask me about it, then Study or Collect. Your MycoDex has {collection_count} entries."
 
 
 
 
82
  )
83
 
84
 
@@ -240,6 +319,44 @@ def pick_current(current=None, collection=None, history=None):
240
  )
241
 
242
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
243
  def study_current(current=None, history=None):
244
  """Study the current mushroom to reveal one cautious field observation."""
245
  current_history = _safe_history(history)
@@ -320,6 +437,72 @@ def _mystery_clue(current, collection_count):
320
  return clue
321
 
322
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
323
  def _secret_signal(current, collection_count):
324
  """Return a memorable secret/reward hint for the MycoDex."""
325
  rarity = current.get("rarity", "Common")
 
17
  "Legendary": "The whole clearing goes quiet; this mushroom is hiding part of the Elder Map.",
18
  }
19
  POISONOUS_MUSHROOMS = {"Ghost Gill", "Pepper Pixie", "Ruby Knuckle", "Clockwork Chanterelle"}
20
+ FOREST_EVENTS = (
21
+ {
22
+ "title": "Silver Rain",
23
+ "emoji": "🌧️",
24
+ "mood": "curious",
25
+ "choice": "Follow the rain-song for a safer clue.",
26
+ "consequence": "Rain reveals honest footprints but washes away easy answers.",
27
+ },
28
+ {
29
+ "title": "Lantern Fog",
30
+ "emoji": "🌫️",
31
+ "mood": "nervous",
32
+ "choice": "Trust Myco's glow or risk walking blind.",
33
+ "consequence": "Fog hides poison tells, but it also reveals secret paths.",
34
+ },
35
+ {
36
+ "title": "Moonlit Sporefall",
37
+ "emoji": "🌌",
38
+ "mood": "excited",
39
+ "choice": "Follow the brightest spore to chase a memory fragment.",
40
+ "consequence": "Moonlight can wake memories Myco has never lived.",
41
+ },
42
+ {
43
+ "title": "Quiet Between Trees",
44
+ "emoji": "🕯️",
45
+ "mood": "afraid",
46
+ "choice": "Stay still and listen for the Impossible Mushroom.",
47
+ "consequence": "The forest answers only if you stop rushing.",
48
+ },
49
+ )
50
+ RARE_ENCOUNTERS = (
51
+ "A lost traveler asks why Myco knows their childhood song.",
52
+ "A mushroom guardian blocks the trail and counts your clues.",
53
+ "A tiny forest spirit swaps your shadow with a spore-shadow.",
54
+ "Something under the roots whispers: Myco has been here before.",
55
+ )
56
+ IMPOSSIBLE_OBJECTIVE = "Find the Impossible Mushroom and learn why Myco remembers a forest that vanished."
57
+ MYSTERY_QUESTION = "Why does Myco remember places that disappeared before Myco was born?"
58
+ MYSTERY_CHAPTERS = (
59
+ {
60
+ "threshold": 0,
61
+ "title": "The Wrong Memory",
62
+ "clue": "Myco recognizes the path before you move.",
63
+ "reveal": "The forest is repeating a memory that belongs to someone else.",
64
+ },
65
+ {
66
+ "threshold": 1,
67
+ "title": "The Traveler's Song",
68
+ "clue": "A stranger's lullaby appears in the MycoDex margin.",
69
+ "reveal": "Myco knows the song because the forest sang it through the roots.",
70
+ },
71
+ {
72
+ "threshold": 2,
73
+ "title": "The Door Under Roots",
74
+ "clue": "Rare spores point to a door nobody built.",
75
+ "reveal": "The door opens only for memories, not bodies.",
76
+ },
77
+ {
78
+ "threshold": 3,
79
+ "title": "The MycoDex Seed",
80
+ "clue": "The MycoDex begins growing warm like a living cap.",
81
+ "reveal": "The MycoDex is not recording the forest; it is regrowing it.",
82
+ },
83
+ {
84
+ "threshold": 5,
85
+ "title": "The Impossible Bloom",
86
+ "clue": "The final clue says the Impossible Mushroom was never outside the book.",
87
+ "reveal": "Final reveal: the Impossible Mushroom blooms inside the MycoDex, and Myco is its first spore.",
88
+ },
89
+ )
90
 
91
 
92
  def choose_mushroom(catalog=None):
 
105
  discovery_count = len(current_collection)
106
  current = mushroom.to_dict()
107
  current["poison"] = "Yes" if _is_poisonous(current) else "No"
108
+ current.update(_story_moment(current, discovery_count))
109
+ current.update(_mystery_thread(discovery_count))
110
  current["clue"] = _mystery_clue(current, discovery_count)
111
  current["secret"] = _secret_signal(current, discovery_count)
112
  message = _discovery_reaction(current, discovery_count)
 
141
  prompt = (
142
  f"The player just discovered {mushroom.name}. "
143
  f"Rarity: {mushroom.rarity}. Clue: {current.get('clue', 'No clue yet')}. "
144
+ f"Forest event: {current.get('event_title', 'Strange Omen')}. "
145
+ f"Encounter: {current.get('encounter', 'No creature yet')}. "
146
+ f"Mystery: {current.get('mystery_title', 'The Wrong Memory')}. "
147
+ "React as Myco with emotion, make the moment memorable, and invite a meaningful choice."
148
  )
149
  answer = _hf_companion_answer(prompt, current)
150
  if answer:
151
  return answer
152
 
153
  return (
154
+ f"We found a {mushroom.name} during {current.get('event_title', 'a strange omen')}! "
155
+ f"Myco feels {current.get('myco_mood', 'curious')} and whispers: "
156
+ f"{current.get('encounter', 'the forest is watching us')} "
157
+ f"Mystery: {current.get('mystery_title', 'The Wrong Memory')} — "
158
+ f"{current.get('mystery_reveal', 'the forest is hiding a memory')}. "
159
+ f"Clue: {current.get('clue', 'the forest is trying to tell us something')} "
160
+ "Choose Study, Pick, or Follow Whisper."
161
  )
162
 
163
 
 
319
  )
320
 
321
 
322
+ def follow_whisper(current=None, collection=None, history=None):
323
+ """Follow the active story omen for a risk-reward discovery moment."""
324
+ current_collection = _safe_collection(collection)
325
+ current_history = _safe_history(history)
326
+ if current is None:
327
+ return None, _append_assistant(
328
+ current_history,
329
+ "Myco cups one ear. First search a clearing; the forest only whispers near mushrooms.",
330
+ )
331
+
332
+ if _is_poisonous(current) and current.get("studied") != "Yes":
333
+ game_over = {**current, "danger": "Poisonous", "game_over": "Yes"}
334
+ return game_over, _append_assistant(
335
+ current_history,
336
+ (
337
+ "💀 GAME OVER — the whisper belonged to poison. "
338
+ "Myco freezes, then remembers this exact mistake from a dream."
339
+ ),
340
+ )
341
+
342
+ mystery = _mystery_thread(len(current_collection) + 1)
343
+ memory = _memory_fragment(current, len(current_collection), mystery)
344
+ revealed = {
345
+ **current,
346
+ **mystery,
347
+ "memory_fragment": memory,
348
+ "whisper_followed": "Yes",
349
+ "secret": f"{current.get('secret', 'A secret stirs.')} {memory}",
350
+ }
351
+ return revealed, _append_assistant(
352
+ current_history,
353
+ (
354
+ f"🌌 Myco follows the whisper and gasps: {memory} "
355
+ "This is not just collecting mushrooms anymore — it is recovering Myco's lost forest."
356
+ ),
357
+ )
358
+
359
+
360
  def study_current(current=None, history=None):
361
  """Study the current mushroom to reveal one cautious field observation."""
362
  current_history = _safe_history(history)
 
437
  return clue
438
 
439
 
440
+ def _mystery_thread(collection_count):
441
+ """Return the single unfolding mystery state for the current progress."""
442
+ chapter = MYSTERY_CHAPTERS[0]
443
+ next_chapter = None
444
+ for candidate in MYSTERY_CHAPTERS:
445
+ if collection_count >= candidate["threshold"]:
446
+ chapter = candidate
447
+ elif next_chapter is None:
448
+ next_chapter = candidate
449
+
450
+ if next_chapter is None:
451
+ next_line = "The Impossible Bloom is visible. Follow the whisper for the final truth."
452
+ else:
453
+ remaining = next_chapter["threshold"] - collection_count
454
+ next_line = f"{remaining} clue discovery until {next_chapter['title']}."
455
+
456
+ return {
457
+ "mystery_title": chapter["title"],
458
+ "mystery_question": MYSTERY_QUESTION,
459
+ "mystery_progress": chapter["clue"],
460
+ "mystery_reveal": chapter["reveal"],
461
+ "mystery_next": next_line,
462
+ }
463
+
464
+
465
+ def _story_moment(current, collection_count):
466
+ """Return the event, encounter, mood, and objective for this discovery."""
467
+ event = FOREST_EVENTS[collection_count % len(FOREST_EVENTS)]
468
+ encounter = _encounter_for(current, collection_count)
469
+ return {
470
+ "event_title": event["title"],
471
+ "event_emoji": event["emoji"],
472
+ "event_choice": event["choice"],
473
+ "event_consequence": event["consequence"],
474
+ "encounter": encounter,
475
+ "myco_mood": event["mood"],
476
+ "objective": IMPOSSIBLE_OBJECTIVE,
477
+ }
478
+
479
+
480
+ def _encounter_for(current, collection_count):
481
+ """Return a rare encounter line tied to rarity, poison, and progress."""
482
+ if current.get("rarity") == "Legendary":
483
+ return "A mushroom guardian bows and calls Myco by an old royal name."
484
+ if _is_poisonous(current):
485
+ return "A black-winged moth lands on Myco's cap: a poison omen."
486
+ if current.get("rarity") == "Rare" or collection_count in (2, 5, 8):
487
+ return RARE_ENCOUNTERS[collection_count % len(RARE_ENCOUNTERS)]
488
+ return "No creature appears, but the trees lean closer to hear Myco think."
489
+
490
+
491
+ def _memory_fragment(current, collection_count, mystery):
492
+ """Return the emotional reward for following a story whisper."""
493
+ name = current.get("name", "this mushroom")
494
+ reveal = mystery.get("mystery_reveal", "The forest remembers Myco.")
495
+ if mystery.get("mystery_title") == "The Impossible Bloom":
496
+ return reveal
497
+ if current.get("rarity") == "Legendary":
498
+ return f"Memory fragment: {name} once grew beside Myco's missing home. {reveal}"
499
+ if current.get("rarity") == "Rare":
500
+ return f"Memory fragment: {name} hums the name of a door under the roots. {reveal}"
501
+ if collection_count >= 3:
502
+ return f"Memory fragment: {name} points toward the Impossible Mushroom. {reveal}"
503
+ return f"Memory fragment: {name} shows Myco a path they do not remember walking. {reveal}"
504
+
505
+
506
  def _secret_signal(current, collection_count):
507
  """Return a memorable secret/reward hint for the MycoDex."""
508
  rarity = current.get("rarity", "Common")
tests/test_myco_core.py CHANGED
@@ -14,6 +14,7 @@ from game.engine import (
14
  companion_reply,
15
  discover_mushroom,
16
  eat_current,
 
17
  hf_companion_status,
18
  hf_model_id,
19
  pick_current,
@@ -219,6 +220,59 @@ class MycoCoreTests(unittest.TestCase):
219
  self.assertEqual(duplicate_collection, collection)
220
  self.assertIn("already", duplicate_history[-1]["content"])
221
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
  def test_pick_current_can_game_over_on_poison(self):
223
  poisonous = {
224
  "name": "Ghost Gill",
@@ -279,6 +333,8 @@ class MycoCoreTests(unittest.TestCase):
279
  self.assertIn("First Spore", world_map_markdown([current]))
280
  self.assertEqual(world_map_markdown([current]).count('class="map-card '), 4)
281
  self.assertIn("Quest Log", game_status_markdown(current, [current]))
 
 
282
  self.assertIn("Mystery", game_status_markdown(current, [current]))
283
  self.assertIn(current["name"], game_status_markdown(current, [current]))
284
  self.assertEqual(current_area(0).name, "Mossy Trail")
@@ -319,6 +375,7 @@ class MycoCoreTests(unittest.TestCase):
319
  self.assertIn('search_button = gr.Button("🎮 Search Clearing", variant="primary")', source)
320
  self.assertIn('with gr.Group(elem_id="near-monitor-controls"):', source)
321
  self.assertIn('pick_button = gr.Button("🍄 Pick", variant="primary")', source)
 
322
 
323
  def test_gradio_app_rejects_old_corrupted_callback_fragments(self):
324
  source = Path("ui/gradio_app.py").read_text()
 
14
  companion_reply,
15
  discover_mushroom,
16
  eat_current,
17
+ follow_whisper,
18
  hf_companion_status,
19
  hf_model_id,
20
  pick_current,
 
220
  self.assertEqual(duplicate_collection, collection)
221
  self.assertIn("already", duplicate_history[-1]["content"])
222
 
223
+ def test_discoveries_include_memorable_story_moments(self):
224
+ _mushroom, current, history = discover_mushroom([])
225
+
226
+ self.assertIn("event_title", current)
227
+ self.assertIn("encounter", current)
228
+ self.assertIn("Impossible Mushroom", current["objective"])
229
+ self.assertIn("mystery_title", current)
230
+ self.assertIn("mystery_reveal", current)
231
+ self.assertIn(current["event_title"], history[-1]["content"])
232
+
233
+ def test_single_mystery_reaches_magical_final_reveal(self):
234
+ catalog = (load_mushrooms()[0],)
235
+ collection = [{"name": f"clue-{index}"} for index in range(5)]
236
+ _mushroom, current, _history = discover_mushroom(collection, catalog)
237
+ followed, history = follow_whisper(current, collection, [])
238
+
239
+ assert followed is not None
240
+ self.assertEqual(followed["mystery_title"], "The Impossible Bloom")
241
+ self.assertIn("blooms inside the MycoDex", followed["mystery_reveal"])
242
+ self.assertIn("first spore", followed["memory_fragment"])
243
+ self.assertIn("recovering Myco's lost forest", history[-1]["content"])
244
+
245
+ def test_follow_whisper_reveals_memory_or_game_over(self):
246
+ rare = {
247
+ "name": "Silvercap",
248
+ "rarity": "Rare",
249
+ "habitat": "moon roots",
250
+ "lore": "It rings like a tiny bell.",
251
+ "edible": "Unknown",
252
+ "magic": "Unknown",
253
+ "danger": "Unknown",
254
+ "event_title": "Moonlit Sporefall",
255
+ "event_emoji": "🌌",
256
+ "event_choice": "Follow the brightest spore.",
257
+ "event_consequence": "A memory wakes.",
258
+ "encounter": "A lost traveler waits.",
259
+ "clue": "A clue",
260
+ "secret": "A secret",
261
+ }
262
+ followed, history = follow_whisper(rare, [], [])
263
+
264
+ assert followed is not None
265
+ self.assertEqual(followed["whisper_followed"], "Yes")
266
+ self.assertIn("Memory fragment", followed["memory_fragment"])
267
+ self.assertIn("recovering Myco's lost forest", history[-1]["content"])
268
+
269
+ poison = {**rare, "name": "Ghost Gill"}
270
+ game_over, history = follow_whisper(poison, [], [])
271
+
272
+ assert game_over is not None
273
+ self.assertEqual(game_over["game_over"], "Yes")
274
+ self.assertIn("GAME OVER", history[-1]["content"])
275
+
276
  def test_pick_current_can_game_over_on_poison(self):
277
  poisonous = {
278
  "name": "Ghost Gill",
 
333
  self.assertIn("First Spore", world_map_markdown([current]))
334
  self.assertEqual(world_map_markdown([current]).count('class="map-card '), 4)
335
  self.assertIn("Quest Log", game_status_markdown(current, [current]))
336
+ self.assertIn("Mystery thread", game_status_markdown(current, [current]))
337
+ self.assertIn("Event:", game_status_markdown(current, [current]))
338
  self.assertIn("Mystery", game_status_markdown(current, [current]))
339
  self.assertIn(current["name"], game_status_markdown(current, [current]))
340
  self.assertEqual(current_area(0).name, "Mossy Trail")
 
375
  self.assertIn('search_button = gr.Button("🎮 Search Clearing", variant="primary")', source)
376
  self.assertIn('with gr.Group(elem_id="near-monitor-controls"):', source)
377
  self.assertIn('pick_button = gr.Button("🍄 Pick", variant="primary")', source)
378
+ self.assertIn('whisper_button = gr.Button("🌌 Follow Whisper")', source)
379
 
380
  def test_gradio_app_rejects_old_corrupted_callback_fragments(self):
381
  source = Path("ui/gradio_app.py").read_text()
ui/gradio_app.py CHANGED
@@ -8,6 +8,7 @@ from game.engine import (
8
  collect_current,
9
  discover_mushroom,
10
  eat_current,
 
11
  hf_companion_status,
12
  myco_reply,
13
  pick_current,
@@ -37,8 +38,8 @@ HOME_MARKDOWN = """
37
  Myco is a tiny forest game portal. Open **🎮 Play** to search for mushrooms,
38
  visit **📖 MycoDex** to review progress, and use **🧭 Guide** for the loop.
39
 
40
- **Goal:** collect 3 mushroom clues to wake the Whispering Ring, then keep exploring for
41
- rare and legendary secrets that only Myco can interpret.
42
  """
43
 
44
  GUIDE_MARKDOWN = """
@@ -48,7 +49,8 @@ GUIDE_MARKDOWN = """
48
  2. Use the controls directly under the forest monitor to move Myco.
49
  3. Click **Search Clearing** to reveal a mushroom in the current clearing.
50
  4. Press **Pick** to grab the mushroom like a platformer item — poisonous mushrooms trigger Game Over.
51
- 5. Ask Myco, Study, and Collect safe clues in the MycoDex.
 
52
  """
53
 
54
 
@@ -60,6 +62,7 @@ def mushroom_card_from_state(current):
60
  Mushroom.from_dict(current),
61
  current.get("clue"),
62
  current.get("secret"),
 
63
  )
64
 
65
 
@@ -115,6 +118,19 @@ def pick_discovery(current, collection, history, position):
115
  )
116
 
117
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  def study_discovery(current, history, collection, position):
119
  """Study the active mushroom and refresh the discovery card."""
120
  updated_current, updated_history = study_current(current, history)
@@ -207,6 +223,7 @@ def build_app():
207
  )
208
  with gr.Row():
209
  eat_button = gr.Button("🍽️ Eat?")
 
210
  collect_button = gr.Button("📖 Collect")
211
  study_button = gr.Button("🔍 Study")
212
  with gr.Column(scale=3):
@@ -280,6 +297,11 @@ def build_app():
280
  inputs=(current_mushroom, collection, chat, player_position),
281
  outputs=(collection, current_mushroom, scene, status, discovery, dex, world_map, chat, progress),
282
  )
 
 
 
 
 
283
  study_button.click(
284
  study_discovery,
285
  inputs=(current_mushroom, chat, collection, player_position),
 
8
  collect_current,
9
  discover_mushroom,
10
  eat_current,
11
+ follow_whisper,
12
  hf_companion_status,
13
  myco_reply,
14
  pick_current,
 
38
  Myco is a tiny forest game portal. Open **🎮 Play** to search for mushrooms,
39
  visit **📖 MycoDex** to review progress, and use **🧭 Guide** for the loop.
40
 
41
+ **Goal:** solve one mystery: why does Myco remember a forest that vanished before
42
+ it was born? Follow clues until the Impossible Mushroom blooms.
43
  """
44
 
45
  GUIDE_MARKDOWN = """
 
49
  2. Use the controls directly under the forest monitor to move Myco.
50
  3. Click **Search Clearing** to reveal a mushroom in the current clearing.
51
  4. Press **Pick** to grab the mushroom like a platformer item — poisonous mushrooms trigger Game Over.
52
+ 5. Press **Follow Whisper** to reveal memory fragments. Safe whispers advance the mystery; poison whispers can end the run.
53
+ 6. Ask Myco, Study, and Collect safe clues until the Impossible Mushroom reveal appears.
54
  """
55
 
56
 
 
62
  Mushroom.from_dict(current),
63
  current.get("clue"),
64
  current.get("secret"),
65
+ current,
66
  )
67
 
68
 
 
118
  )
119
 
120
 
121
+ def follow_story_whisper(current, collection, history, position):
122
+ """Follow the active forest whisper and refresh story panels."""
123
+ updated_current, updated_history = follow_whisper(current, collection, history)
124
+ player_position = _safe_position(position)
125
+ return (
126
+ updated_current,
127
+ forest_scene(updated_current, collection, player_position),
128
+ game_status_markdown(updated_current, collection, player_position),
129
+ mushroom_card_from_state(updated_current),
130
+ updated_history,
131
+ )
132
+
133
+
134
  def study_discovery(current, history, collection, position):
135
  """Study the active mushroom and refresh the discovery card."""
136
  updated_current, updated_history = study_current(current, history)
 
223
  )
224
  with gr.Row():
225
  eat_button = gr.Button("🍽️ Eat?")
226
+ whisper_button = gr.Button("🌌 Follow Whisper")
227
  collect_button = gr.Button("📖 Collect")
228
  study_button = gr.Button("🔍 Study")
229
  with gr.Column(scale=3):
 
297
  inputs=(current_mushroom, collection, chat, player_position),
298
  outputs=(collection, current_mushroom, scene, status, discovery, dex, world_map, chat, progress),
299
  )
300
+ whisper_button.click(
301
+ follow_story_whisper,
302
+ inputs=(current_mushroom, collection, chat, player_position),
303
+ outputs=(current_mushroom, scene, status, discovery, chat),
304
+ )
305
  study_button.click(
306
  study_discovery,
307
  inputs=(current_mushroom, chat, collection, player_position),
ui/renderers.py CHANGED
@@ -54,10 +54,11 @@ def home_forest_markdown() -> str:
54
  <span class="home-tree right">🌳</span>
55
  </div>
56
  <p><strong>The Milky Way is awake.</strong> Myco hears a brown mushroom whispering your first clue.</p>
57
- <span class="home-whisper">“Let’s find what the forest is hiding.”</span>
58
  </div>
59
  """
60
 
 
61
  def game_intro_markdown() -> str:
62
  """Render a video-game-style mission HUD for the Play tab."""
63
  return """
@@ -65,7 +66,7 @@ def game_intro_markdown() -> str:
65
  <div>
66
  <p class="eyebrow">Mission</p>
67
  <h2>Wake the Whispering Ring</h2>
68
- <p>Move Myco through the forest, search each clearing, and collect 3 clue-mushrooms.</p>
69
  </div>
70
  <div class="game-hud-stats">
71
  <span>🎮 Move</span>
@@ -82,13 +83,13 @@ def play_hook_markdown() -> str:
82
  return """
83
  <div class="play-hook">
84
  <p class="eyebrow">First 30 seconds</p>
85
- <h2>Goal: collect 3 clues to wake the Whispering Ring.</h2>
86
  <div class="hook-steps">
87
  <span>1 · Move through the forest</span>
88
  <span>2 · Discover a mushroom clue</span>
89
- <span>3 · Ask Myco, Study, then Collect</span>
90
  </div>
91
- <p>Every mushroom is a clue. Rare and legendary finds reveal stranger secrets, and Myco reacts like a companion who is trying to solve the forest with you.</p>
92
  </div>
93
  """
94
 
@@ -110,12 +111,18 @@ def forest_scene(
110
  sprite = "✨"
111
  status = "The moss is listening. Click Search Clearing to wake the forest."
112
  omen = "Myco is waiting to sense the first spore."
 
 
 
113
  else:
114
  mushroom_name = current.get("name", "Mystery mushroom")
115
  rarity = current.get("rarity", "Common")
116
  sprite = _mushroom_sprite(rarity)
117
  studied = current.get("studied") == "Yes"
118
  game_over = current.get("game_over") == "Yes"
 
 
 
119
  status = f"A {rarity.lower()} {mushroom_name} breaks through the moss!"
120
  if game_over:
121
  status = f"GAME OVER: {mushroom_name} was poisonous."
@@ -131,6 +138,8 @@ def forest_scene(
131
  <span>🧭 {escape(area.name)}</span>
132
  <span>🎮 Myco: ({pos_x + 1}, {pos_y + 1})</span>
133
  <span>📖 {count} MycoDex finds</span>
 
 
134
  </div>
135
  <div class="scene-stage" aria-label="Magical forest scene">
136
  <span class="tree tree-left">🌲</span>
@@ -149,6 +158,10 @@ def forest_scene(
149
  <strong>{escape(status)}</strong>
150
  <span>{escape(omen)}</span>
151
  </div>
 
 
 
 
152
  </div>
153
  '''
154
 
@@ -188,14 +201,16 @@ def game_status_markdown(
188
  active_mystery = next_mystery(count)
189
  mystery_line = _mystery_goal_line(active_mystery, count)
190
  if current is None:
191
- objective = "Goal: collect **3 clue-mushrooms** to wake the **Whispering Ring**."
192
  discovery = "No active discovery yet. Move Myco, then Search Clearing."
193
  ai_job = "Myco's job: notice clues you would miss alone."
 
194
  clue_line = mystery_line
 
195
  else:
196
  name = current.get("name", "Mystery mushroom")
197
  studied = current.get("studied") == "Yes"
198
- next_step = "Collect it to preserve the clue" if studied else "Ask Myco, then Study the clue"
199
  if current.get("game_over") == "Yes":
200
  objective = "**GAME OVER:** press **Search Clearing** to start a new run."
201
  elif current.get("picked") == "Yes":
@@ -203,7 +218,13 @@ def game_status_markdown(
203
  else:
204
  objective = f"Current objective: **{next_step}**."
205
  discovery = f"Active discovery: **{name}** · Rarity: **{current.get('rarity', 'Unknown')}**"
 
206
  clue_line = f"**Clue:** {current.get('clue', 'Myco is still listening.')}"
 
 
 
 
 
207
  ai_job = "Myco's job: interpret clues, warn you away from danger, and make discoveries feel alive."
208
 
209
  return "\n".join(
@@ -213,18 +234,26 @@ def game_status_markdown(
213
  f"**Map position:** ({pos_x + 1}, {pos_y + 1})",
214
  discovery,
215
  objective,
 
216
  clue_line,
 
217
  mystery_line,
218
  ai_job,
219
  )
220
  )
221
 
222
 
223
- def mushroom_card(mushroom: Mushroom | None, clue: str | None = None, secret: str | None = None) -> str:
 
 
 
 
 
224
  """Render the current mushroom discovery as markdown."""
225
  if mushroom is None:
226
  return "### 🌲 Forest Clearing\nClick **Search Clearing** to wake a strange fungus."
227
 
 
228
  return "\n".join(
229
  (
230
  f"### 🍄‍🟫 {mushroom.name}",
@@ -235,6 +264,14 @@ def mushroom_card(mushroom: Mushroom | None, clue: str | None = None, secret: st
235
  f"* **Magic:** {mushroom.magic}",
236
  f"* **Danger:** {mushroom.danger}",
237
  f"* **Poison risk:** {_poison_risk_label(mushroom.name)}",
 
 
 
 
 
 
 
 
238
  f"* **Clue:** {clue or 'Study with Myco to reveal the clue.'}",
239
  f"* **Secret signal:** {secret or 'Collect it to see how the MycoDex reacts.'}",
240
  "",
 
54
  <span class="home-tree right">🌳</span>
55
  </div>
56
  <p><strong>The Milky Way is awake.</strong> Myco hears a brown mushroom whispering your first clue.</p>
57
+ <span class="home-whisper">“Tap Play. Let’s find what the forest is hiding.”</span>
58
  </div>
59
  """
60
 
61
+
62
  def game_intro_markdown() -> str:
63
  """Render a video-game-style mission HUD for the Play tab."""
64
  return """
 
66
  <div>
67
  <p class="eyebrow">Mission</p>
68
  <h2>Wake the Whispering Ring</h2>
69
+ <p>Single mystery: find the Impossible Mushroom and learn why Myco remembers a vanished forest.</p>
70
  </div>
71
  <div class="game-hud-stats">
72
  <span>🎮 Move</span>
 
83
  return """
84
  <div class="play-hook">
85
  <p class="eyebrow">First 30 seconds</p>
86
+ <h2>Goal: follow clues until Myco remembers the Impossible Mushroom.</h2>
87
  <div class="hook-steps">
88
  <span>1 · Move through the forest</span>
89
  <span>2 · Discover a mushroom clue</span>
90
+ <span>3 · Choose: Pick, Study, or Follow Whisper</span>
91
  </div>
92
+ <p>Every clue advances one mystery. Follow whispers to reveal why the MycoDex is regrowing a forest that vanished.</p>
93
  </div>
94
  """
95
 
 
111
  sprite = "✨"
112
  status = "The moss is listening. Click Search Clearing to wake the forest."
113
  omen = "Myco is waiting to sense the first spore."
114
+ event_label = "🌌 Dreaming Forest"
115
+ encounter = "The next clearing may reveal a memory, creature, or poison omen."
116
+ mystery_label = "The Wrong Memory"
117
  else:
118
  mushroom_name = current.get("name", "Mystery mushroom")
119
  rarity = current.get("rarity", "Common")
120
  sprite = _mushroom_sprite(rarity)
121
  studied = current.get("studied") == "Yes"
122
  game_over = current.get("game_over") == "Yes"
123
+ event_label = f"{current.get('event_emoji', '✨')} {current.get('event_title', 'Strange Omen')}"
124
+ encounter = current.get("encounter", "The forest waits for Myco's reaction.")
125
+ mystery_label = current.get("mystery_title", "The Wrong Memory")
126
  status = f"A {rarity.lower()} {mushroom_name} breaks through the moss!"
127
  if game_over:
128
  status = f"GAME OVER: {mushroom_name} was poisonous."
 
138
  <span>🧭 {escape(area.name)}</span>
139
  <span>🎮 Myco: ({pos_x + 1}, {pos_y + 1})</span>
140
  <span>📖 {count} MycoDex finds</span>
141
+ <span>{escape(event_label)}</span>
142
+ <span>🧩 {escape(mystery_label)}</span>
143
  </div>
144
  <div class="scene-stage" aria-label="Magical forest scene">
145
  <span class="tree tree-left">🌲</span>
 
158
  <strong>{escape(status)}</strong>
159
  <span>{escape(omen)}</span>
160
  </div>
161
+ <div class="story-moment">
162
+ <strong>{escape(event_label)}</strong>
163
+ <span>{escape(encounter)}</span>
164
+ </div>
165
  </div>
166
  '''
167
 
 
201
  active_mystery = next_mystery(count)
202
  mystery_line = _mystery_goal_line(active_mystery, count)
203
  if current is None:
204
+ objective = "Goal: solve **one mystery** — why does Myco remember a vanished forest?"
205
  discovery = "No active discovery yet. Move Myco, then Search Clearing."
206
  ai_job = "Myco's job: notice clues you would miss alone."
207
+ event = "**Event:** waiting for the first omen"
208
  clue_line = mystery_line
209
+ thread_line = "**Mystery thread:** The Wrong Memory — search the first clearing."
210
  else:
211
  name = current.get("name", "Mystery mushroom")
212
  studied = current.get("studied") == "Yes"
213
+ next_step = "Collect it to preserve the clue" if studied else "Ask Myco, then choose Study or Follow Whisper"
214
  if current.get("game_over") == "Yes":
215
  objective = "**GAME OVER:** press **Search Clearing** to start a new run."
216
  elif current.get("picked") == "Yes":
 
218
  else:
219
  objective = f"Current objective: **{next_step}**."
220
  discovery = f"Active discovery: **{name}** · Rarity: **{current.get('rarity', 'Unknown')}**"
221
+ event = f"**Event:** {current.get('event_emoji', '✨')} {current.get('event_title', 'Strange Omen')}"
222
  clue_line = f"**Clue:** {current.get('clue', 'Myco is still listening.')}"
223
+ thread_line = (
224
+ f"**Mystery thread:** {current.get('mystery_title', 'The Wrong Memory')} — "
225
+ f"{current.get('mystery_progress', 'Myco remembers the path too early.')} "
226
+ f"Next: {current.get('mystery_next', 'follow the whisper.')}"
227
+ )
228
  ai_job = "Myco's job: interpret clues, warn you away from danger, and make discoveries feel alive."
229
 
230
  return "\n".join(
 
234
  f"**Map position:** ({pos_x + 1}, {pos_y + 1})",
235
  discovery,
236
  objective,
237
+ event,
238
  clue_line,
239
+ thread_line,
240
  mystery_line,
241
  ai_job,
242
  )
243
  )
244
 
245
 
246
+ def mushroom_card(
247
+ mushroom: Mushroom | None,
248
+ clue: str | None = None,
249
+ secret: str | None = None,
250
+ state: MushroomState | None = None,
251
+ ) -> str:
252
  """Render the current mushroom discovery as markdown."""
253
  if mushroom is None:
254
  return "### 🌲 Forest Clearing\nClick **Search Clearing** to wake a strange fungus."
255
 
256
+ story_state = state or {}
257
  return "\n".join(
258
  (
259
  f"### 🍄‍🟫 {mushroom.name}",
 
264
  f"* **Magic:** {mushroom.magic}",
265
  f"* **Danger:** {mushroom.danger}",
266
  f"* **Poison risk:** {_poison_risk_label(mushroom.name)}",
267
+ f"* **Forest event:** {story_state.get('event_emoji', '✨')} {story_state.get('event_title', 'Strange Omen')}",
268
+ f"* **Encounter:** {story_state.get('encounter', 'No creature has stepped forward yet.')}",
269
+ f"* **Choice:** {story_state.get('event_choice', 'Study it, pick it, or follow the whisper.')}",
270
+ f"* **Consequence:** {story_state.get('event_consequence', 'The forest remembers your choice.')}",
271
+ f"* **Mystery:** {story_state.get('mystery_title', 'The Wrong Memory')}",
272
+ f"* **Mystery question:** {story_state.get('mystery_question', 'Why does Myco remember this place?')}",
273
+ f"* **Mystery reveal:** {story_state.get('mystery_reveal', 'Follow whispers to reveal more.')}",
274
+ f"* **Memory:** {story_state.get('memory_fragment', 'Not revealed yet.')}",
275
  f"* **Clue:** {clue or 'Study with Myco to reveal the clue.'}",
276
  f"* **Secret signal:** {secret or 'Collect it to see how the MycoDex reacts.'}",
277
  "",
ui/styles.py CHANGED
@@ -294,6 +294,26 @@ APP_CSS = """
294
  box-shadow: 0 24px 70px rgba(4, 18, 12, 0.3);
295
  }
296
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
  #near-monitor-controls {
298
  margin: 0.55rem 0;
299
  padding: 0.7rem;
 
294
  box-shadow: 0 24px 70px rgba(4, 18, 12, 0.3);
295
  }
296
 
297
+
298
+ .story-moment {
299
+ margin: 0.85rem auto 0;
300
+ max-width: 760px;
301
+ padding: 0.85rem 1rem;
302
+ border: 1px solid rgba(255, 234, 166, 0.3);
303
+ border-radius: 18px;
304
+ background: rgba(25, 18, 45, 0.72);
305
+ color: #fff7d6;
306
+ box-shadow: 0 0 24px rgba(165, 111, 255, 0.22);
307
+ }
308
+ .story-moment strong,
309
+ .story-moment span {
310
+ display: block;
311
+ }
312
+ .story-moment span {
313
+ margin-top: 0.25rem;
314
+ color: #f6e7b2;
315
+ }
316
+
317
  #near-monitor-controls {
318
  margin: 0.55rem 0;
319
  padding: 0.7rem;