awacke1 commited on
Commit
4c41ba6
ยท
1 Parent(s): bb4a3ff

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -72
app.py DELETED
@@ -1,72 +0,0 @@
1
- import streamlit as st
2
- import random
3
- import datetime
4
- import pytz
5
-
6
- # Define the emojis and class names
7
- classes = {
8
- u'Engineering': {'emojis': [u'๐Ÿ› ๏ธ', u'๐Ÿ”ง', u'๐Ÿ”ฉ', u'๐Ÿ”จ', u'๐Ÿš€']},
9
- u'Magic': {'emojis': [u'๐Ÿง™', u'๐Ÿ”ฎ', u'โœจ', u'๐ŸŒŸ', u'๐ŸŽฉ']},
10
- u'Industry': {'emojis': [u'๐Ÿญ', u'๐Ÿšœ', u'๐Ÿ”จ', u'๐Ÿ—๏ธ', u'๐Ÿš›']}
11
- }
12
-
13
- # Define the function to roll the dice
14
- def roll_dice(emojis):
15
- return [random.choice(emojis) for i in range(20)]
16
-
17
- # Define the function to check for three of a kind
18
- def check_three_of_a_kind(dice):
19
- for emoji in set(dice):
20
- if dice.count(emoji) >= 3:
21
- return True
22
- return False
23
-
24
- # Define the function to save the results to a file
25
- def save_results(class_name, result):
26
- now = datetime.datetime.now(pytz.timezone('US/Pacific'))
27
- date_str = now.strftime('%Y-%m-%d')
28
- time_str = now.strftime('%I-%M-%S-%p')
29
- if now.hour >= 6 and now.hour < 18:
30
- day_night_emoji = u'โ˜€๏ธ'
31
- else:
32
- day_night_emoji = u'๐ŸŒ™'
33
- filename = f'{class_name}-{date_str}-{time_str}-{day_night_emoji}.txt'
34
- with open(filename, 'wb') as f:
35
- f.write(f'{class_name}: {result}'.encode('utf-8'))
36
-
37
- # Define the Streamlit app
38
- def main():
39
- st.title("Roll the Dice Game")
40
- st.write("Select a class to roll for:")
41
- class_selection = st.selectbox("", list(classes.keys()))
42
-
43
- emojis = classes[class_selection]['emojis']
44
- class_name = class_selection.lower()
45
-
46
- st.write(f"Selected class: {class_selection}")
47
- st.write("Click the button to roll the dice:")
48
-
49
- rolls_left = 3
50
- dice_rolled = False
51
- while rolls_left > 0 and not dice_rolled:
52
- if st.button("Roll the Dice"):
53
- dice = roll_dice(emojis)
54
- dice_words = [emoji.encode('unicode_escape').decode('utf-8') for emoji in dice]
55
- st.write("Dice:", " ".join(dice_words))
56
- if check_three_of_a_kind(dice):
57
- st.write("Congratulations! You rolled three of a kind!")
58
- dice_rolled = True
59
- result = 'win'
60
- else:
61
- st.write("You did not roll three of a kind. Try again.")
62
- result = 'loss'
63
- rolls_left -= 1
64
-
65
- if not dice_rolled:
66
- st.write("Sorry, you did not roll three of a kind. Better luck next time.")
67
- result = 'loss'
68
-
69
- save_results(class_name, result)
70
-
71
- if __name__ == "__main__":
72
- main()