File size: 3,499 Bytes
863e252
 
 
 
 
 
 
 
 
a073cd0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cc4ba11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a073cd0
 
 
 
863e252
 
a073cd0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
863e252
 
a073cd0
 
 
 
 
 
 
 
 
 
863e252
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



import streamlit as st
import pandas as pd
import random
import base64


st.markdown("""

๐ŸŽฒ: This is the standard die used in many games, with each face showing a different number from 1 to 6.

๐ŸŽฏ: This emoji represents a dart board, but it can also be used to refer to a 6-sided die in which each face shows a different number from 1 to 6.

๐ŸŽด: This is a Japanese flower card game, but can also be used to represent a 6-sided die in which each face shows a different number from 1 to 6.

๐ŸŽฐ: This emoji represents a slot machine, but it can also be used to refer to a 6-sided die in which each face shows a different number from 1 to 6.

๐ŸŽณ: This emoji represents a bowling game, but it can also be used to refer to a 10-sided die in which each face shows a different number from 0 to 9.

๐ŸŽฎ: This emoji represents a video game controller, but it can also be used to refer to a 20-sided die often used in role-playing games, with each face showing a different number from 1 to 20.

๐ŸŽด: This is a Japanese flower card game, but it can also be used to represent a 6-sided die in which each face shows a different number from 1 to 6.

๐Ÿ€„: This is a mahjong tile representing the one of circles, but it can also be used to represent a 6-sided die in which each face shows a different number from 1 to 6.


""")

import pandas as pd
import tkinter as tk
import random

# Create the pandas dataframe
df = pd.DataFrame({
    'emoji': ['๐ŸŽฒ', '๐ŸŽฏ', '๐ŸŽด', '๐ŸŽฐ', '๐ŸŽณ', '๐ŸŽฎ', '๐ŸŽด', '๐Ÿ€„'],
    'dice_meaning': ['6-sided die', '6-sided die', '6-sided die', '6-sided die', '10-sided die', '20-sided die', '6-sided die', '6-sided die']
})

# Create the drop-down list box
root = tk.Tk()
root.title('Actor Role Playing Game')
selected_emoji = tk.StringVar()
dropdown = tk.OptionMenu(root, selected_emoji, *df['emoji'].values)
dropdown.pack()




# set up the game board
player_pos = {'Player 1': [0, 0], 'Player 2': [0, 0]}
board = pd.DataFrame(index=range(5), columns=range(5))
board.iloc[player_pos['Player 1'][0], player_pos['Player 1'][1]] = '๐ŸŽด'
board.iloc[player_pos['Player 2'][0], player_pos['Player 2'][1]] = '๐ŸŽด'

# implement the dice game
rolls = []
coins = {'Player 1': 0, 'Player 2': 0}
def roll_dice(player):
    roll = random.randint(1, 6)
    rolls.append(roll)
    if roll in rolls[:-1]:
        coins[player] += 10

# save results to file
results = pd.DataFrame(columns=['Player', 'Roll'])
def save_results(player, roll):
    results.loc[len(results)] = [player, roll]
    results.to_csv('results.txt', index=False)

# implement download link
def get_table_download_link(df, text):
    csv = df.to_csv(index=False)
    b64 = base64.b64encode(csv.encode()).decode()
    href = f'<a href="data:file/csv;base64,{b64}" download="{text}.csv">Download Results</a>'
    return href

# create multiplayer aspect
players = ['Player 1', 'Player 2']
player = st.selectbox('Select Player', players)
player_pos[player][1] = st.slider('Move Right or Left', -2, 2, 0)
player_pos[player][0] = st.slider('Move Up or Down', -2, 2, 0)
board.iloc[player_pos['Player 1'][0], player_pos['Player 1'][1]] = '๐ŸŽฎ'
board.iloc[player_pos['Player 2'][0], player_pos['Player 2'][1]] = '๐ŸŽฒ'

if st.button('Roll Dice'):
    roll_dice(player)
    st.write('Roll:', rolls[-1])
    st.write('Coins:', coins[player])
    save_results(player, rolls[-1])

st.write(board)

if st.button('Download Results'):
    st.markdown(get_table_download_link(results, 'results'), unsafe_allow_html=True)