Spaces:
Build error
Build error
File size: 1,665 Bytes
1d6af2e |
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 |
import streamlit as st
import random
# Define the emojis for each class
engineering_emojis = ['🛠️', '🔧', '🔩', '🔨', '🚀']
magic_emojis = ['🧙', '🔮', '✨', '🌟', '🎩']
industry_emojis = ['🏭', '🚜', '🔨', '🏗️', '🚛']
# Define the function to roll the dice
def roll_dice():
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 Streamlit app
def main():
st.title("Roll the Dice Game")
st.write("Select a class to roll for:")
class_selection = st.selectbox("", ["Engineering", "Magic", "Industry"])
if class_selection == "Engineering":
emojis = engineering_emojis
elif class_selection == "Magic":
emojis = magic_emojis
else:
emojis = industry_emojis
st.write("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()
st.write("Dice:", " ".join(dice))
if check_three_of_a_kind(dice):
st.write("Congratulations! You rolled three of a kind!")
dice_rolled = True
else:
st.write("You did not roll three of a kind. Try again.")
rolls_left -= 1
if not dice_rolled:
st.write("Sorry, you did not roll three of a kind. Better luck next time.")
if __name__ == "__main__":
main()
|