awacke1 commited on
Commit
e898f75
Β·
1 Parent(s): 6f39e61

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -22
app.py CHANGED
@@ -50,43 +50,47 @@ if game_state is None:
50
  'wildlife_stack': random.sample(wildlife_tokens * 10, 50),
51
  'players': {player: {'habitat': [], 'wildlife': [], 'nature_tokens': 3} for player in players}
52
  }
 
53
 
54
  # Streamlit Interface
55
  st.title("🌲 Cascadia Lite 🌲")
56
 
57
  # Function to draw habitat and wildlife
58
- def draw_habitat_and_wildlife(player):
59
- habitat = st.session_state['habitat_stack'].pop()
60
- wildlife = st.session_state['wildlife_stack'].pop()
61
- st.session_state['players'][player]['habitat'].append(habitat)
62
- st.session_state['players'][player]['wildlife'].append(wildlife)
 
63
 
64
- # Display players' areas
65
  for player in players:
66
  st.write(f"## {player}'s Play Area")
67
- player_data = pd.DataFrame({'Habitat Tiles': st.session_state['players'][player]['habitat'],
68
- 'Wildlife Tokens': st.session_state['players'][player]['wildlife']})
69
  st.dataframe(player_data)
70
 
71
  # Drafting Phase
72
  if st.button(f"{player}: Draw Habitat and Wildlife"):
73
- draw_habitat_and_wildlife(player)
 
74
 
75
- # Tile Placement
76
- tile_placement = st.selectbox(f"{player}: Place Habitat Tile", options=['Select Position'] + list(range(1, len(st.session_state['players'][player]['habitat']) + 1)))
77
-
78
- # Wildlife Placement
79
- wildlife_placement = st.selectbox(f"{player}: Place Wildlife Token", options=['Select Habitat'] + list(range(1, len(st.session_state['players'][player]['wildlife']) + 1)))
80
 
81
- # Nature Tokens
82
- if st.session_state['players'][player]['nature_tokens'] > 0:
83
- if st.button(f"{player}: Use a Nature Token"):
84
- st.session_state['players'][player]['nature_tokens'] -= 1
85
- # Logic for swapping wildlife tokens or other actions
86
- st.write(f"{player} used a nature token. Remaining: {st.session_state['players'][player]['nature_tokens']}")
87
 
88
- # Save game state
89
- save_game_state()
 
 
 
 
 
 
 
 
90
 
91
  # Game Controls and Instructions
92
  st.write("## Game Controls")
 
50
  'wildlife_stack': random.sample(wildlife_tokens * 10, 50),
51
  'players': {player: {'habitat': [], 'wildlife': [], 'nature_tokens': 3} for player in players}
52
  }
53
+ save_game_state(game_state)
54
 
55
  # Streamlit Interface
56
  st.title("🌲 Cascadia Lite 🌲")
57
 
58
  # Function to draw habitat and wildlife
59
+ def draw_habitat_and_wildlife(player, game_state):
60
+ habitat = game_state['habitat_stack'].pop()
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
+ # Display players' areas and handle actions
67
  for player in players:
68
  st.write(f"## {player}'s Play Area")
69
+ player_data = pd.DataFrame({'Habitat Tiles': game_state['players'][player]['habitat'],
70
+ 'Wildlife Tokens': game_state['players'][player]['wildlife']})
71
  st.dataframe(player_data)
72
 
73
  # Drafting Phase
74
  if st.button(f"{player}: Draw Habitat and Wildlife"):
75
+ draw_habitat_and_wildlife(player, game_state)
76
+ game_state = load_game_state() # Reload game state after update
77
 
78
+ # Tile and Wildlife Placement (Placeholders for actual game logic)
79
+ # ... (Add selectbox and logic for tile and wildlife placement)
 
 
 
80
 
81
+ # Nature Tokens (Placeholder for actual game logic)
82
+ # ... (Add button and logic for using nature tokens)
 
 
 
 
83
 
84
+ # Reset Button
85
+ if st.button("Reset Game"):
86
+ os.remove(save_file) # Delete the save file
87
+ game_state = {
88
+ 'habitat_stack': random.sample(habitat_tiles * 10, 50),
89
+ 'wildlife_stack': random.sample(wildlife_tokens * 10, 50),
90
+ 'players': {player: {'habitat': [], 'wildlife': [], 'nature_tokens': 3} for player in players}
91
+ }
92
+ save_game_state(game_state)
93
+ st.experimental_rerun()
94
 
95
  # Game Controls and Instructions
96
  st.write("## Game Controls")