File size: 4,480 Bytes
fdfffce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import streamlit as st
import random

st.set_page_config(page_title="๐ŸŽฎ Mini Game Arcade", page_icon="๐ŸŽฒ")

st.title("๐ŸŽฎ Mini Game Arcade")

# Game selection
game = st.selectbox("Choose a game to play:", [
    "Rock, Paper, Scissors",
    "Guess the Number",
    "Word Scramble",
    "Emoji Quiz",
    "Math Quiz",
    "Hangman",
    "Tic-Tac-Toe",
    "Coin Toss",
    "Dice Roll",
    "Memory Challenge"
])

# ------------------------------
if game == "Rock, Paper, Scissors":
    st.subheader("โœŠโœ‹โœŒ๏ธ Rock, Paper, Scissors")
    user_choice = st.radio("Choose:", ["Rock", "Paper", "Scissors"])
    if st.button("Play"):
        computer_choice = random.choice(["Rock", "Paper", "Scissors"])
        st.write(f"Computer chose: **{computer_choice}**")
        if user_choice == computer_choice:
            st.info("It's a tie!")
        elif (user_choice, computer_choice) in [("Rock", "Scissors"), ("Scissors", "Paper"), ("Paper", "Rock")]:
            st.success("You win!")
        else:
            st.error("You lose!")

# ------------------------------
elif game == "Guess the Number":
    st.subheader("๐Ÿ”ข Guess the Number (1-10)")
    secret = random.randint(1, 10)
    guess = st.number_input("Your guess:", 1, 10, step=1)
    if st.button("Check"):
        if guess == secret:
            st.success("๐ŸŽ‰ Correct! You guessed it.")
        else:
            st.warning(f"Wrong! The number was {secret}.")

# ------------------------------
elif game == "Word Scramble":
    st.subheader("๐Ÿ”ค Word Scramble")
    word = random.choice(["streamlit", "python", "arcade", "developer", "career"])
    scrambled = "".join(random.sample(word, len(word)))
    answer = st.text_input(f"Unscramble this word: **{scrambled}**")
    if st.button("Check"):
        if answer.lower() == word:
            st.success("โœ… Correct!")
        else:
            st.error(f"โŒ Wrong! The word was: **{word}**")

# ------------------------------
elif game == "Emoji Quiz":
    st.subheader("๐Ÿ˜Š Emoji Quiz")
    quiz = {
        "๐Ÿฆ๐Ÿ‘‘": "lion king",
        "๐ŸŽ๐Ÿ“ฑ": "apple",
        "๐ŸŽฌ๐Ÿฟ": "movie",
        "โšฝ๐Ÿ†": "football",
    }
    emoji, answer = random.choice(list(quiz.items()))
    user_answer = st.text_input(f"What does this mean? {emoji}")
    if st.button("Submit"):
        if user_answer.lower() == answer:
            st.success("Correct! ๐ŸŽ‰")
        else:
            st.error(f"Nope! The answer was: {answer}")

# ------------------------------
elif game == "Math Quiz":
    st.subheader("โž• Math Quiz")
    a, b = random.randint(1, 20), random.randint(1, 20)
    user_answer = st.number_input(f"What is {a} + {b}?", value=0)
    if st.button("Check Answer"):
        if user_answer == a+b:
            st.success("โœ… Correct!")
        else:
            st.error(f"โŒ Wrong! Answer is {a+b}.")

# ------------------------------
elif game == "Hangman":
    st.subheader("๐Ÿชข Hangman (1 chance)")
    word = random.choice(["cat", "dog", "bat", "rat", "sun"])
    display = "_ " * len(word)
    guess = st.text_input(f"Guess the word: {display}").lower()
    if st.button("Submit Guess"):
        if guess == word:
            st.success("๐ŸŽ‰ You win!")
        else:
            st.error(f"You lose! Word was: {word}")

# ------------------------------
elif game == "Tic-Tac-Toe":
    st.subheader("โŒโญ• Tic-Tac-Toe")
    st.write("Sorry! Tic-Tac-Toe is currently just a placeholder (implementing full board interaction is advanced here).")
    st.info("You can extend this by adding a 3x3 grid with session state!")

# ------------------------------
elif game == "Coin Toss":
    st.subheader("๐Ÿช™ Coin Toss")
    if st.button("Toss Coin"):
        result = random.choice(["Heads", "Tails"])
        st.write(f"Result: **{result}**")

# ------------------------------
elif game == "Dice Roll":
    st.subheader("๐ŸŽฒ Dice Roll")
    if st.button("Roll Dice"):
        roll = random.randint(1,6)
        st.write(f"You rolled: **{roll}**")

# ------------------------------
elif game == "Memory Challenge":
    st.subheader("๐Ÿง  Memory Challenge")
    numbers = [random.randint(1, 9) for _ in range(3)]
    st.write(f"Remember this sequence: {numbers}")
    guess = st.text_input("Enter the sequence (comma-separated):")
    if st.button("Check Sequence"):
        if guess.replace(" ", "") == ",".join(map(str, numbers)):
            st.success("๐ŸŽ‰ Correct!")
        else:
            st.error(f"Wrong! It was: {numbers}")