File size: 3,115 Bytes
eb8835a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import pandas as pd

PLAYERS = {
    "Player 1": {"Sketch": "🎨", "Character": "πŸ§™β€β™€οΈ", "Player Board": "πŸ“œ", "Action Dice": "🎲", "Health Tokens": "❀️", "Coin Tokens": "πŸ’°", "Battle Tokens": "βš”οΈ", "Attack": 5, "Defense": 3},
    "Player 2": {"Sketch": "🎨", "Character": "πŸ§™β€β™‚οΈ", "Player Board": "πŸ“œ", "Action Dice": "🎲", "Health Tokens": "❀️", "Coin Tokens": "πŸ’°", "Battle Tokens": "βš”οΈ", "Attack": 4, "Defense": 4},
}

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},
}

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:
        return None

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():
    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 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()

if __name__ == "__main__":
    main()