File size: 3,707 Bytes
c11db43
49a4692
c11db43
 
 
 
 
6ea294a
c11db43
6ea294a
 
 
 
c11db43
 
 
6ea294a
c11db43
 
 
 
 
6ea294a
c11db43
 
 
 
 
6ea294a
 
c11db43
 
 
6ea294a
 
 
 
39bd597
88bab31
 
 
 
 
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
import os
import pandas as pd
import streamlit as st

st.set_page_config(page_title="Dice Roller", page_icon="๐ŸŽฒ")
st.title("๐ŸŽฒ Dice Roller")

if 'username' not in st.session_state: st.session_state.username = st.text_input("๐Ÿ‘ค Username", max_chars=50)

dice_types = {"๐ŸŽฒ Six-sided dice": {"sides": 6, "name": "d6", "emoji": "๐ŸŽฒ"},
              "๐ŸŽฒ Thirty-sided dice": {"sides": 30, "name": "d30", "emoji": "๐ŸŽฒ"},
              "๐ŸŽฒ Twenty-sided dice": {"sides": 20, "name": "d20", "emoji": "๐ŸŽฒ"},
              "๐ŸŽฒ One hundred-sided dice": {"sides": 100, "name": "d100", "emoji": "๐Ÿ’ฏ"}}

dice_type = st.selectbox("๐ŸŽฒ Select a dice type", options=list(dice_types.keys()), format_func=lambda x: x.split(' ')[-2])
num_rolls = st.slider("๐ŸŽฒ How many times do you want to roll the dice?", 1, 1000000, 100)
rolls = [str(pd.Series([dice_types[dice_type]["sides"]] * num_rolls).apply(pd.Series.sample, replace=True))]
rolls = rolls[0].strip('[]').split('\n')

if st.button("๐ŸŽฒ Roll Dice"):
    display_roll = [int(i) for i in rolls]
    st.write(f"{dice_types[dice_type]['emoji']} You rolled {len(display_roll)} {dice_types[dice_type]['name']} dice: {', '.join(map(str, display_roll))}.")
    bonus_match, count = (None, sum(display_roll))
    if count % dice_types[dice_type]['sides'] == 0:
        bonus_match = dice_types[dice_type]['name']
        st.write(f"๐ŸŽ‰ Bonus match! You rolled a multiple of {dice_types[dice_type]['sides']}.")
    df = pd.DataFrame({'Roll': rolls, 'Count': count, 'DiceNumberOfSides': dice_types[dice_type]['sides']})
    file_exists = os.path.exists("SharedState.csv")
    if file_exists: df.to_csv("SharedState.csv", mode='a', header=False, index=False)
    else: df.to_csv("SharedState.csv", mode='w', header=True, index=False)

download_roll_history = st.checkbox("๐Ÿ“ฅ Download Roll History", value=True)
if os.path.exists("SharedState.csv"):
    if download_roll_history:
        with open("SharedState.csv", "rb") as f:
            st.download_button(label="๐Ÿ“ฅ Download Roll History", data=f, file_name="SharedState.csv", mime="text/csv")
else: st.warning("No roll history found.")

st.write("""

๐Ÿž Bread, ๐Ÿฅ Croissant, ๐Ÿฅ– Baguette Bread, ๐Ÿซ“ Flatbread, ๐Ÿฅจ Pretzel, ๐Ÿฅฏ Bagel, ๐Ÿฅž Pancakes, ๐Ÿง‡ Waffle, ๐Ÿง€ Cheese Wedge, ๐Ÿ– Meat on Bone, ๐Ÿ— Poultry Leg, ๐Ÿฅฉ Cut of Meat, ๐Ÿฅ“ Bacon, ๐Ÿ” Hamburger, ๐ŸŸ French Fries, ๐Ÿ• Pizza, ๐ŸŒญ Hot Dog, ๐Ÿฅช Sandwich, ๐ŸŒฎ Taco, ๐ŸŒฏ Burrito, ๐Ÿซ” Tamale, ๐Ÿฅ™ Stuffed Flatbread, ๐Ÿง† Falafel, ๐Ÿฅš Egg, ๐Ÿณ Cooking, ๐Ÿฅ˜ Shallow Pan of Food, ๐Ÿฒ Pot of Food, ๐Ÿซ• Fondue, ๐Ÿฅฃ Bowl with Spoon, ๐Ÿฅ— Green Salad, ๐Ÿฟ Popcorn, ๐Ÿงˆ Butter, ๐Ÿง‚ Salt, ๐Ÿฅซ Canned Food, ๐Ÿฑ Bento Box, ๐Ÿ˜ Rice Cracker, ๐Ÿ™ Rice Ball, ๐Ÿš Cooked Rice, ๐Ÿ› Curry Rice, ๐Ÿœ Steaming Bowl, ๐Ÿ Spaghetti, ๐Ÿ  Roasted Sweet Potato, ๐Ÿข Oden, ๐Ÿฃ Sushi, ๐Ÿค Fried Shrimp, ๐Ÿฅ Fish Cake with Swirl, ๐Ÿฅฎ Moon Cake, ๐Ÿก Dango, ๐ŸฅŸ Dumpling, ๐Ÿฅ  Fortune Cookie, ๐Ÿฅก Takeout Box, ๐Ÿฆช Oyster, ๐Ÿฆ Soft Ice Cream, ๐Ÿง Shaved Ice, ๐Ÿจ Ice Cream, ๐Ÿฉ Doughnut, ๐Ÿช Cookie, ๐ŸŽ‚ Birthday Cake, ๐Ÿฐ Shortcake, ๐Ÿง Cupcake, ๐Ÿฅง Pie, ๐Ÿซ Chocolate Bar, ๐Ÿฌ Candy, ๐Ÿญ Lollipop, ๐Ÿฎ Custard, ๐Ÿฏ Honey Pot, ๐Ÿผ Baby Bottle, ๐Ÿฅ› Glass of Milk, โ˜• Hot Beverage, ๐Ÿซ– Teapot, ๐Ÿต Teacup Without Handle, ๐Ÿถ Sake, ๐Ÿพ Bottle with Popping Cork, ๐Ÿท Wine Glass, ๐Ÿธ Cocktail Glass, ๐Ÿน Tropical Drink, ๐Ÿบ Beer Mug, ๐Ÿป Clinking Beer Mugs, ๐Ÿฅ‚ Clinking Glasses, ๐Ÿฅƒ Tumbler Glass, ๐Ÿซ— Pouring Liquid, ๐Ÿฅค Cup with Straw, ๐Ÿง‹ Bubble Tea, ๐Ÿงƒ Beverage Box, ๐Ÿง‰ Mate, ๐ŸงŠ Ice, ๐Ÿฅข Chopsticks, ๐Ÿฝ๏ธ Fork and Knife with Plate, ๐Ÿด Fork and Knife, ๐Ÿฅ„ Spoon, ๐Ÿซ™ Jar")
""")