Spaces:
Sleeping
Sleeping
Deploy Myco from CI
Browse files- game/engine.py +8 -0
game/engine.py
CHANGED
|
@@ -759,6 +759,14 @@ def check_auto_pickup(new_pos_x, new_pos_y, current, collection, active_mushroom
|
|
| 759 |
Check if Myco stepped on any mushroom in active_mushrooms.
|
| 760 |
Returns (current, collection, active_mushrooms) — all three updated.
|
| 761 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 762 |
if active_mushrooms is None:
|
| 763 |
# Fallback: try reading from current dict (legacy path)
|
| 764 |
active_mushrooms = (current or {}).get("active_mushrooms", [])
|
|
|
|
| 759 |
Check if Myco stepped on any mushroom in active_mushrooms.
|
| 760 |
Returns (current, collection, active_mushrooms) — all three updated.
|
| 761 |
"""
|
| 762 |
+
if isinstance(current, str):
|
| 763 |
+
try:
|
| 764 |
+
current = json.loads(current)
|
| 765 |
+
except json.JSONDecodeError:
|
| 766 |
+
current = {}
|
| 767 |
+
elif current is None:
|
| 768 |
+
current = {}
|
| 769 |
+
|
| 770 |
if active_mushrooms is None:
|
| 771 |
# Fallback: try reading from current dict (legacy path)
|
| 772 |
active_mushrooms = (current or {}).get("active_mushrooms", [])
|