Gamuu / app.py
Iammcqwory's picture
Update app.py
add40a2 verified
import streamlit as st
import random
import time
from datetime import datetime
import base64
# App Title and Config
st.set_page_config(page_title="Gamuu", page_icon="๐ŸŽฎ", layout="wide")
st.title("๐ŸŽฎ Gamuu - Ultimate Connection Game")
# Initialize Session State
if 'registered' not in st.session_state:
st.session_state.registered = False
if 'players' not in st.session_state:
st.session_state.players = {}
if 'teams' not in st.session_state:
st.session_state.teams = {}
if 'questions' not in st.session_state:
st.session_state.questions = {
'Music': [
"If your life had a theme song, what would it be?",
"What song describes your love life?",
"What concert would you travel back in time to see?",
"If you could only listen to one artist for the rest of your life, who would it be?",
"What song always makes you want to dance?",
"Which music genre do you think best represents your personality?",
"What's the most underrated song you know?",
"If you could write a song about your life, what would the title be?",
"What's your favorite music video?",
"What song do you listen to when you're feeling down?",
"What's the best live performance you've ever seen?",
"What song reminds you of your childhood?",
"What's your favorite karaoke song?",
"What song do you wish you could play on an instrument?",
"What's the first album you ever bought?",
"What song do you associate with your favorite memory?",
"What's your favorite song to sing in the shower?",
"What song always gets stuck in your head?",
"What's your favorite song from a movie soundtrack?",
"What song do you listen to when you need motivation?",
"What's your favorite cover of a song?",
"What song do you think has the best lyrics?",
"What's your favorite instrumental song?",
"What song do you listen to when you're relaxing?",
"What's your favorite song to dance to at a party?",
"What song reminds you of a past relationship?",
"What's your favorite song to listen to while driving?",
"What song do you think is overrated?",
"What's your favorite song from a video game?",
"What song do you listen to when you're working out?"
],
'Love Language': [
"How do you prefer to receive affection?",
"What's your unconventional love language?",
"How do you show love when words aren't enough?",
"What's the most thoughtful gift you've ever received?",
"How do you express love without using words?",
"What's the sweetest thing someone has done for you?",
"How do you like to be comforted when you're feeling down?",
"What's your favorite way to spend quality time with someone?",
"What's the most romantic gesture you've ever experienced?",
"What's your favorite thing to wear to feel sexy?",
"What's the most unexpected place you've felt a spark with someone?",
"What's your favorite scent on a partner?",
"What's the most adventurous place you've ever had a romantic encounter?",
"What's your favorite fantasy role-play scenario?",
"What's the most daring thing you've done to impress someone?",
"What's your favorite part of your partner's body?",
"What's the wildest place you've ever had sex?",
"What's your favorite position and why?",
"What's the most adventurous thing you've done in the bedroom?",
"What's your favorite toy or accessory to use during intimate moments?",
"What's the most daring fantasy you've ever had?",
"What's the most taboo thing you've ever fantasized about?",
"Have you ever had a threesome or group experience? Details?",
"What's the most intense BDSM experience you've had?",
"What's your favorite kink or fetish?",
"Have you ever had sex in a public place? What happened?",
"What's the craziest travel adventure you've had?",
"What's your favorite self-care activity?",
"What's the biggest lesson you've learned in life?",
"What's your proudest achievement?"
],
'Movies': [
"What movie character represents your ideal partner?",
"What romantic scene from a movie would you reenact?",
"If you could be any movie character, who would it be and why?",
"What movie scene always makes you cry?",
"Which movie do you wish you could watch for the first time again?",
"What's the most quotable movie you've seen?",
"If you could direct a movie, what genre would it be and what would the plot be?",
"What's your favorite movie soundtrack?",
"What movie do you always watch when you're sick?",
"What's the scariest movie you've ever seen?",
"What movie has the best twist ending?",
"What's your favorite animated movie?",
"What movie do you love that everyone else hates?",
"What's your favorite movie quote?",
"What movie has the best special effects?",
"What's your favorite comedy movie?",
"What movie has the best fight scene?",
"What's your favorite movie to watch with friends?",
"What movie has the best car chase?",
"What's your favorite movie adaptation of a book?",
"What movie has the best costume design?",
"What's your favorite movie franchise?",
"What movie has the best opening scene?",
"What's your favorite movie ending?",
"What movie has the best cinematography?",
"What's your favorite movie villain?",
"What movie has the best love story?",
"What's your favorite movie soundtrack song?",
"What movie has the best dance scene?",
"What's your favorite movie genre?"
],
'Activities': [
"What's the most adventurous thing you've ever done?",
"If you could learn any new skill instantly, what would it be?",
"What's your favorite childhood game or activity?",
"If you could travel anywhere in the world, where would you go and why?",
"What's the most relaxing activity you enjoy?",
"What's your idea of a perfect day together?",
"What adventure would you want to experience with a partner?",
"What's the most beautiful place you've ever visited?",
"If you could live anywhere in the world, where would it be?",
"What's the most memorable trip you've taken?",
"What's your dream vacation destination?",
"What's the craziest travel adventure you've had?",
"What's your favorite self-care activity?",
"What's the biggest lesson you've learned in life?",
"What's your proudest achievement?",
"What's the best advice you've ever received?",
"What's your biggest fear and how do you overcome it?",
"What's your favorite way to spend a rainy day?",
"What's your favorite outdoor activity?",
"What's your favorite indoor activity?",
"What's your favorite sport to play or watch?",
"What's your favorite board game or card game?",
"What's your favorite video game?",
"What's your favorite hobby?",
"What's your favorite way to exercise?",
"What's your favorite way to relax?",
"What's your favorite way to spend time with friends?",
"What's your favorite way to spend time alone?",
"What's your favorite way to celebrate a special occasion?",
"What's your favorite way to unwind after a long day?"
],
'18+': {
'Spicy': [
"What's your secret turn-on?",
"Where's the most unusual place you've been kissed?",
"What fantasy have you never admitted?",
"What's your favorite role-play scenario?",
"What's the most adventurous intimate experience you've had?",
"What's your wildest unfulfilled desire?",
"What's the most daring thing you've done in the bedroom?",
"What's your favorite intimate accessory?",
"What's the most unexpected place you've felt a spark with someone?",
"What's your favorite scent on a partner?",
"What's the most adventurous place you've ever had a romantic encounter?",
"What's your favorite fantasy role-play scenario?",
"What's the most daring thing you've done to impress someone?",
"What's your favorite part of your partner's body?",
"What's the wildest place you've ever had sex?",
"What's your favorite position and why?",
"What's the most adventurous thing you've done in the bedroom?",
"What's your favorite toy or accessory to use during intimate moments?",
"What's your most daring fantasy you've ever had?",
"What's the most taboo thing you've ever fantasized about?",
"Have you ever had a threesome or group experience? Details?",
"What's the most intense BDSM experience you've had?",
"What's your favorite kink or fetish?",
"Have you ever had sex in a public place? What happened?",
"What's the craziest travel adventure you've had?",
"What's your favorite self-care activity?",
"What's the biggest lesson you've learned in life?",
"What's your proudest achievement?",
"What's the best advice you've ever received?",
"What's your biggest fear and how do you overcome it?"
],
'Extra Spicy': [
"What's your favorite piece of lingerie or underwear?",
"What's the most adventurous place you've ever had a romantic encounter?",
"What's your favorite fantasy role-play scenario?",
"What's the most daring thing you've done to impress someone?",
"What's your favorite part of your partner's body?",
"What's the wildest place you've ever had sex?",
"What's your favorite position and why?",
"What's the most adventurous thing you've done in the bedroom?",
"What's your favorite toy or accessory to use during intimate moments?",
"What's your most daring fantasy you've ever had?",
"What's the most taboo thing you've ever fantasized about?",
"Have you ever had a threesome or group experience? Details?",
"What's the most intense BDSM experience you've had?",
"What's your favorite kink or fetish?",
"Have you ever had sex in a public place? What happened?",
"What's the craziest travel adventure you've had?",
"What's your favorite self-care activity?",
"What's the biggest lesson you've learned in life?",
"What's your proudest achievement?",
"What's the best advice you've ever received?",
"What's your biggest fear and how do you overcome it?",
"What's your favorite way to spend a rainy day?",
"What's your favorite outdoor activity?",
"What's your favorite indoor activity?",
"What's your favorite sport to play or watch?",
"What's your favorite board game or card game?",
"What's your favorite video game?",
"What's your favorite hobby?",
"What's your favorite way to exercise?",
"What's your favorite way to relax?",
"What's your favorite way to spend time with friends?"
],
'Space Spicy': [
"Describe your most adventurous intimate experience.",
"What's your wildest unfulfilled desire?",
"What's the most daring thing you've done in the bedroom?",
"What's your favorite intimate accessory?",
"What's the most unexpected place you've felt a spark with someone?",
"What's your favorite scent on a partner?",
"What's the most adventurous place you've ever had a romantic encounter?",
"What's your favorite fantasy role-play scenario?",
"What's the most daring thing you've done to impress someone?",
"What's your favorite part of your partner's body?",
"What's the wildest place you've ever had sex?",
"What's your favorite position and why?",
"What's the most adventurous thing you've done in the bedroom?",
"What's your favorite toy or accessory to use during intimate moments?",
"What's your most daring fantasy you've ever had?",
"What's the most taboo thing you've ever fantasized about?",
"Have you ever had a threesome or group experience? Details?",
"What's the most intense BDSM experience you've had?",
"What's your favorite kink or fetish?",
"Have you ever had sex in a public place? What happened?",
"What's the craziest travel adventure you've had?",
"What's your favorite self-care activity?",
"What's the biggest lesson you've learned in life?",
"What's your proudest achievement?",
"What's the best advice you've ever received?",
"What's your biggest fear and how do you overcome it?",
"What's your favorite way to spend a rainy day?",
"What's your favorite outdoor activity?",
"What's your favorite indoor activity?",
"What's your favorite sport to play or watch?",
"What's your favorite board game or card game?",
"What's your favorite video game?"
],
'Hardcore': [
"What's the most taboo thing you've ever fantasized about?",
"Have you ever had a threesome or group experience? Details?",
"What's the most intense BDSM experience you've had?",
"What's your favorite kink or fetish?",
"Have you ever had sex in a public place? What happened?",
"What's the craziest travel adventure you've had?",
"What's your favorite self-care activity?",
"What's the biggest lesson you've learned in life?",
"What's your proudest achievement?",
"What's the best advice you've ever received?",
"What's your biggest fear and how do you overcome it?",
"What's your favorite way to spend a rainy day?",
"What's your favorite outdoor activity?",
"What's your favorite indoor activity?",
"What's your favorite sport to play or watch?",
"What's your favorite board game or card game?",
"What's your favorite video game?",
"What's your favorite hobby?",
"What's your favorite way to exercise?",
"What's your favorite way to relax?",
"What's your favorite way to spend time with friends?",
"What's your favorite way to spend time alone?",
"What's your favorite way to celebrate a special occasion?",
"What's your favorite way to unwind after a long day?",
"What's your favorite movie soundtrack song?",
"What movie has the best dance scene?",
"What's your favorite movie genre?",
"What's your favorite movie villain?",
"What movie has the best love story?",
"What's your favorite movie soundtrack?",
"What movie do you always watch when you're sick?"
]
},
'Travel': [
"What's the most beautiful place you've ever visited?",
"If you could live anywhere in the world, where would it be?",
"What's the most memorable trip you've taken?",
"What's your dream vacation destination?",
"What's the craziest travel adventure you've had?",
"What's your favorite mode of transportation when traveling?",
"What's the best local cuisine you've ever tried?",
"What's the most interesting cultural experience you've had?",
"What's the most beautiful natural wonder you've seen?",
"What's your favorite travel memory?",
"What's the most challenging travel experience you've had?",
"What's your favorite travel companion?",
"What's the most unexpected place you've visited?",
"What's your favorite travel book or movie?",
"What's the most luxurious travel experience you've had?",
"What's your favorite travel quote?",
"What's the most adventurous thing you've done while traveling?",
"What's your favorite travel souvenir?",
"What's the most beautiful sunset you've seen?",
"What's your favorite travel photo you've taken?",
"What's the most interesting historical site you've visited?",
"What's your favorite travel app or tool?",
"What's the most relaxing travel experience you've had?",
"What's your favorite travel hack?",
"What's the most beautiful beach you've visited?",
"What's your favorite travel destination for food?",
"What's the most interesting wildlife you've seen?",
"What's your favorite travel destination for adventure?",
"What's the most beautiful city you've visited?",
"What's your favorite travel destination for culture?"
],
'Food': [
"What's your favorite comfort food?",
"If you could only eat one cuisine for the rest of your life, what would it be?",
"What's the most exotic food you've ever tried?",
"What's your go-to meal to cook for someone special?",
"What's the best meal you've ever had?",
"What's your favorite dessert?",
"What's your favorite cooking show or chef?",
"What's the most memorable meal you've had while traveling?",
"What's your favorite food memory from childhood?",
"What's your favorite type of cheese?",
"What's your favorite food to order for delivery?",
"What's your favorite food to eat at a sports game?",
"What's your favorite food to eat at the movies?",
"What's your favorite food to eat for breakfast?",
"What's your favorite food to eat for a midnight snack?",
"What's your favorite food to eat at a picnic?",
"What's your favorite food to eat at a barbecue?",
"What's your favorite food to eat at a fancy restaurant?",
"What's your favorite food to eat at a casual restaurant?",
"What's your favorite food to eat at a food truck?",
"What's your favorite food to eat at a street market?",
"What's your favorite food to eat at a festival?",
"What's your favorite food to eat at a theme park?",
"What's your favorite food to eat at a concert?",
"What's your favorite food to eat at a sporting event?",
"What's your favorite food to eat at a carnival?",
"What's your favorite food to eat at a fair?",
"What's your favorite food to eat at a holiday gathering?",
"What's your favorite food to eat at a family reunion?"
],
'Personal Growth': [
"What's the biggest lesson you've learned in life?",
"What's your proudest achievement?",
"What's the best advice you've ever received?",
"What's your biggest fear and how do you overcome it?",
"What's your favorite self-care activity?",
"What's the most challenging thing you've ever done?",
"What's your favorite way to relax and unwind?",
"What's your favorite book or podcast for personal growth?",
"What's the most important value you live by?",
"What's your favorite quote or mantra?",
"What's the most meaningful compliment you've ever received?",
"What's your favorite way to give back to your community?",
"What's the most impactful experience you've had?",
"What's your favorite way to stay motivated?",
"What's the most important goal you're working towards?",
"What's your favorite way to stay organized?",
"What's the most important habit you've developed?",
"What's your favorite way to stay healthy?",
"What's the most important relationship in your life?",
"What's your favorite way to stay connected with friends and family?",
"What's the most important lesson you've learned from a failure?",
"What's your favorite way to stay positive?",
"What's the most important quality you look for in a friend?",
"What's your favorite way to stay creative?",
"What's the most important skill you've learned?",
"What's your favorite way to stay curious?",
"What's the most important lesson you've learned from a mentor?",
"What's your favorite way to stay inspired?",
"What's the most important change you've made in your life?",
"What's your favorite way to stay grateful?"
],
'Dare': [
"Show us your best dance move!",
"Sing a song out loud for 30 seconds!",
"Tell a funny joke that makes everyone laugh!",
"Share a secret talent you have!",
"Do a 30-second plank!",
"Mimic your favorite celebrity!",
"Share your most embarrassing moment!",
"Do a dramatic reading of a random text message!",
"Show us your best impression of another player!",
"Share a childhood nickname and the story behind it!",
"Do a 30-second freestyle rap!",
"Share a hidden skill or hobby you have!",
"Do a 30-second yoga pose!",
"Share a funny childhood memory!",
"Do a 30-second impersonation of a famous character!",
"Share a funny pet story!",
"Do a 30-second interpretive dance!",
"Share a funny travel story!",
"Do a 30-second comedy skit!",
"Share a funny family tradition!",
"Do a 30-second magic trick!",
"Share a funny school memory!",
"Do a 30-second fitness challenge!",
"Share a funny work story!",
"Do a 30-second karaoke performance!",
"Share a funny dating story!",
"Do a 30-second stand-up comedy routine!",
"Share a funny holiday memory!",
"Do a 30-second dance-off with another player!",
"Share a funny prank you've pulled!",
"Do a 30-second lip-sync performance!"
]
}
if 'points' not in st.session_state:
st.session_state.points = {} # Individual player points
if 'team_points' not in st.session_state:
st.session_state.team_points = {} # Team points
if 'feedback' not in st.session_state:
st.session_state.feedback = []
if 'suggestions' not in st.session_state:
st.session_state.suggestions = []
if 'current_player' not in st.session_state:
st.session_state.current_player = None
if 'question' not in st.session_state:
st.session_state.question = None
if 'timer_start' not in st.session_state:
st.session_state.timer_start = None
if 'achievements' not in st.session_state:
st.session_state.achievements = {}
if 'timeouts' not in st.session_state:
st.session_state.timeouts = {}
if 'admin' not in st.session_state:
st.session_state.admin = False
if 'round' not in st.session_state:
st.session_state.round = 0
if 'dare_frequency' not in st.session_state:
st.session_state.dare_frequency = 5
if 'penalty_threshold' not in st.session_state:
st.session_state.penalty_threshold = 3
if 'game_paused' not in st.session_state:
st.session_state.game_paused = False
if 'available_categories' not in st.session_state:
st.session_state.available_categories = []
if 'theme' not in st.session_state:
st.session_state.theme = "Light"
if 'leaderboard_history' not in st.session_state:
st.session_state.leaderboard_history = []
if 'question_count' not in st.session_state:
st.session_state.question_count = 0
if 'current_category_index' not in st.session_state:
st.session_state.current_category_index = 0
if 'round_start_time' not in st.session_state:
st.session_state.round_start_time = None
# Theme CSS
def apply_theme():
if st.session_state.theme == "Dark":
st.markdown("""
<style>
body { background-color: #1a1a1a; color: #ffffff; }
.stApp { background-color: #1a1a1a; color: #ffffff; }
.stButton>button { background-color: #4CAF50; color: white; }
.stTextInput>div>input { background-color: #333; color: #fff; }
</style>
""", unsafe_allow_html=True)
elif st.session_state.theme == "Retro":
st.markdown("""
<style>
body { background-color: #f0e68c; color: #8b4513; font-family: 'Courier New', Courier, monospace; }
.stApp { background-color: #f0e68c; color: #8b4513; }
.stButton>button { background-color: #ff4500; color: white; }
.stTextInput>div>input { background-color: #fffacd; color: #8b4513; }
</style>
""", unsafe_allow_html=True)
else: # Light
st.markdown("""
<style>
body { background-color: #ffffff; color: #000000; }
.stApp { background-color: #ffffff; color: #000000; }
</style>
""", unsafe_allow_html=True)
# Non-blocking Timer HTML
timer_html = """
<script>
let timeLeft = 30;
let timer = setInterval(() => {
if (timeLeft > 0 && !window.paused) {
timeLeft--;
document.getElementById("timer").innerHTML = `โณ Time Remaining: ${timeLeft}s`;
document.getElementById("progress").value = 30 - timeLeft;
} else if (timeLeft <= 0) {
clearInterval(timer);
document.getElementById("timer").innerHTML = "โฐ Time's up!";
}
}, 1000);
function pauseTimer() {
window.paused = true;
}
function resumeTimer() {
window.paused = false;
}
</script>
<div id="timer">โณ Time Remaining: 30s</div>
<progress id="progress" value="0" max="30"></progress>
"""
# Sidebar - Registration and Socials
with st.sidebar:
st.header("๐Ÿš€ Player Registration")
with st.form("registration"):
player_name = st.text_input("Your Name")
team_name = st.text_input("Team Name (leave blank for solo)")
all_categories = ['Music', 'Love Language', 'Movies', 'Activities', '18+', 'Travel', 'Food', 'Personal Growth', 'Dare']
categories = st.multiselect("Choose Categories", all_categories, key=f"categories_{len(st.session_state.players)}")
avatar_file = st.file_uploader("Upload Avatar (optional)", type=["png", "jpg", "jpeg"])
submitted = st.form_submit_button("Join Game")
if submitted and player_name:
avatar_data = avatar_file.read() if avatar_file else None
st.session_state.players[player_name] = {
'categories': categories,
'joined': datetime.now(),
'team': team_name if team_name else player_name,
'avatar': base64.b64encode(avatar_data).decode('utf-8') if avatar_data else None
}
st.session_state.points[player_name] = 0
st.session_state.timeouts[player_name] = 0
if team_name:
if team_name not in st.session_state.teams:
st.session_state.teams[team_name] = []
st.session_state.team_points[team_name] = 0
st.session_state.teams[team_name].append(player_name)
st.session_state.registered = True
st.session_state.available_categories = list(set().union(*[p['categories'] for p in st.session_state.players.values()]))
st.success(f"Welcome {player_name}! You've joined the game.")
st.rerun()
st.header("๐ŸŽจ Theme Selection")
st.session_state.theme = st.selectbox("Choose Theme", ["Light", "Dark", "Retro"], index=["Light", "Dark", "Retro"].index(st.session_state.theme))
apply_theme()
st.header("๐Ÿ“ฑ Social Connect")
st.write("๐Ÿ”— [Instagram](https://instagram.com) | [Twitter](https://twitter.com)")
st.write("๐ŸŽง [Discord Server](https://discord.com) | ๐Ÿ“ง support@gamuu.com")
st.header("๐Ÿ’ก Feedback & Suggestions")
with st.form("feedback_form"):
feedback = st.text_area("Share your experience or suggest improvements")
if st.form_submit_button("Submit Feedback"):
if player_name:
st.session_state.feedback.append(feedback)
st.session_state.points[player_name] += 5
st.success("Thanks for your feedback! +5 points")
else:
st.error("Please register first!")
st.header("๐Ÿ”’ Admin Login")
admin_password = st.text_input("Admin Password", type="password")
if st.button("Login as Admin"):
if admin_password == "admin123": # Replace with a secure method
st.session_state.admin = True
st.success("Admin login successful!")
else:
st.error("Incorrect password.")
# Admin Dashboard
if st.session_state.admin:
st.sidebar.header("๐Ÿ”ง Admin Dashboard")
admin_tab1, admin_tab2 = st.sidebar.tabs(["Manage Questions", "Game Settings"])
with admin_tab1:
st.subheader("Add New Question")
with st.form("add_question"):
category = st.selectbox("Category", list(st.session_state.questions.keys()))
new_question = st.text_input("New Question")
if st.form_submit_button("Add Question"):
if category in st.session_state.questions:
if isinstance(st.session_state.questions[category], dict):
subcategory = st.selectbox("Subcategory", list(st.session_state.questions[category].keys()))
st.session_state.questions[category][subcategory].append(new_question)
else:
st.session_state.questions[category].append(new_question)
st.success("Question added successfully!")
else:
st.error("Category not found.")
st.subheader("Remove Question")
with st.form("remove_question"):
category = st.selectbox("Category to Remove From", list(st.session_state.questions.keys()))
if isinstance(st.session_state.questions[category], dict):
subcategory = st.selectbox("Subcategory", list(st.session_state.questions[category].keys()))
question_to_remove = st.selectbox("Question to Remove", st.session_state.questions[category][subcategory])
else:
question_to_remove = st.selectbox("Question to Remove", st.session_state.questions[category])
if st.form_submit_button("Remove Question"):
if isinstance(st.session_state.questions[category], dict):
st.session_state.questions[category][subcategory].remove(question_to_remove)
else:
st.session_state.questions[category].remove(question_to_remove)
st.success("Question removed successfully!")
with admin_tab2:
st.subheader("Game Settings")
penalty_threshold = st.number_input("Penalty Threshold", min_value=1, value=st.session_state.penalty_threshold)
dare_frequency = st.number_input("Dare Frequency (Rounds)", min_value=1, value=st.session_state.dare_frequency)
if st.button("Save Settings"):
st.session_state.penalty_threshold = penalty_threshold
st.session_state.dare_frequency = dare_frequency
st.success(f"Settings saved! Penalty Threshold: {penalty_threshold}, Dare Frequency: every {dare_frequency} rounds.")
# Main Game Interface
tab1, tab2, tab3, tab4 = st.tabs(["๐ŸŽฏ Game Zone", "๐Ÿ† Leaderboard", "๐ŸŽ Redeem Points", "๐ŸŒŸ Achievements"])
with tab1:
if st.session_state.registered:
st.header("๐ŸŒŸ Current Round")
col1, col2 = st.columns([3, 2])
players = list(st.session_state.players.keys())
with col1:
if st.button("โธ๏ธ Pause Game" if not st.session_state.game_paused else "โ–ถ๏ธ Resume Game"):
st.session_state.game_paused = not st.session_state.game_paused
if st.session_state.game_paused:
st.warning("Game Paused!")
st.components.v1.html("<script>pauseTimer();</script>", height=0)
else:
st.success("Game Resumed!")
st.components.v1.html("<script>resumeTimer();</script>", height=0)
if not st.session_state.game_paused:
# Round Timer (5 minutes = 300 seconds)
if st.session_state.round_start_time is None:
st.session_state.round_start_time = time.time()
round_time_left = 300 - int(time.time() - st.session_state.round_start_time)
if round_time_left <= 0:
st.session_state.current_player = None
st.session_state.question = None
st.session_state.timer_start = None
st.session_state.round_start_time = time.time()
st.session_state.question_count = 0
st.session_state.current_category_index = 0
st.warning("Round ended! Moving to next round.")
st.write(f"โณ Round Time Left: {round_time_left}s")
# Category Cycling
available_categories = st.session_state.available_categories
if st.session_state.question_count >= 9 and len(available_categories) > 1:
st.session_state.current_category_index = (st.session_state.current_category_index + 1) % len(available_categories)
st.session_state.question_count = 0
st.success(f"Switching to category: {available_categories[st.session_state.current_category_index]}")
selected_category = st.selectbox("Choose Question Category",
available_categories + ['Random'], index=st.session_state.current_category_index)
if selected_category == '18+' and '18+' in available_categories:
spice_level = st.select_slider("๐ŸŒถ๏ธ Spice Level",
options=['Spicy', 'Extra Spicy', 'Space Spicy', 'Hardcore'])
if st.button("๐ŸŒ€ Spin the Bottle", use_container_width=True):
if len(players) > 1:
st.session_state.current_player = random.choice(players)
st.session_state.timer_start = time.time()
st.session_state.round += 1
st.session_state.question_count += 1
if selected_category == '18+':
st.session_state.question = random.choice(st.session_state.questions['18+'][spice_level])
elif selected_category == 'Random':
category = random.choice(available_categories)
if isinstance(st.session_state.questions[category], dict):
subcategory = random.choice(list(st.session_state.questions[category].keys()))
st.session_state.question = random.choice(st.session_state.questions[category][subcategory])
else:
st.session_state.question = random.choice(st.session_state.questions[category])
else:
st.session_state.question = random.choice(st.session_state.questions[selected_category])
if st.session_state.round % st.session_state.dare_frequency == 0 and 'Dare' in available_categories:
st.session_state.question = random.choice(st.session_state.questions['Dare'])
st.success(f"๐ŸŽฏ {st.session_state.current_player}, it's your turn!")
st.session_state.round_start_time = time.time() if st.session_state.round_start_time is None else st.session_state.round_start_time
else:
st.error("Not enough players to spin the bottle!")
if st.session_state.current_player and st.session_state.question and not st.session_state.game_paused:
with col2:
player_avatar = st.session_state.players[st.session_state.current_player]['avatar']
if player_avatar:
st.image(f"data:image/png;base64,{player_avatar}", width=100)
st.subheader(f"๐ŸŽฏ Current Player: {st.session_state.current_player}")
st.subheader("โ“ Your Question:")
st.write(f"**{st.session_state.question}**")
# Non-blocking Timer
timer_placeholder = st.components.v1.html(timer_html, height=70)
if st.session_state.timer_start and time.time() - st.session_state.timer_start >= 30:
st.error("โฐ Time's up! Points deducted")
st.session_state.points[st.session_state.current_player] -= 10
st.session_state.timeouts[st.session_state.current_player] += 1
st.session_state.timer_start = None
# Penalty System
if st.session_state.timeouts[st.session_state.current_player] >= st.session_state.penalty_threshold:
st.error(f"{st.session_state.current_player} has timed out too many times and is penalized!")
savior = st.selectbox("Choose a Savior", [p for p in players if p != st.session_state.current_player])
ultimate_question = random.choice(st.session_state.questions['18+']['Hardcore'])
st.write(f"{savior}, answer this ultimate question to save {st.session_state.current_player}:")
st.write(f"**{ultimate_question}**")
if st.button("Submit Answer"):
st.success(f"{savior} has saved {st.session_state.current_player}!")
st.session_state.timeouts[st.session_state.current_player] = 0
if st.button("โœ… Submit Answer", key="answer_submit"):
time_taken = int(time.time() - st.session_state.timer_start)
points = max(50 - time_taken, 10)
st.session_state.points[st.session_state.current_player] += points
team = st.session_state.players[st.session_state.current_player]['team']
if team != st.session_state.current_player: # If part of a team
st.session_state.team_points[team] += points
st.success(f"๐ŸŽ‰ Answer accepted! +{points} points")
st.session_state.current_player = None
st.session_state.question = None
st.session_state.timer_start = None
with st.expander("๐Ÿ’ก Suggest a New Question"):
with st.form("question_suggestion"):
new_category = st.selectbox("Category", list(st.session_state.questions.keys()))
new_question = st.text_input("Your Question")
if st.form_submit_button("Suggest"):
if player_name:
st.session_state.suggestions.append((new_category, new_question))
st.session_state.points[player_name] += 15
st.success("Question submitted! +15 points")
else:
st.error("Please register first!")
with tab2:
st.header("๐Ÿ… Player Leaderboard")
sorted_players = sorted(st.session_state.points.items(), key=lambda x: x[1], reverse=True)
for i, (player, points) in enumerate(sorted_players):
avatar = st.session_state.players[player]['avatar']
if avatar:
st.image(f"data:image/png;base64,{avatar}", width=50)
st.metric(f"๐Ÿฅ‡ {i+1}. {player}", f"{points} points")
st.header("๐Ÿ… Team Leaderboard")
sorted_teams = sorted(st.session_state.team_points.items(), key=lambda x: x[1], reverse=True)
for i, (team, points) in enumerate(sorted_teams):
st.metric(f"๐Ÿฅ‡ {i+1}. Team {team}", f"{points} points")
st.header("๐Ÿ… Leaderboard History")
if st.button("Save Current Leaderboard"):
history_entry = {
'date': datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
'players': dict(sorted_players),
'teams': dict(sorted_teams)
}
st.session_state.leaderboard_history.append(history_entry)
st.success("Leaderboard saved!")
for entry in st.session_state.leaderboard_history:
st.write(f"**{entry['date']}**")
st.write("Players:", entry['players'])
st.write("Teams:", entry['teams'])
with tab3:
st.header("๐Ÿ›๏ธ Redeem Points")
if player_name and player_name in st.session_state.points:
current_points = st.session_state.points[player_name]
st.write(f"Your available points: {current_points}")
col1, col2, col3 = st.columns(3)
with col1:
st.subheader("๐ŸŽ Basic Rewards")
if st.button("Custom Emoji (50 points)"):
if current_points >= 50:
st.session_state.points[player_name] -= 50
st.success("๐ŸŽ‰ Emoji unlocked!")
with col2:
st.subheader("๐Ÿ’Ž Premium Rewards")
if st.button("Special Badge (200 points)"):
if current_points >= 200:
st.session_state.points[player_name] -= 200
st.success("๐ŸŒŸ Badge awarded!")
with col3:
st.subheader("๐Ÿ”ฅ Spicy Rewards")
if st.button("18+ Question Pack (300 points)"):
if current_points >= 300:
st.session_state.points[player_name] -= 300
st.success("๐Ÿ”ž Pack unlocked!")
else:
st.warning("Please register to redeem points.")
with tab4:
st.header("๐ŸŒŸ Achievements")
if player_name:
st.write(f"๐Ÿ† {player_name}'s Achievements:")
if st.session_state.achievements.get(player_name):
for achievement in st.session_state.achievements[player_name]:
st.write(f"- {achievement}")
else:
st.write("No achievements yet. Keep playing!")
else:
st.warning("Please register to view achievements.")
# Footer
st.markdown("---")
st.markdown("**๐ŸŽฎ Gamuu** - Where Connections Get Interesting! โ‹… v3.0 โ‹… [Privacy Policy] โ‹… [Terms of Service]")