Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -61,8 +61,18 @@ def draw_habitat_and_wildlife(player, game_state):
|
|
| 61 |
wildlife = game_state['wildlife_stack'].pop()
|
| 62 |
game_state['players'][player]['habitat'].append(habitat)
|
| 63 |
game_state['players'][player]['wildlife'].append(wildlife)
|
|
|
|
|
|
|
|
|
|
| 64 |
save_game_state(game_state)
|
| 65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
# Display players' areas and handle actions
|
| 68 |
col1, col2 = st.columns(2)
|
|
@@ -75,11 +85,15 @@ for index, player in enumerate(players):
|
|
| 75 |
})
|
| 76 |
st.dataframe(player_data)
|
| 77 |
|
| 78 |
-
#
|
|
|
|
|
|
|
| 79 |
if st.button(f"{player}: Draw Habitat and Wildlife"):
|
| 80 |
draw_habitat_and_wildlife(player, game_state)
|
| 81 |
game_state = load_game_state()
|
| 82 |
|
|
|
|
|
|
|
| 83 |
# Tile and Wildlife Placement
|
| 84 |
placement_options = ['Place Habitat', 'Place Wildlife', 'Skip']
|
| 85 |
placement_choice = st.selectbox(f"{player}: Choose an action", placement_options, key=f'placement_{player}')
|
|
|
|
| 61 |
wildlife = game_state['wildlife_stack'].pop()
|
| 62 |
game_state['players'][player]['habitat'].append(habitat)
|
| 63 |
game_state['players'][player]['wildlife'].append(wildlife)
|
| 64 |
+
# Calculate and update score
|
| 65 |
+
score = calculate_score(habitat, wildlife)
|
| 66 |
+
game_state['players'][player]['score'] += score
|
| 67 |
save_game_state(game_state)
|
| 68 |
|
| 69 |
+
# Function to change wildlife
|
| 70 |
+
def change_wildlife(player, game_state):
|
| 71 |
+
if game_state['players'][player]['wildlife']:
|
| 72 |
+
game_state['players'][player]['wildlife'][-1] = random.choice(wildlife_tokens)
|
| 73 |
+
save_game_state(game_state)
|
| 74 |
+
else:
|
| 75 |
+
st.warning(f"{player}, you have no wildlife to change!")
|
| 76 |
|
| 77 |
# Display players' areas and handle actions
|
| 78 |
col1, col2 = st.columns(2)
|
|
|
|
| 85 |
})
|
| 86 |
st.dataframe(player_data)
|
| 87 |
|
| 88 |
+
# Display current score
|
| 89 |
+
st.write(f"Current Score: {game_state['players'][player]['score']}")
|
| 90 |
+
|
| 91 |
if st.button(f"{player}: Draw Habitat and Wildlife"):
|
| 92 |
draw_habitat_and_wildlife(player, game_state)
|
| 93 |
game_state = load_game_state()
|
| 94 |
|
| 95 |
+
|
| 96 |
+
|
| 97 |
# Tile and Wildlife Placement
|
| 98 |
placement_options = ['Place Habitat', 'Place Wildlife', 'Skip']
|
| 99 |
placement_choice = st.selectbox(f"{player}: Choose an action", placement_options, key=f'placement_{player}')
|