Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,7 +33,7 @@ MONSTERS = {
|
|
| 33 |
"Gorgon": {"Picture": "πποΈβπ¨οΈ", "Description": "A creature with the body of a lion and the head of a snake, whose gaze can turn people to stone.", "Attack": 6, "Defense": 4},
|
| 34 |
}
|
| 35 |
|
| 36 |
-
def
|
| 37 |
monster_name = st.session_state.selected_monster
|
| 38 |
if monster_name:
|
| 39 |
monster = MONSTERS[monster_name]
|
|
@@ -45,6 +45,29 @@ def get_random_monster():
|
|
| 45 |
else:
|
| 46 |
return None
|
| 47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
def save_data():
|
| 49 |
data = pd.DataFrame.from_dict(st.session_state.players, orient="index")
|
| 50 |
filename = "player_data.csv"
|
|
|
|
| 33 |
"Gorgon": {"Picture": "πποΈβπ¨οΈ", "Description": "A creature with the body of a lion and the head of a snake, whose gaze can turn people to stone.", "Attack": 6, "Defense": 4},
|
| 34 |
}
|
| 35 |
|
| 36 |
+
def get_random_monster_old():
|
| 37 |
monster_name = st.session_state.selected_monster
|
| 38 |
if monster_name:
|
| 39 |
monster = MONSTERS[monster_name]
|
|
|
|
| 45 |
else:
|
| 46 |
return None
|
| 47 |
|
| 48 |
+
def get_random_monster():
|
| 49 |
+
monster_name = st.session_state.selected_monster
|
| 50 |
+
if monster_name:
|
| 51 |
+
monster = MONSTERS[monster_name]
|
| 52 |
+
st.write("Picture: ", monster["Picture"])
|
| 53 |
+
st.write("Description: ", monster["Description"])
|
| 54 |
+
st.write("Attack: ", monster["Attack"])
|
| 55 |
+
st.write("Defense: ", monster["Defense"])
|
| 56 |
+
return monster
|
| 57 |
+
else:
|
| 58 |
+
# Select a random monster based on its size
|
| 59 |
+
monster_sizes = [monster_data["Attack"] + monster_data["Defense"] for monster_data in MONSTERS.values()]
|
| 60 |
+
selected_size = random.choice(monster_sizes)
|
| 61 |
+
monster_names = [monster_name for monster_name, monster_data in MONSTERS.items() if monster_data["Attack"] + monster_data["Defense"] == selected_size]
|
| 62 |
+
selected_monster = random.choice(monster_names)
|
| 63 |
+
st.session_state.selected_monster = selected_monster
|
| 64 |
+
monster = MONSTERS[selected_monster]
|
| 65 |
+
st.write("Picture: ", monster["Picture"])
|
| 66 |
+
st.write("Description: ", monster["Description"])
|
| 67 |
+
st.write("Attack: ", monster["Attack"])
|
| 68 |
+
st.write("Defense: ", monster["Defense"])
|
| 69 |
+
return monster
|
| 70 |
+
|
| 71 |
def save_data():
|
| 72 |
data = pd.DataFrame.from_dict(st.session_state.players, orient="index")
|
| 73 |
filename = "player_data.csv"
|