Spaces:
Sleeping
Sleeping
Deploy Myco from CI
Browse files- ui/renderers.py +1 -35
ui/renderers.py
CHANGED
|
@@ -297,14 +297,6 @@ def play_hook_markdown() -> str:
|
|
| 297 |
</div>
|
| 298 |
"""
|
| 299 |
|
| 300 |
-
import hashlib
|
| 301 |
-
|
| 302 |
-
def get_procedural_mushroom(name: str) -> str:
|
| 303 |
-
"""Generates a procedural mushroom sprite based on the name."""
|
| 304 |
-
hash_val = int(hashlib.md5(name.encode('utf-8')).hexdigest(), 16)
|
| 305 |
-
hue = (hash_val % 360)
|
| 306 |
-
return f'<span style="filter: hue-rotate({hue}deg); display: inline-block;">π</span>'
|
| 307 |
-
|
| 308 |
def forest_scene(
|
| 309 |
current: MushroomState | None,
|
| 310 |
collection: CollectionState | None,
|
|
@@ -331,14 +323,7 @@ def forest_scene(
|
|
| 331 |
else:
|
| 332 |
mushroom_name = current.get("name", "Mystery mushroom")
|
| 333 |
rarity = current.get("rarity", "Common").lower()
|
| 334 |
-
|
| 335 |
-
# --- ADDED LOGIC START ---
|
| 336 |
-
if mushroom_name == "Mystery mushroom":
|
| 337 |
-
sprite = "πβπ«"
|
| 338 |
-
else:
|
| 339 |
-
sprite = get_procedural_mushroom(mushroom_name)
|
| 340 |
-
# --- ADDED LOGIC END ---
|
| 341 |
-
|
| 342 |
game_over = current.get("game_over") == "Yes"
|
| 343 |
studied = current.get("studied") == "Yes"
|
| 344 |
event_label = f"{current.get('event_emoji','β¨')} {current.get('event_title','Strange Omen')}"
|
|
@@ -604,23 +589,4 @@ def game_intro_markdown() -> str:
|
|
| 604 |
</p>
|
| 605 |
</div>
|
| 606 |
"""
|
| 607 |
-
|
| 608 |
-
def get_emerging_mushroom_html(name: str) -> str:
|
| 609 |
-
"""
|
| 610 |
-
Generates a unique procedural mushroom sprite for the emerging state.
|
| 611 |
-
Uses the name hash to determine color and hue shift.
|
| 612 |
-
"""
|
| 613 |
-
hash_val = int(hashlib.md5(name.encode('utf-8')).hexdigest(), 16)
|
| 614 |
-
|
| 615 |
-
# Procedural color logic based on the name
|
| 616 |
-
hue = (hash_val % 360)
|
| 617 |
-
saturation = 60 + (hash_val % 30)
|
| 618 |
-
lightness = 40 + (hash_val % 20)
|
| 619 |
|
| 620 |
-
# This generates the HTML sprite using a CSS filter for consistent color variety
|
| 621 |
-
return (
|
| 622 |
-
f'<div class="mushroom-sprite" '
|
| 623 |
-
f'style="filter: hue-rotate({hue}deg) saturate({saturation}%) brightness({lightness}%); '
|
| 624 |
-
f'display: inline-block; transition: transform 0.3s ease;" '
|
| 625 |
-
f'title="{escape(name)}">π</div>'
|
| 626 |
-
)
|
|
|
|
| 297 |
</div>
|
| 298 |
"""
|
| 299 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 300 |
def forest_scene(
|
| 301 |
current: MushroomState | None,
|
| 302 |
collection: CollectionState | None,
|
|
|
|
| 323 |
else:
|
| 324 |
mushroom_name = current.get("name", "Mystery mushroom")
|
| 325 |
rarity = current.get("rarity", "Common").lower()
|
| 326 |
+
sprite = "πβπ«"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 327 |
game_over = current.get("game_over") == "Yes"
|
| 328 |
studied = current.get("studied") == "Yes"
|
| 329 |
event_label = f"{current.get('event_emoji','β¨')} {current.get('event_title','Strange Omen')}"
|
|
|
|
| 589 |
</p>
|
| 590 |
</div>
|
| 591 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 592 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|