File size: 2,369 Bytes
5ee21a0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import random
import datetime
import pytz

# Define the emojis and class names
classes = {
    'Engineering': {'emojis': ['๐Ÿ› ๏ธ', '๐Ÿ”ง', '๐Ÿ”ฉ', '๐Ÿ”จ', '๐Ÿš€']},
    'Magic': {'emojis': ['๐Ÿง™', '๐Ÿ”ฎ', 'โœจ', '๐ŸŒŸ', '๐ŸŽฉ']},
    'Industry': {'emojis': ['๐Ÿญ', '๐Ÿšœ', '๐Ÿ”จ', '๐Ÿ—๏ธ', '๐Ÿš›']}
}

# Define the function to roll the dice
def roll_dice(emojis):
    return [random.choice(emojis) for i in range(20)]

# Define the function to check for three of a kind
def check_three_of_a_kind(dice):
    for emoji in set(dice):
        if dice.count(emoji) >= 3:
            return True
    return False

# Define the function to save the results to a file
def save_results(class_name, result):
    now = datetime.datetime.now(pytz.timezone('US/Pacific'))
    date_str = now.strftime('%Y-%m-%d')
    time_str = now.strftime('%I-%M-%S-%p')
    if now.hour >= 6 and now.hour < 18:
        day_night_emoji = 'โ˜€๏ธ'
    else:
        day_night_emoji = '๐ŸŒ™'
    filename = f'{class_name}-{date_str}-{time_str}-{day_night_emoji}.txt'
    with open(filename, 'w') as f:
        f.write(f'{class_name}: {result}')

# Define the Streamlit app
def main():
    st.title("Roll the Dice Game")
    st.write("Select a class to roll for:")
    class_selection = st.selectbox("", list(classes.keys()))

    emojis = classes[class_selection]['emojis']
    class_name = class_selection.lower()

    st.write(f"Selected class: {class_selection}")
    st.write("Click the button to roll the dice:")

    rolls_left = 3
    dice_rolled = False
    while rolls_left > 0 and not dice_rolled:
        if st.button("Roll the Dice"):
            dice = roll_dice(emojis)
            dice_words = [emoji.encode('unicode_escape').decode('utf-8') for emoji in dice]
            st.write("Dice:", " ".join(dice_words))
            if check_three_of_a_kind(dice):
                st.write("Congratulations! You rolled three of a kind!")
                dice_rolled = True
                result = 'win'
            else:
                st.write("You did not roll three of a kind. Try again.")
                result = 'loss'
            rolls_left -= 1

    if not dice_rolled:
        st.write("Sorry, you did not roll three of a kind. Better luck next time.")
        result = 'loss'

    save_results(class_name, result)

if __name__ == "__main__":
    main()