File size: 2,520 Bytes
4632fbc
 
091bf0d
4632fbc
 
091bf0d
 
 
81ae0d1
4632fbc
81ae0d1
 
4632fbc
 
091bf0d
81ae0d1
 
091bf0d
81ae0d1
 
4632fbc
81ae0d1
091bf0d
 
 
 
 
 
81ae0d1
091bf0d
81ae0d1
091bf0d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81ae0d1
 
091bf0d
 
4632fbc
091bf0d
4632fbc
091bf0d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import streamlit as st
import random
import pandas as pd

# Cascadia Game Components
habitat_tiles = ['🌲', '🏞️', '🌊', '🌡', 'πŸŒ„']
wildlife_tokens = ['🐻', 'πŸ¦…', '🐟', '🦌', '🐿️']
players = ['Player 1', 'Player 2']
save_file = 'cascadia_game_state.txt'

# Initialize or load game state
def initialize_game():
    st.session_state['habitat_stack'] = random.sample(habitat_tiles * 10, 50)
    st.session_state['wildlife_stack'] = random.sample(wildlife_tokens * 10, 50)
    st.session_state['players'] = {player: {'habitat': [], 'wildlife': [], 'nature_tokens': 3} for player in players}

if 'habitat_stack' not in st.session_state:
    initialize_game()

# Streamlit Interface
st.title("🌲 Cascadia Lite 🌲")

# Function to draw habitat and wildlife
def draw_habitat_and_wildlife(player):
    habitat = st.session_state['habitat_stack'].pop()
    wildlife = st.session_state['wildlife_stack'].pop()
    st.session_state['players'][player]['habitat'].append(habitat)
    st.session_state['players'][player]['wildlife'].append(wildlife)

# Display players' areas
for player in players:
    st.write(f"## {player}'s Play Area")
    player_data = pd.DataFrame({'Habitat Tiles': st.session_state['players'][player]['habitat'], 
                                'Wildlife Tokens': st.session_state['players'][player]['wildlife']})
    st.dataframe(player_data)

    # Drafting Phase
    if st.button(f"{player}: Draw Habitat and Wildlife"):
        draw_habitat_and_wildlife(player)

    # Tile Placement
    tile_placement = st.selectbox(f"{player}: Place Habitat Tile", options=['Select Position'] + list(range(1, len(st.session_state['players'][player]['habitat']) + 1)))
    
    # Wildlife Placement
    wildlife_placement = st.selectbox(f"{player}: Place Wildlife Token", options=['Select Habitat'] + list(range(1, len(st.session_state['players'][player]['wildlife']) + 1)))

    # Nature Tokens
    if st.session_state['players'][player]['nature_tokens'] > 0:
        if st.button(f"{player}: Use a Nature Token"):
            st.session_state['players'][player]['nature_tokens'] -= 1
            # Logic for swapping wildlife tokens or other actions
            st.write(f"{player} used a nature token. Remaining: {st.session_state['players'][player]['nature_tokens']}")

# Save game state
with open(save_file, 'w') as file:
    json.dump(st.session_state, file)

# Game Controls and Instructions
st.write("## Game Controls")
st.write("Use the buttons and select boxes to play the game!")