jadarenee/CTRLPlay
0
1import gradio as gr2 3# Placeholder images (updated with your real ones!)4images = {5 "planning_room": "https://plus.unsplash.com/premium_photo-1731317217524-97389fb06929?q=80&w=3212&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",6 "riddle_gate": "https://i.pinimg.com/736x/b5/1f/9e/b51f9e8b4ee013e4bcdc6d574de2ee2b.jpg",7 "laser_grid": "https://plus.unsplash.com/premium_photo-1685148902854-9b9bb49fff08?q=80&w=3132&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",8 "vault": "https://images.unsplash.com/photo-1553205136-a5028624553c?q=80&w=3087&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",9 "heist_success": "https://images.unsplash.com/photo-1698285439446-2ad560e31a17?q=80&w=2960&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",10 "heist_fail": "https://images.unsplash.com/photo-1599350686877-382a54114d2f?q=80&w=3027&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"11}12 13# Vibe choices14vibes = ["Peace", "Joy", "Creativity"]15 16# Riddles and answers17riddles = {18 "Peace": ("I float in stillness but move like breath. What am I?", "calm"),19 "Joy": ("I dance without music. I shine without the sun. What am I?", "laughter"),20 "Creativity": ("I bloom from chaos and build dreams. What am I?", "art"),21}22 23# Main game logic24def vibe_heist(selected_vibe, user_input, current_stage):25 if current_stage == "planning":26 return images["riddle_gate"], f"Heist started! Solve this to enter the museum:\n\n{riddles[selected_vibe][0]}", "riddle"27 28 elif current_stage == "riddle":29 correct = riddles[selected_vibe][1]30 if user_input.strip().lower() == correct:31 return images["laser_grid"], "You passed the Riddle Gate! Now dodge the lasers. Type 'disable' to pass.", "laser"32 else:33 return images["heist_fail"], "Caught at the Riddle Gate! Mission failed.", "result"34 35 elif current_stage == "laser":36 if user_input.strip().lower() == "disable":37 return images["vault"], "You've reached the Vibe Vault! Type 'unlock' to open it.", "vault"38 else:39 return images["heist_fail"], "Hit by the security lasers! Mission failed.", "result"40 41 elif current_stage == "vault":42 if user_input.strip().lower() == "unlock":43 return images["heist_success"], f"๐ YOU STOLE THE VIBE OF {selected_vibe.upper()}! ๐", "result"44 else:45 return images["heist_fail"], "Couldn't unlock the vault! Mission failed.", "result"46 47 else:48 return images["planning_room"], "Choose your vibe and start the heist!", "planning"49 50# Helper function to actually play the game51def play_vibe_heist(selected_vibe, user_input, current_stage):52 return vibe_heist(selected_vibe, user_input, current_stage)53 54# Gradio Interface55def launch_vibe_heist():56 with gr.Blocks() as vibe_heist:57 gr.Markdown("# ๐ญ Vibe Heist\n_Steal the vibes. Win the moment._")58 59 vibe = gr.Dropdown(vibes, label="Choose Your Vibe Target")60 current_image = gr.Image(value=images["planning_room"], label="Heist Scene")61 instructions = gr.Textbox(value="Choose your vibe and start the heist!", interactive=False, label="Heist Instructions")62 user_action = gr.Textbox(placeholder="Type your action/answer...", label="Your Move")63 64 stage = gr.State("planning") # Track which stage you're on65 66 with gr.Row():67 start_btn = gr.Button("Start Heist / Continue")68 69 start_btn.click(70 play_vibe_heist, # โ
Now it's a real function71 inputs=[vibe, user_action, stage],72 outputs=[current_image, instructions, stage]73 )74 75 return vibe_heist76 77launch_vibe_heist().launch()78 