Spaces:
Runtime error
Runtime error
import streamlit as st | |
import random | |
import pandas as pd | |
# Cascadia Game Components | |
habitat_tiles = ['π²', 'ποΈ', 'π', 'π΅', 'π'] # Representing different habitats | |
wildlife_tokens = ['π»', 'π¦ ', 'π', 'π¦', 'πΏοΈ'] # Different wildlife | |
nature_tokens = 'π' # Nature tokens | |
# Initialize game state | |
if 'habitat_stack' not in st.session_state: | |
st.session_state['habitat_stack'] = random.sample(habitat_tiles * 10, 50) | |
if 'wildlife_stack' not in st.session_state: | |
st.session_state['wildlife_stack'] = random.sample(wildlife_tokens * 10, 50) | |
if 'player_area' not in st.session_state: | |
st.session_state['player_area'] = {'habitat': [], 'wildlife': []} | |
if 'nature_tokens' not in st.session_state: | |
st.session_state['nature_tokens'] = 0 | |
# Function to draw habitat and wildlife | |
def draw_habitat_and_wildlife(): | |
if st.session_state.habitat_stack and st.session_state.wildlife_stack: | |
habitat = st.session_state.habitat_stack.pop() | |
wildlife = st.session_state.wildlife_stack.pop() | |
return habitat, wildlife | |
else: | |
return None, None | |
# Display game board | |
st.title("π² Cascadia Lite π²") | |
st.write("## Your Play Area") | |
col1, col2 = st.columns(2) | |
with col1: | |
st.write("Habitat Tiles") | |
st.write(' '.join(st.session_state.player_area['habitat'])) | |
with col2: | |
st.write("Wildlife Tokens") | |
st.write(' '.join(st.session_state.player_area['wildlife'])) | |
# Drafting phase | |
st.write("## Drafting Phase") | |
if st.button("Draw Habitat and Wildlife"): | |
habitat, wildlife = draw_habitat_and_wildlife() | |
if habitat and wildlife: | |
st.session_state.player_area['habitat'].append(habitat) | |
st.session_state.player_area['wildlife'].append(wildlife) | |
st.write(f"Drawn Habitat: {habitat}, Wildlife: {wildlife}") | |
else: | |
st.write("No more tiles or tokens to draw!") | |
# Scoring (Placeholder for actual scoring logic) | |
st.write("## Scoring") | |
st.write("Your score will be calculated here.") | |
# End of Game (Placeholder) | |
st.write("## End of Game") | |
st.write("Final score and winner announcement will be displayed here.") | |
# Run the Streamlit app | |
st.write("## Game Controls") | |
st.write("Use the buttons and controls to play the game!") | |