File size: 9,563 Bytes
71c8f6e
 
75b4491
 
6eec04b
71c8f6e
 
1f61cb7
 
 
 
 
 
 
 
71c8f6e
1f61cb7
71c8f6e
 
 
 
1f61cb7
 
 
 
 
 
 
 
 
 
 
 
71c8f6e
 
6c20dad
71c8f6e
 
 
 
 
 
 
 
 
 
 
6c20dad
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71c8f6e
 
 
 
 
 
 
 
 
 
 
c7ff268
71c8f6e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c7ff268
 
 
 
 
 
 
 
 
 
 
 
 
 
14272ba
 
 
 
c7ff268
 
 
 
6eec04b
75b4491
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6eec04b
 
 
 
 
 
 
81bbb41
71c8f6e
 
 
 
 
dd7ed8a
 
 
71c8f6e
 
 
 
 
 
 
 
 
 
75b4491
 
 
71c8f6e
 
 
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import streamlit as st
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
import os

PLAYERS = {
    "Player 1": {"Sketch": "🎨", "Character": "πŸ§™β€β™€οΈ", "Player Board": "πŸ“œ", "Action Dice": "🎲", "Health Tokens": "❀️", "Coin Tokens": "πŸ’°", "Battle Tokens": "βš”οΈ", "Attack": 5, "Defense": 3, "Class": "Wizard"},
    "Player 2": {"Sketch": "🎨", "Character": "πŸ§™β€β™‚οΈ", "Player Board": "πŸ“œ", "Action Dice": "🎲", "Health Tokens": "❀️", "Coin Tokens": "πŸ’°", "Battle Tokens": "βš”οΈ", "Attack": 4, "Defense": 4, "Class": "Fighter"},
    "Player 3": {"Sketch": "🎨", "Character": "πŸ§β€β™€οΈ", "Player Board": "πŸ“œ", "Action Dice": "🎲", "Health Tokens": "❀️", "Coin Tokens": "πŸ’°", "Battle Tokens": "βš”οΈ", "Attack": 3, "Defense": 5, "Class": "Ranger"},
    "Player 4": {"Sketch": "🎨", "Character": "πŸ§β€β™‚οΈ", "Player Board": "πŸ“œ", "Action Dice": "🎲", "Health Tokens": "❀️", "Coin Tokens": "πŸ’°", "Battle Tokens": "βš”οΈ", "Attack": 4, "Defense": 4, "Class": "Rogue"},
    "Player 5": {"Sketch": "🎨", "Character": "πŸ§β€β™€οΈ", "Player Board": "πŸ“œ", "Action Dice": "🎲", "Health Tokens": "❀️", "Coin Tokens": "πŸ’°", "Battle Tokens": "βš”οΈ", "Attack": 2, "Defense": 6, "Class": "Cleric"},
    "Player 6": {"Sketch": "🎨", "Character": "πŸ§β€β™‚οΈ", "Player Board": "πŸ“œ", "Action Dice": "🎲", "Health Tokens": "❀️", "Coin Tokens": "πŸ’°", "Battle Tokens": "βš”οΈ", "Attack": 3, "Defense": 5, "Class": "Barbarian"},
    "Player 7": {"Sketch": "🎨", "Character": "πŸ§Ÿβ€β™€οΈ", "Player Board": "πŸ“œ", "Action Dice": "🎲", "Health Tokens": "❀️", "Coin Tokens": "πŸ’°", "Battle Tokens": "βš”οΈ", "Attack": 1, "Defense": 7, "Class": "Paladin"},
    "Player 8": {"Sketch": "🎨", "Character": "πŸ§Ÿβ€β™‚οΈ", "Player Board": "πŸ“œ", "Action Dice": "🎲", "Health Tokens": "❀️", "Coin Tokens": "πŸ’°", "Battle Tokens": "βš”οΈ", "Attack": 2, "Defense": 6, "Class": "Bard"}
}
    
MONSTERS = {
    "Goblin": {"Picture": "πŸ‘Ί", "Description": "A small, mischievous creature with sharp teeth and claws.", "Attack": 2, "Defense": 1},
    "Orc": {"Picture": "πŸ‘Ή", "Description": "A large, brutish humanoid with green skin and a nasty temperament.", "Attack": 4, "Defense": 2},
    "Dragon": {"Picture": "🐲", "Description": "A massive, fire-breathing beast with scales as hard as steel.", "Attack": 6, "Defense": 5},
    "Cyclops": {"Picture": "πŸ‘οΈ", "Description": "A one-eyed giant with incredible strength.", "Attack": 8, "Defense": 6},
    "Minotaur": {"Picture": "πŸ‚", "Description": "A half-man, half-bull creature with a fierce temper.", "Attack": 5, "Defense": 3},
    "Medusa": {"Picture": "🐍", "Description": "A woman with snakes for hair who can turn people to stone with her gaze.", "Attack": 3, "Defense": 2},
    "Siren": {"Picture": "🧜", "Description": "A beautiful creature with the upper body of a woman and the lower body of a bird, whose singing lures sailors to their doom.", "Attack": 1, "Defense": 1},
    "Kraken": {"Picture": "πŸ¦‘", "Description": "A massive sea creature with tentacles that can crush ships.", "Attack": 7, "Defense": 4},
    "Beholder": {"Picture": "πŸ‘οΈβ€πŸ—¨οΈ", "Description": "A floating orb covered in eyes, each of which can cast a deadly spell.", "Attack": 9, "Defense": 8},
    "Chimera": {"Picture": "🐲🐐🦁", "Description": "A creature with the body of a lion, the head of a goat, and the tail of a dragon.", "Attack": 6, "Defense": 5},
    "Basilisk": {"Picture": "πŸπŸ‘οΈ", "Description": "A serpent that can turn people to stone with its gaze.", "Attack": 4, "Defense": 3},
    "Mimic": {"Picture": "πŸ“¦", "Description": "A creature that can disguise itself as a treasure chest and surprise unwary adventurers.", "Attack": 2, "Defense": 1},
    "Aboleth": {"Picture": "πŸ¦‘πŸ‘οΈ", "Description": "A sea monster with slimy tentacles and the power to control people's minds.", "Attack": 7, "Defense": 6},
    "Troll": {"Picture": "πŸ‘ΉπŸ”¨", "Description": "A regenerating monster that can only be killed with fire or acid.", "Attack": 5, "Defense": 4},
    "Gorgon": {"Picture": "πŸπŸ‘οΈβ€πŸ—¨οΈ", "Description": "A creature with the body of a lion and the head of a snake, whose gaze can turn people to stone.", "Attack": 6, "Defense": 4},
}

def get_random_monster_old():
    monster_name = st.session_state.selected_monster
    if monster_name:
        monster = MONSTERS[monster_name]
        st.write("Picture: ", monster["Picture"])
        st.write("Description: ", monster["Description"])
        st.write("Attack: ", monster["Attack"])
        st.write("Defense: ", monster["Defense"])
        return monster
    else:
        return None

def get_random_monster():
    monster_name = st.session_state.selected_monster
    if monster_name:
        monster = MONSTERS[monster_name]
        st.write("Picture: ", monster["Picture"])
        st.write("Description: ", monster["Description"])
        st.write("Attack: ", monster["Attack"])
        st.write("Defense: ", monster["Defense"])
        return monster
    else:
        # Select a random monster based on its size
        monster_sizes = [monster_data["Attack"] + monster_data["Defense"] for monster_data in MONSTERS.values()]
        selected_size = random.choice(monster_sizes)
        monster_names = [monster_name for monster_name, monster_data in MONSTERS.items() if monster_data["Attack"] + monster_data["Defense"] == selected_size]
        selected_monster = random.choice(monster_names)
        st.session_state.selected_monster = selected_monster
        monster = MONSTERS[selected_monster]
        st.write("Picture: ", monster["Picture"])
        st.write("Description: ", monster["Description"])
        st.write("Attack: ", monster["Attack"])
        st.write("Defense: ", monster["Defense"])
        return monster

def save_data():
    data = pd.DataFrame.from_dict(st.session_state.players, orient="index")
    filename = "player_data.csv"
    data.to_csv(filename)
    st.write(f"Player data saved to {filename}")

def display_player_card(player_name, player_data):
    st.write(f"**{player_name}**")
    for key, value in player_data.items():
        st.write(f"{key}: {value}")

def battle_player_card_old():
    selected_player = st.session_state.selected_player
    selected_monster = st.session_state.selected_monster
    if not selected_player:
        st.warning("Please select a player card.")
        return
    if not selected_monster:
        st.warning("Please select a monster.")
        return
    player_data = PLAYERS[selected_player]
    monster_data = MONSTERS[selected_monster]
    if player_data["Attack"] > monster_data["Defense"]:
        st.success("You defeated the monster!")
    else:
        st.error("The monster defeated you.")
    save_data()

def battle_player_card():
    selected_player = st.session_state.selected_player
    selected_monster = st.session_state.selected_monster
    if not selected_player:
        st.warning("Please select a player card.")
        return
    if not selected_monster:
        st.warning("Please select a monster.")
        return
    player_data = PLAYERS[selected_player]
    monster_data = MONSTERS[selected_monster]
    if player_data["Attack"] > monster_data["Defense"]:
        st.success("You defeated the monster!")
        # Increase player's Health Tokens
        # player_data["Health Tokens"] += 1
        # Increase player's Health Tokens and add an additional heart emoji
        player_data["Health Tokens"] += "❀️"

    else:
        st.error("The monster defeated you.")
    save_data()
    
def load_and_display_player_data_old():
    player_data = pd.read_csv("player_data.csv")
    st.write("## Player Data")
    st.write(player_data)

    fig = px.treemap(player_data,
                     path=['Player'],
                     values='Health Tokens',
                     color='Attack',
                     color_continuous_scale='Blues',
                     title='Player Attack Power and Health Tokens')
    fig.update_traces(textinfo='label+value+percent entry',
                      hovertemplate='<b>%{label}</b><br>Attack: %{color}<br>Health: %{value}<br>Percent: %{percentEntry:.2f}%<extra></extra>')
    fig.update_layout(margin=dict(t=50, b=0, l=0, r=0), height=400)
    st.plotly_chart(fig)
    
def load_and_display_player_data():
    if os.path.exists("player_data.csv"):
        player_data = pd.read_csv("player_data.csv")
        st.write("## Player Data")
        st.write(player_data)
    else:
        st.write("Player data file not found.")
        
def main():
    st.set_page_config(page_title="Player Cards and Monsters")
    st.title("Player Cards and Monsters")
    st.write("πŸƒ Select a player card to reveal a monster and battle it! πŸ‰")

    if "players" not in st.session_state:
        st.session_state.players = {}
            
    st.sidebar.title("πŸƒ Select a Player Card")
    selected_player = st.sidebar.radio("Select a player:", list(PLAYERS.keys()))
    display_player_card(selected_player, PLAYERS[selected_player])

    if st.button("πŸ”₯ Battle!"):
        st.session_state.selected_player = selected_player
        st.session_state.selected_monster = st.sidebar.selectbox("Select a monster:", list(MONSTERS.keys()))
        monster = get_random_monster()
        if monster:
            battle_player_card()
            
    load_and_display_player_data()
    
if __name__ == "__main__":
    main()