Spaces:
Runtime error
Runtime error
Create backup.app.py
Browse files- backup.app.py +61 -0
backup.app.py
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import random
|
3 |
+
import pandas as pd
|
4 |
+
|
5 |
+
# Cascadia Game Components
|
6 |
+
habitat_tiles = ['π²', 'ποΈ', 'π', 'π΅', 'π'] # Representing different habitats
|
7 |
+
wildlife_tokens = ['π»', 'π¦
', 'π', 'π¦', 'πΏοΈ'] # Different wildlife
|
8 |
+
nature_tokens = 'π' # Nature tokens
|
9 |
+
|
10 |
+
# Initialize game state
|
11 |
+
if 'habitat_stack' not in st.session_state:
|
12 |
+
st.session_state['habitat_stack'] = random.sample(habitat_tiles * 10, 50)
|
13 |
+
if 'wildlife_stack' not in st.session_state:
|
14 |
+
st.session_state['wildlife_stack'] = random.sample(wildlife_tokens * 10, 50)
|
15 |
+
if 'player_area' not in st.session_state:
|
16 |
+
st.session_state['player_area'] = {'habitat': [], 'wildlife': []}
|
17 |
+
if 'nature_tokens' not in st.session_state:
|
18 |
+
st.session_state['nature_tokens'] = 0
|
19 |
+
|
20 |
+
# Function to draw habitat and wildlife
|
21 |
+
def draw_habitat_and_wildlife():
|
22 |
+
if st.session_state.habitat_stack and st.session_state.wildlife_stack:
|
23 |
+
habitat = st.session_state.habitat_stack.pop()
|
24 |
+
wildlife = st.session_state.wildlife_stack.pop()
|
25 |
+
return habitat, wildlife
|
26 |
+
else:
|
27 |
+
return None, None
|
28 |
+
|
29 |
+
# Display game board
|
30 |
+
st.title("π² Cascadia Lite π²")
|
31 |
+
st.write("## Your Play Area")
|
32 |
+
col1, col2 = st.columns(2)
|
33 |
+
with col1:
|
34 |
+
st.write("Habitat Tiles")
|
35 |
+
st.write(' '.join(st.session_state.player_area['habitat']))
|
36 |
+
with col2:
|
37 |
+
st.write("Wildlife Tokens")
|
38 |
+
st.write(' '.join(st.session_state.player_area['wildlife']))
|
39 |
+
|
40 |
+
# Drafting phase
|
41 |
+
st.write("## Drafting Phase")
|
42 |
+
if st.button("Draw Habitat and Wildlife"):
|
43 |
+
habitat, wildlife = draw_habitat_and_wildlife()
|
44 |
+
if habitat and wildlife:
|
45 |
+
st.session_state.player_area['habitat'].append(habitat)
|
46 |
+
st.session_state.player_area['wildlife'].append(wildlife)
|
47 |
+
st.write(f"Drawn Habitat: {habitat}, Wildlife: {wildlife}")
|
48 |
+
else:
|
49 |
+
st.write("No more tiles or tokens to draw!")
|
50 |
+
|
51 |
+
# Scoring (Placeholder for actual scoring logic)
|
52 |
+
st.write("## Scoring")
|
53 |
+
st.write("Your score will be calculated here.")
|
54 |
+
|
55 |
+
# End of Game (Placeholder)
|
56 |
+
st.write("## End of Game")
|
57 |
+
st.write("Final score and winner announcement will be displayed here.")
|
58 |
+
|
59 |
+
# Run the Streamlit app
|
60 |
+
st.write("## Game Controls")
|
61 |
+
st.write("Use the buttons and controls to play the game!")
|