Spaces:
Sleeping
Sleeping
Deploy Myco from CI
Browse files- game/engine.py +46 -0
- tests/test_myco_core.py +42 -0
- ui/gradio_app.py +65 -37
- ui/renderers.py +50 -4
- ui/styles.py +61 -0
game/engine.py
CHANGED
|
@@ -16,6 +16,7 @@ RARITY_CLUES = {
|
|
| 16 |
"Rare": "Silver spores circle it in a pattern Myco has seen only in old forest stories.",
|
| 17 |
"Legendary": "The whole clearing goes quiet; this mushroom is hiding part of the Elder Map.",
|
| 18 |
}
|
|
|
|
| 19 |
|
| 20 |
|
| 21 |
def choose_mushroom(catalog=None):
|
|
@@ -33,6 +34,7 @@ def discover_mushroom(collection=None, catalog=None):
|
|
| 33 |
mushroom = choose_mushroom(catalog)
|
| 34 |
discovery_count = len(current_collection)
|
| 35 |
current = mushroom.to_dict()
|
|
|
|
| 36 |
current["clue"] = _mystery_clue(current, discovery_count)
|
| 37 |
current["secret"] = _secret_signal(current, discovery_count)
|
| 38 |
message = _discovery_reaction(current, discovery_count)
|
|
@@ -199,6 +201,45 @@ def collect_current(current=None, collection=None, history=None):
|
|
| 199 |
)
|
| 200 |
|
| 201 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
def study_current(current=None, history=None):
|
| 203 |
"""Study the current mushroom to reveal one cautious field observation."""
|
| 204 |
current_history = _safe_history(history)
|
|
@@ -289,3 +330,8 @@ def _secret_signal(current, collection_count):
|
|
| 289 |
if collection_count + 1 in (1, 3, 7, 12):
|
| 290 |
return "A hidden path symbol flickers at the page corner."
|
| 291 |
return "The page smells faintly of rain and moss."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
"Rare": "Silver spores circle it in a pattern Myco has seen only in old forest stories.",
|
| 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):
|
|
|
|
| 34 |
mushroom = choose_mushroom(catalog)
|
| 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)
|
|
|
|
| 201 |
)
|
| 202 |
|
| 203 |
|
| 204 |
+
def pick_current(current=None, collection=None, history=None):
|
| 205 |
+
"""Pick the current mushroom like a game item; poisonous picks end the run."""
|
| 206 |
+
current_collection = _safe_collection(collection)
|
| 207 |
+
current_history = _safe_history(history)
|
| 208 |
+
if current is None:
|
| 209 |
+
return current_collection, None, _append_assistant(
|
| 210 |
+
current_history,
|
| 211 |
+
"Move Myco, search a clearing, then pick the mushroom that appears.",
|
| 212 |
+
)
|
| 213 |
+
|
| 214 |
+
if _is_poisonous(current):
|
| 215 |
+
game_over = {**current, "danger": "Poisonous", "game_over": "Yes"}
|
| 216 |
+
return current_collection, game_over, _append_assistant(
|
| 217 |
+
current_history,
|
| 218 |
+
(
|
| 219 |
+
f"💀 GAME OVER — {current['name']} was poisonous. "
|
| 220 |
+
"Myco pulls you back, but this run is over. "
|
| 221 |
+
"Search a new clearing to try again."
|
| 222 |
+
),
|
| 223 |
+
)
|
| 224 |
+
|
| 225 |
+
picked = {**current, "picked": "Yes", "danger": "No obvious poison"}
|
| 226 |
+
if collection_contains(current_collection, picked["name"]):
|
| 227 |
+
return current_collection, picked, _append_assistant(
|
| 228 |
+
current_history,
|
| 229 |
+
f"{picked['name']} was already picked and logged in the MycoDex.",
|
| 230 |
+
)
|
| 231 |
+
|
| 232 |
+
updated_collection = [*current_collection, picked]
|
| 233 |
+
return updated_collection, picked, _append_assistant(
|
| 234 |
+
current_history,
|
| 235 |
+
(
|
| 236 |
+
f"🍄 Picked {picked['name']} safely! "
|
| 237 |
+
"Myco tucks the clue into the MycoDex. "
|
| 238 |
+
"Keep moving and pick the next clearing."
|
| 239 |
+
),
|
| 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)
|
|
|
|
| 330 |
if collection_count + 1 in (1, 3, 7, 12):
|
| 331 |
return "A hidden path symbol flickers at the page corner."
|
| 332 |
return "The page smells faintly of rain and moss."
|
| 333 |
+
|
| 334 |
+
|
| 335 |
+
def _is_poisonous(current):
|
| 336 |
+
"""Return whether the mushroom should trigger a game-over pick."""
|
| 337 |
+
return current.get("name", "") in POISONOUS_MUSHROOMS or current.get("danger") == "Poisonous"
|
tests/test_myco_core.py
CHANGED
|
@@ -16,6 +16,7 @@ from game.engine import (
|
|
| 16 |
eat_current,
|
| 17 |
hf_companion_status,
|
| 18 |
hf_model_id,
|
|
|
|
| 19 |
study_current,
|
| 20 |
)
|
| 21 |
from game.progression import current_area, next_area, next_mystery, revealed_mysteries
|
|
@@ -23,6 +24,7 @@ from ui.gradio_app import build_app, move_player
|
|
| 23 |
from ui.renderers import (
|
| 24 |
dex_markdown,
|
| 25 |
forest_scene,
|
|
|
|
| 26 |
game_status_markdown,
|
| 27 |
home_forest_markdown,
|
| 28 |
progress_markdown,
|
|
@@ -58,6 +60,13 @@ class MycoCoreTests(unittest.TestCase):
|
|
| 58 |
self.assertIn("clue", current)
|
| 59 |
self.assertIn("secret", current)
|
| 60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
def test_home_keeps_original_tree_and_mushroom_postcard(self):
|
| 62 |
home = home_forest_markdown()
|
| 63 |
|
|
@@ -210,6 +219,35 @@ class MycoCoreTests(unittest.TestCase):
|
|
| 210 |
self.assertEqual(duplicate_collection, collection)
|
| 211 |
self.assertIn("already", duplicate_history[-1]["content"])
|
| 212 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
def test_study_and_eat_are_safe(self):
|
| 214 |
_mushroom, current, history = discover_mushroom([])
|
| 215 |
studied, study_history = study_current(current, history)
|
|
@@ -277,6 +315,10 @@ class MycoCoreTests(unittest.TestCase):
|
|
| 277 |
self.assertIn('with gr.Tabs(selected="home") as tabs:', source)
|
| 278 |
self.assertIn('with gr.Tab("🎮 Play", id="play"):', source)
|
| 279 |
self.assertIn('start_play_button.click(open_play_tab, outputs=(tabs,))', source)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 280 |
|
| 281 |
def test_gradio_app_rejects_old_corrupted_callback_fragments(self):
|
| 282 |
source = Path("ui/gradio_app.py").read_text()
|
|
|
|
| 16 |
eat_current,
|
| 17 |
hf_companion_status,
|
| 18 |
hf_model_id,
|
| 19 |
+
pick_current,
|
| 20 |
study_current,
|
| 21 |
)
|
| 22 |
from game.progression import current_area, next_area, next_mystery, revealed_mysteries
|
|
|
|
| 24 |
from ui.renderers import (
|
| 25 |
dex_markdown,
|
| 26 |
forest_scene,
|
| 27 |
+
game_intro_markdown,
|
| 28 |
game_status_markdown,
|
| 29 |
home_forest_markdown,
|
| 30 |
progress_markdown,
|
|
|
|
| 60 |
self.assertIn("clue", current)
|
| 61 |
self.assertIn("secret", current)
|
| 62 |
|
| 63 |
+
def test_play_tab_has_game_hud(self):
|
| 64 |
+
hud = game_intro_markdown()
|
| 65 |
+
|
| 66 |
+
self.assertIn("game-hud-panel", hud)
|
| 67 |
+
self.assertIn("Wake the Whispering Ring", hud)
|
| 68 |
+
self.assertIn("Search", hud)
|
| 69 |
+
|
| 70 |
def test_home_keeps_original_tree_and_mushroom_postcard(self):
|
| 71 |
home = home_forest_markdown()
|
| 72 |
|
|
|
|
| 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",
|
| 225 |
+
"rarity": "Legendary",
|
| 226 |
+
"habitat": "fog pockets",
|
| 227 |
+
"lore": "Its gills vanish unless you look from the corner of your eye.",
|
| 228 |
+
"edible": "Unknown",
|
| 229 |
+
"magic": "Unknown",
|
| 230 |
+
"danger": "Unknown",
|
| 231 |
+
"clue": "A bad clue",
|
| 232 |
+
"secret": "A bad secret",
|
| 233 |
+
}
|
| 234 |
+
collection, picked, history = pick_current(poisonous, [], [])
|
| 235 |
+
|
| 236 |
+
self.assertEqual(collection, [])
|
| 237 |
+
assert picked is not None
|
| 238 |
+
self.assertEqual(picked["game_over"], "Yes")
|
| 239 |
+
self.assertIn("GAME OVER", history[-1]["content"])
|
| 240 |
+
|
| 241 |
+
def test_pick_current_collects_safe_mushroom(self):
|
| 242 |
+
_mushroom, current, history = discover_mushroom([])
|
| 243 |
+
current["name"] = "Glowcap"
|
| 244 |
+
collection, picked, history = pick_current(current, [], history)
|
| 245 |
+
|
| 246 |
+
self.assertEqual(len(collection), 1)
|
| 247 |
+
assert picked is not None
|
| 248 |
+
self.assertEqual(picked["picked"], "Yes")
|
| 249 |
+
self.assertIn("Picked", history[-1]["content"])
|
| 250 |
+
|
| 251 |
def test_study_and_eat_are_safe(self):
|
| 252 |
_mushroom, current, history = discover_mushroom([])
|
| 253 |
studied, study_history = study_current(current, history)
|
|
|
|
| 315 |
self.assertIn('with gr.Tabs(selected="home") as tabs:', source)
|
| 316 |
self.assertIn('with gr.Tab("🎮 Play", id="play"):', source)
|
| 317 |
self.assertIn('start_play_button.click(open_play_tab, outputs=(tabs,))', source)
|
| 318 |
+
self.assertIn('with gr.Group(elem_id="game-shell"):', source)
|
| 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()
|
ui/gradio_app.py
CHANGED
|
@@ -10,6 +10,7 @@ from game.engine import (
|
|
| 10 |
eat_current,
|
| 11 |
hf_companion_status,
|
| 12 |
myco_reply,
|
|
|
|
| 13 |
study_current,
|
| 14 |
)
|
| 15 |
from game.state import welcome_history
|
|
@@ -17,6 +18,7 @@ from models.mushroom import Mushroom
|
|
| 17 |
from ui.renderers import (
|
| 18 |
dex_markdown,
|
| 19 |
forest_scene,
|
|
|
|
| 20 |
game_status_markdown,
|
| 21 |
hero_markdown,
|
| 22 |
home_forest_markdown,
|
|
@@ -43,10 +45,10 @@ GUIDE_MARKDOWN = """
|
|
| 43 |
## How to play
|
| 44 |
|
| 45 |
1. Go to **🎮 Play**.
|
| 46 |
-
2. Use the
|
| 47 |
-
3. Click **
|
| 48 |
-
4.
|
| 49 |
-
5.
|
| 50 |
"""
|
| 51 |
|
| 52 |
|
|
@@ -96,6 +98,23 @@ def collect_discovery(current, collection, history, position):
|
|
| 96 |
)
|
| 97 |
|
| 98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
def study_discovery(current, history, collection, position):
|
| 100 |
"""Study the active mushroom and refresh the discovery card."""
|
| 101 |
updated_current, updated_history = study_current(current, history)
|
|
@@ -162,44 +181,48 @@ def build_app():
|
|
| 162 |
gr.Markdown(hf_companion_status(), elem_id="ai-status")
|
| 163 |
|
| 164 |
with gr.Tab("🎮 Play", id="play"):
|
|
|
|
| 165 |
gr.HTML(play_hook_markdown())
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
)
|
| 171 |
-
with gr.Row():
|
| 172 |
-
with gr.Column(scale=2):
|
| 173 |
-
discovery = gr.Markdown(
|
| 174 |
-
mushroom_card(None),
|
| 175 |
-
elem_id="discovery-card",
|
| 176 |
-
)
|
| 177 |
-
search_button = gr.Button("🌲 Explore the Forest", variant="primary")
|
| 178 |
-
with gr.Row():
|
| 179 |
-
north_button = gr.Button("▲")
|
| 180 |
-
with gr.Row():
|
| 181 |
-
west_button = gr.Button("◀")
|
| 182 |
-
east_button = gr.Button("▶")
|
| 183 |
with gr.Row():
|
| 184 |
-
|
| 185 |
with gr.Row():
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
with gr.Column(scale=3):
|
| 190 |
-
chat = gr.Chatbot(
|
| 191 |
-
value=cast(Any, welcome_history()),
|
| 192 |
-
label="Myco Chat",
|
| 193 |
-
height=360,
|
| 194 |
-
)
|
| 195 |
with gr.Row():
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
)
|
| 202 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
|
| 204 |
with gr.Tab("📖 MycoDex"):
|
| 205 |
with gr.Row():
|
|
@@ -252,6 +275,11 @@ def build_app():
|
|
| 252 |
inputs=(current_mushroom, collection, chat, player_position),
|
| 253 |
outputs=(collection, scene, status, dex, world_map, chat, progress),
|
| 254 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
study_button.click(
|
| 256 |
study_discovery,
|
| 257 |
inputs=(current_mushroom, chat, collection, player_position),
|
|
|
|
| 10 |
eat_current,
|
| 11 |
hf_companion_status,
|
| 12 |
myco_reply,
|
| 13 |
+
pick_current,
|
| 14 |
study_current,
|
| 15 |
)
|
| 16 |
from game.state import welcome_history
|
|
|
|
| 18 |
from ui.renderers import (
|
| 19 |
dex_markdown,
|
| 20 |
forest_scene,
|
| 21 |
+
game_intro_markdown,
|
| 22 |
game_status_markdown,
|
| 23 |
hero_markdown,
|
| 24 |
home_forest_markdown,
|
|
|
|
| 45 |
## How to play
|
| 46 |
|
| 47 |
1. Go to **🎮 Play**.
|
| 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 |
|
|
|
|
| 98 |
)
|
| 99 |
|
| 100 |
|
| 101 |
+
def pick_discovery(current, collection, history, position):
|
| 102 |
+
"""Pick the active mushroom as an in-game item with poison risk."""
|
| 103 |
+
updated_collection, updated_current, updated_history = pick_current(current, collection, history)
|
| 104 |
+
player_position = _safe_position(position)
|
| 105 |
+
return (
|
| 106 |
+
updated_collection,
|
| 107 |
+
updated_current,
|
| 108 |
+
forest_scene(updated_current, updated_collection, player_position),
|
| 109 |
+
game_status_markdown(updated_current, updated_collection, player_position),
|
| 110 |
+
mushroom_card_from_state(updated_current),
|
| 111 |
+
dex_markdown(updated_collection),
|
| 112 |
+
world_map_markdown(updated_collection),
|
| 113 |
+
updated_history,
|
| 114 |
+
progress_markdown(updated_collection),
|
| 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)
|
|
|
|
| 181 |
gr.Markdown(hf_companion_status(), elem_id="ai-status")
|
| 182 |
|
| 183 |
with gr.Tab("🎮 Play", id="play"):
|
| 184 |
+
gr.HTML(game_intro_markdown())
|
| 185 |
gr.HTML(play_hook_markdown())
|
| 186 |
+
with gr.Group(elem_id="game-shell"):
|
| 187 |
+
scene = gr.HTML(forest_scene(None, EMPTY_COLLECTION, START_POSITION))
|
| 188 |
+
with gr.Group(elem_id="near-monitor-controls"):
|
| 189 |
+
search_button = gr.Button("🎮 Search Clearing", variant="primary")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
with gr.Row():
|
| 191 |
+
north_button = gr.Button("⬆️")
|
| 192 |
with gr.Row():
|
| 193 |
+
west_button = gr.Button("⬅️")
|
| 194 |
+
pick_button = gr.Button("🍄 Pick", variant="primary")
|
| 195 |
+
east_button = gr.Button("➡️")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
with gr.Row():
|
| 197 |
+
south_button = gr.Button("⬇️")
|
| 198 |
+
status = gr.Markdown(
|
| 199 |
+
game_status_markdown(None, EMPTY_COLLECTION, START_POSITION),
|
| 200 |
+
elem_id="quest-log",
|
| 201 |
+
)
|
| 202 |
+
with gr.Row():
|
| 203 |
+
with gr.Column(scale=2):
|
| 204 |
+
discovery = gr.Markdown(
|
| 205 |
+
mushroom_card(None),
|
| 206 |
+
elem_id="discovery-card",
|
| 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):
|
| 213 |
+
chat = gr.Chatbot(
|
| 214 |
+
value=cast(Any, welcome_history()),
|
| 215 |
+
label="Myco Chat",
|
| 216 |
+
height=360,
|
| 217 |
)
|
| 218 |
+
with gr.Row():
|
| 219 |
+
prompt = gr.Textbox(
|
| 220 |
+
label="Ask Myco",
|
| 221 |
+
value="Myco, what do you sense about this mushroom?",
|
| 222 |
+
placeholder="Ask Myco what the forest is hiding",
|
| 223 |
+
scale=4,
|
| 224 |
+
)
|
| 225 |
+
ask_button = gr.Button("Ask Myco 🍄", scale=1)
|
| 226 |
|
| 227 |
with gr.Tab("📖 MycoDex"):
|
| 228 |
with gr.Row():
|
|
|
|
| 275 |
inputs=(current_mushroom, collection, chat, player_position),
|
| 276 |
outputs=(collection, scene, status, dex, world_map, chat, progress),
|
| 277 |
)
|
| 278 |
+
pick_button.click(
|
| 279 |
+
pick_discovery,
|
| 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),
|
ui/renderers.py
CHANGED
|
@@ -13,6 +13,13 @@ from game.progression import (
|
|
| 13 |
from game.state import CollectionState, EMPTY_DEX, MushroomState
|
| 14 |
from models.mushroom import Mushroom
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
def hero_markdown() -> str:
|
| 18 |
"""Render a polished first-impression hero panel."""
|
|
@@ -52,6 +59,25 @@ def home_forest_markdown() -> str:
|
|
| 52 |
"""
|
| 53 |
|
| 54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
def play_hook_markdown() -> str:
|
| 56 |
"""Render a compact first-30-seconds onboarding panel."""
|
| 57 |
return """
|
|
@@ -83,15 +109,22 @@ def forest_scene(
|
|
| 83 |
mushroom_name = "Hidden mushroom"
|
| 84 |
rarity = "Common"
|
| 85 |
sprite = "✨"
|
| 86 |
-
status = "The moss is listening. Click
|
| 87 |
omen = "Myco is waiting to sense the first spore."
|
| 88 |
else:
|
| 89 |
mushroom_name = current.get("name", "Mystery mushroom")
|
| 90 |
rarity = current.get("rarity", "Common")
|
| 91 |
sprite = _mushroom_sprite(rarity)
|
| 92 |
studied = current.get("studied") == "Yes"
|
|
|
|
| 93 |
status = f"A {rarity.lower()} {mushroom_name} breaks through the moss!"
|
|
|
|
|
|
|
| 94 |
omen = "New field note unlocked." if studied else "Ask Myco what the forest is hiding."
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
|
| 96 |
return f'''
|
| 97 |
<div class="forest-scene rarity-{escape(rarity.lower())} {position_class}">
|
|
@@ -157,14 +190,19 @@ def game_status_markdown(
|
|
| 157 |
mystery_line = _mystery_goal_line(active_mystery, count)
|
| 158 |
if current is None:
|
| 159 |
objective = "Goal: collect **3 clue-mushrooms** to wake the **Whispering Ring**."
|
| 160 |
-
discovery = "No active discovery yet. Move Myco, then
|
| 161 |
ai_job = "Myco's job: notice clues you would miss alone."
|
| 162 |
clue_line = mystery_line
|
| 163 |
else:
|
| 164 |
name = current.get("name", "Mystery mushroom")
|
| 165 |
studied = current.get("studied") == "Yes"
|
| 166 |
next_step = "Collect it to preserve the clue" if studied else "Ask Myco, then Study the clue"
|
| 167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
discovery = f"Active discovery: **{name}** · Rarity: **{current.get('rarity', 'Unknown')}**"
|
| 169 |
clue_line = f"**Clue:** {current.get('clue', 'Myco is still listening.')}"
|
| 170 |
ai_job = "Myco's job: interpret clues, warn you away from danger, and make discoveries feel alive."
|
|
@@ -186,7 +224,7 @@ def game_status_markdown(
|
|
| 186 |
def mushroom_card(mushroom: Mushroom | None, clue: str | None = None, secret: str | None = None) -> str:
|
| 187 |
"""Render the current mushroom discovery as markdown."""
|
| 188 |
if mushroom is None:
|
| 189 |
-
return "### 🌲 Forest Clearing\nClick **
|
| 190 |
|
| 191 |
return "\n".join(
|
| 192 |
(
|
|
@@ -197,6 +235,7 @@ def mushroom_card(mushroom: Mushroom | None, clue: str | None = None, secret: st
|
|
| 197 |
f"* **Edible:** {mushroom.edible}",
|
| 198 |
f"* **Magic:** {mushroom.magic}",
|
| 199 |
f"* **Danger:** {mushroom.danger}",
|
|
|
|
| 200 |
f"* **Clue:** {clue or 'Study with Myco to reveal the clue.'}",
|
| 201 |
f"* **Secret signal:** {secret or 'Collect it to see how the MycoDex reacts.'}",
|
| 202 |
"",
|
|
@@ -205,6 +244,13 @@ def mushroom_card(mushroom: Mushroom | None, clue: str | None = None, secret: st
|
|
| 205 |
)
|
| 206 |
|
| 207 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
def world_map_markdown(collection: CollectionState | None) -> str:
|
| 209 |
"""Render a game-like world map with unlocks and achievements."""
|
| 210 |
count = len(_safe_collection(collection))
|
|
|
|
| 13 |
from game.state import CollectionState, EMPTY_DEX, MushroomState
|
| 14 |
from models.mushroom import Mushroom
|
| 15 |
|
| 16 |
+
POISONOUS_MUSHROOM_NAMES = {
|
| 17 |
+
"Ghost Gill",
|
| 18 |
+
"Pepper Pixie",
|
| 19 |
+
"Ruby Knuckle",
|
| 20 |
+
"Clockwork Chanterelle",
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
|
| 24 |
def hero_markdown() -> str:
|
| 25 |
"""Render a polished first-impression hero panel."""
|
|
|
|
| 59 |
"""
|
| 60 |
|
| 61 |
|
| 62 |
+
def game_intro_markdown() -> str:
|
| 63 |
+
"""Render a video-game-style mission HUD for the Play tab."""
|
| 64 |
+
return """
|
| 65 |
+
<div class="game-hud-panel">
|
| 66 |
+
<div>
|
| 67 |
+
<p class="eyebrow">Mission</p>
|
| 68 |
+
<h2>Wake the Whispering Ring</h2>
|
| 69 |
+
<p>Move Myco through the forest, search each clearing, and collect 3 clue-mushrooms.</p>
|
| 70 |
+
</div>
|
| 71 |
+
<div class="game-hud-stats">
|
| 72 |
+
<span>🎮 Move</span>
|
| 73 |
+
<span>🔎 Search</span>
|
| 74 |
+
<span>🍄 Ask Myco</span>
|
| 75 |
+
<span>📖 Collect clues</span>
|
| 76 |
+
</div>
|
| 77 |
+
</div>
|
| 78 |
+
"""
|
| 79 |
+
|
| 80 |
+
|
| 81 |
def play_hook_markdown() -> str:
|
| 82 |
"""Render a compact first-30-seconds onboarding panel."""
|
| 83 |
return """
|
|
|
|
| 109 |
mushroom_name = "Hidden mushroom"
|
| 110 |
rarity = "Common"
|
| 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 |
else:
|
| 115 |
mushroom_name = current.get("name", "Mystery mushroom")
|
| 116 |
rarity = current.get("rarity", "Common")
|
| 117 |
sprite = _mushroom_sprite(rarity)
|
| 118 |
studied = current.get("studied") == "Yes"
|
| 119 |
+
game_over = current.get("game_over") == "Yes"
|
| 120 |
status = f"A {rarity.lower()} {mushroom_name} breaks through the moss!"
|
| 121 |
+
if game_over:
|
| 122 |
+
status = f"GAME OVER: {mushroom_name} was poisonous."
|
| 123 |
omen = "New field note unlocked." if studied else "Ask Myco what the forest is hiding."
|
| 124 |
+
if current.get("picked") == "Yes":
|
| 125 |
+
omen = "Picked safely. Move to another clearing for the next mushroom."
|
| 126 |
+
if game_over:
|
| 127 |
+
omen = "Press Search Clearing to start a new run."
|
| 128 |
|
| 129 |
return f'''
|
| 130 |
<div class="forest-scene rarity-{escape(rarity.lower())} {position_class}">
|
|
|
|
| 190 |
mystery_line = _mystery_goal_line(active_mystery, count)
|
| 191 |
if current is None:
|
| 192 |
objective = "Goal: collect **3 clue-mushrooms** to wake the **Whispering Ring**."
|
| 193 |
+
discovery = "No active discovery yet. Move Myco, then Search Clearing."
|
| 194 |
ai_job = "Myco's job: notice clues you would miss alone."
|
| 195 |
clue_line = mystery_line
|
| 196 |
else:
|
| 197 |
name = current.get("name", "Mystery mushroom")
|
| 198 |
studied = current.get("studied") == "Yes"
|
| 199 |
next_step = "Collect it to preserve the clue" if studied else "Ask Myco, then Study the clue"
|
| 200 |
+
if current.get("game_over") == "Yes":
|
| 201 |
+
objective = "**GAME OVER:** press **Search Clearing** to start a new run."
|
| 202 |
+
elif current.get("picked") == "Yes":
|
| 203 |
+
objective = "Current objective: **move to the next clearing and search again**."
|
| 204 |
+
else:
|
| 205 |
+
objective = f"Current objective: **{next_step}**."
|
| 206 |
discovery = f"Active discovery: **{name}** · Rarity: **{current.get('rarity', 'Unknown')}**"
|
| 207 |
clue_line = f"**Clue:** {current.get('clue', 'Myco is still listening.')}"
|
| 208 |
ai_job = "Myco's job: interpret clues, warn you away from danger, and make discoveries feel alive."
|
|
|
|
| 224 |
def mushroom_card(mushroom: Mushroom | None, clue: str | None = None, secret: str | None = None) -> str:
|
| 225 |
"""Render the current mushroom discovery as markdown."""
|
| 226 |
if mushroom is None:
|
| 227 |
+
return "### 🌲 Forest Clearing\nClick **Search Clearing** to wake a strange fungus."
|
| 228 |
|
| 229 |
return "\n".join(
|
| 230 |
(
|
|
|
|
| 235 |
f"* **Edible:** {mushroom.edible}",
|
| 236 |
f"* **Magic:** {mushroom.magic}",
|
| 237 |
f"* **Danger:** {mushroom.danger}",
|
| 238 |
+
f"* **Poison risk:** {_poison_risk_label(mushroom.name)}",
|
| 239 |
f"* **Clue:** {clue or 'Study with Myco to reveal the clue.'}",
|
| 240 |
f"* **Secret signal:** {secret or 'Collect it to see how the MycoDex reacts.'}",
|
| 241 |
"",
|
|
|
|
| 244 |
)
|
| 245 |
|
| 246 |
|
| 247 |
+
def _poison_risk_label(name: str) -> str:
|
| 248 |
+
"""Return the platformer-style pickup risk label."""
|
| 249 |
+
if name in POISONOUS_MUSHROOM_NAMES:
|
| 250 |
+
return "Possible game over"
|
| 251 |
+
return "No obvious poison"
|
| 252 |
+
|
| 253 |
+
|
| 254 |
def world_map_markdown(collection: CollectionState | None) -> str:
|
| 255 |
"""Render a game-like world map with unlocks and achievements."""
|
| 256 |
count = len(_safe_collection(collection))
|
ui/styles.py
CHANGED
|
@@ -249,6 +249,67 @@ APP_CSS = """
|
|
| 249 |
50% { transform: translateY(-0.24rem) scale(1.04); }
|
| 250 |
}
|
| 251 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
.play-hook {
|
| 253 |
margin-bottom: 1rem;
|
| 254 |
padding: 1.1rem 1.25rem;
|
|
|
|
| 249 |
50% { transform: translateY(-0.24rem) scale(1.04); }
|
| 250 |
}
|
| 251 |
|
| 252 |
+
|
| 253 |
+
.game-hud-panel {
|
| 254 |
+
display: flex;
|
| 255 |
+
justify-content: space-between;
|
| 256 |
+
gap: 1rem;
|
| 257 |
+
align-items: center;
|
| 258 |
+
margin: 0 0 1rem;
|
| 259 |
+
padding: 1rem 1.15rem;
|
| 260 |
+
border: 1px solid rgba(255, 244, 190, 0.34);
|
| 261 |
+
border-radius: 24px;
|
| 262 |
+
background: linear-gradient(135deg, rgba(16, 40, 31, 0.98), rgba(51, 82, 48, 0.94));
|
| 263 |
+
box-shadow: 0 18px 48px rgba(8, 30, 20, 0.22);
|
| 264 |
+
color: #f9ffe9 !important;
|
| 265 |
+
}
|
| 266 |
+
.game-hud-panel h2,
|
| 267 |
+
.game-hud-panel p,
|
| 268 |
+
.game-hud-panel span {
|
| 269 |
+
color: #f9ffe9 !important;
|
| 270 |
+
}
|
| 271 |
+
.game-hud-panel h2 {
|
| 272 |
+
margin: 0.15rem 0 0.3rem;
|
| 273 |
+
}
|
| 274 |
+
.game-hud-stats {
|
| 275 |
+
display: grid;
|
| 276 |
+
grid-template-columns: repeat(2, minmax(8rem, 1fr));
|
| 277 |
+
gap: 0.45rem;
|
| 278 |
+
}
|
| 279 |
+
.game-hud-stats span {
|
| 280 |
+
border: 1px solid rgba(255, 255, 255, 0.18);
|
| 281 |
+
border-radius: 999px;
|
| 282 |
+
background: rgba(255, 255, 255, 0.1);
|
| 283 |
+
font-weight: 900;
|
| 284 |
+
padding: 0.45rem 0.65rem;
|
| 285 |
+
text-align: center;
|
| 286 |
+
}
|
| 287 |
+
#game-shell {
|
| 288 |
+
padding: 1rem;
|
| 289 |
+
border: 1px solid rgba(255, 244, 190, 0.28);
|
| 290 |
+
border-radius: 30px;
|
| 291 |
+
background:
|
| 292 |
+
radial-gradient(circle at 50% 0%, rgba(255, 244, 190, 0.13), transparent 18rem),
|
| 293 |
+
linear-gradient(180deg, rgba(8, 26, 19, 0.92), rgba(20, 49, 35, 0.82));
|
| 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;
|
| 300 |
+
border: 1px solid rgba(255, 244, 190, 0.26);
|
| 301 |
+
border-radius: 20px;
|
| 302 |
+
background: rgba(13, 38, 28, 0.52);
|
| 303 |
+
}
|
| 304 |
+
#near-monitor-controls button {
|
| 305 |
+
min-height: 3rem;
|
| 306 |
+
font-size: 1.05rem !important;
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
#game-shell button {
|
| 310 |
+
font-weight: 900 !important;
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
.play-hook {
|
| 314 |
margin-bottom: 1rem;
|
| 315 |
padding: 1.1rem 1.25rem;
|