Spaces:
Build error
Build error
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() | |