dmc12321

Untitled

Apr 21st, 2024
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 74.88 KB | None | 0 0
  1. import discord
  2. import random
  3. import asyncio
  4. import os
  5. from discord.ext import commands
  6. from discord.ui import Button, View
  7.  
  8. # Define the intents your bot will use
  9. intents = discord.Intents.default()
  10. intents.messages = True # Enable receiving message events
  11. intents.guilds = True # Enable receiving guild events
  12. intents.members = True # Enable receiving member events
  13. intents.message_content = True
  14.  
  15. # Initialize the Discord client with intents
  16. bot = commands.Bot(command_prefix='!', intents=discord.Intents.all())
  17.  
  18. # Define puzzles for each category
  19. ANIMALS_PUZZLES = [
  20. "Speedy Cheetah races across the African savannah",
  21. "Majestic Elephant trumpets loudly in the wilderness",
  22. "Graceful Giraffe stretches to reach high tree leaves",
  23. "Fierce Lion roars proudly on the African plains",
  24. "Majestic Eagle soars high above the rugged mountains",
  25. "Playful Dolphin leaps joyfully in the ocean waves",
  26. "Nocturnal Owl watches silently from the treetops",
  27. "Stealthy Panther prowls through the dense jungle",
  28. "Mighty Rhino charges through the African grasslands",
  29. "Curious Meerkat stands alert on the desert sands",
  30. "Sleek Leopard stalks its prey through the jungle",
  31. "Elegant Swan glides gracefully on the tranquil lake",
  32. "Gentle Deer grazes peacefully in the forest glade",
  33. "Agile Monkey swings effortlessly through the trees",
  34. "Regal Lioness leads her pride across the savannah",
  35. "Fearless Wolf howls under the silver moonlight",
  36. "Clever Fox darts through the underbrush in search of food",
  37. "Majestic Horse gallops freely in the open fields",
  38. "Adorable Bunny hops joyfully through the meadow",
  39. "Mysterious Black Panther lurks in the shadows",
  40. "Beautiful Peacock flaunts its vibrant feathers",
  41. "Swift Hummingbird flits from flower to flower",
  42. "Mighty Gorilla pounds its chest in the dense jungle",
  43. "Colorful Parrot squawks loudly in the tropical forest",
  44. "Steadfast Ox plows the fields with unwavering determination",
  45. "Sly Raccoon scavenges for food in the moonlight",
  46. "Enigmatic Chameleon blends seamlessly into its surroundings",
  47. "Noble Stag stands regally on the forest edge",
  48. "Swift Falcon dives swiftly from the sky in pursuit of prey",
  49. "Gentle Lamb frolics in the green pastures",
  50. ]
  51.  
  52. FOOD_DRINK_PUZZLES = [
  53. "Golden brown Croissant with a delicate buttery aroma",
  54. "Sizzling Fajitas with onions and peppers on a skillet",
  55. "Tantalizing Tiramisu layered with creamy mascarpone",
  56. "Spicy Pad Thai garnished with crushed peanuts and lime",
  57. "Buttery Lobster Tail served with drawn garlic butter",
  58. "Exotic Dragon Fruit with vibrant pink flesh and black seeds",
  59. "Crunchy Tempura Shrimp dipped in a tangy soy sauce",
  60. "Hearty Beef Stew simmered with root vegetables and herbs",
  61. "Refreshing Mojito with muddled mint and lime wedges",
  62. "Creamy Risotto infused with saffron and Parmesan cheese",
  63. "Fluffy Belgian Waffle topped with fresh berries and whipped cream",
  64. "Smoky BBQ Ribs glazed with tangy barbecue sauce",
  65. "Decadent Chocolate Fondue with assorted fruits and marshmallows",
  66. "Savory Gourmet Burger topped with melted cheese and crispy bacon",
  67. "Zesty Margherita Pizza with fresh tomatoes and basil leaves",
  68. "Velvety Pumpkin Soup garnished with roasted pumpkin seeds",
  69. "Fizzy Prosecco Champagne served in elegant crystal flutes",
  70. "Rich Chocolate Lava Cake oozing with molten chocolate center",
  71. "Crispy Calamari Rings served with spicy marinara dipping sauce",
  72. "Tangy Kimchi made from fermented cabbage and chili peppers",
  73. "Creamy Lobster Bisque garnished with fresh chives",
  74. "Aromatic Jasmine Rice steamed to fluffy perfection",
  75. "Juicy Watermelon slices chilled and refreshing on a hot day",
  76. "Tender Beef Wellington wrapped in flaky puff pastry",
  77. "Silky Chocolate Mousse topped with whipped cream and chocolate shavings",
  78. "Fragrant Earl Grey Tea served with a slice of lemon",
  79. "Succulent Roast Duck with crispy skin and tender meat",
  80. "Sweet and Sour Pineapple Chicken served over steamed rice",
  81. "Crunchy Kale Chips seasoned with sea salt and nutritional yeast",
  82. "Sizzling Beef Bulgogi marinated in a spicy sweet sauce",
  83. ]
  84.  
  85. QUOTES_PUZZLES = [
  86. "The journey of a thousand miles begins with a single step",
  87. "In the midst of chaos, there is also opportunity",
  88. "To live is the rarest thing in the world",
  89. "The only way to do great work is to love what you do",
  90. "Dream big and dare to fail",
  91. "Life is what happens when you're busy making other plans",
  92. "Success is not final, failure is not fatal",
  93. "The greatest glory in living lies not in never falling",
  94. "Believe you can and you're halfway there",
  95. "The future belongs to those who believe in the beauty",
  96. "Life is either a daring adventure or nothing at all",
  97. "Nothing in life is to be feared, it is only to be understood",
  98. "The only limit to our realization of tomorrow",
  99. "It is our choices that show what we truly are",
  100. "Every child is an artist. The problem is how to remain",
  101. "The only thing worse than being blind is having sight",
  102. "Do not go where the path may lead",
  103. "The only true wisdom is in knowing you know nothing",
  104. "A journey of a thousand miles begins with a single step",
  105. "The best way to predict the future is to invent it",
  106. "The secret of getting ahead is getting started",
  107. "You must be the change you wish to see in the world",
  108. "The future belongs to those who believe in the beauty",
  109. "Life is what happens when you're busy making other plans",
  110. "Strive not to be a success, but rather to be of value",
  111. "Change your thoughts and you change your world",
  112. "The only thing necessary for the triumph of evil",
  113. "The only way to do great work is to love what you do",
  114. "The best preparation for tomorrow is doing your best today",
  115. ]
  116.  
  117. MOVIES_PUZZLES = [
  118. "Inception A mind bending journey into the depths of dreams",
  119. "The Shawshank Redemption A tale of hope and redemption",
  120. "The Matrix A groundbreaking sci-fi adventure with mind bending twists",
  121. "Fight Club An edgy exploration of identity and consumerism",
  122. "The Dark Knight A gripping tale of chaos and morality",
  123. "Pulp Fiction A nonlinear narrative with unforgettable characters",
  124. "Forrest Gump A heartwarming story of love, loss, and destiny",
  125. "The Silence of the Lambs A chilling psychological thriller",
  126. "The Lord of the Rings An epic fantasy saga of friendship and heroism",
  127. "The Godfather A timeless tale of power, family, and betrayal",
  128. "The Shawshank Redemption A story of hope and resilience",
  129. "Schindler's List A poignant portrayal of humanity amid tragedy",
  130. "Star Wars A space opera that captured the imaginations of millions",
  131. "Casablanca A classic romance set against the backdrop of World War II",
  132. "The Lion King An animated masterpiece with timeless themes",
  133. "Titanic A tragic love story set aboard the ill-fated RMS Titanic",
  134. "The Wizard of Oz A whimsical journey through a magical land",
  135. "Goodfellas A gritty crime drama based on true events",
  136. "The Godfather A saga of power, loyalty, and betrayal",
  137. "Back to the Future A thrilling adventure through time",
  138. "The Matrix A mind bending journey into a simulated reality",
  139. "The Dark Knight A dark and complex exploration of heroism",
  140. "Fight Club A provocative examination of modern masculinity",
  141. "Inception A cerebral heist thriller set within the architecture of the mind",
  142. "The Shawshank Redemption A powerful tale of friendship and redemption",
  143. "Pulp Fiction A non-linear narrative weaving multiple storylines",
  144. "Forrest Gump A heartwarming journey through American history",
  145. "The Silence of the Lambs A gripping psychological thriller",
  146. "The Lord of the Rings An epic fantasy adventure of good versus evil",
  147. "Star Wars A timeless space opera that defined a generation",
  148. ]
  149.  
  150. PLACES_PUZZLES = [
  151. "Eiffel Tower An iconic landmark of Paris",
  152. "Statue of Liberty A symbol of freedom and democracy",
  153. "Great Wall of China An ancient marvel visible from space",
  154. "Machu Picchu A mystical Incan city perched high in the Andes Mountains",
  155. "Taj Mahal A magnificent marble mausoleum in Agra",
  156. "Pyramids of Giza Ancient wonders shrouded in mystery",
  157. "Grand Canyon A breathtaking natural wonder carved by the Colorado River",
  158. "Colosseum An iconic symbol of ancient Rome",
  159. "Sydney Opera House An architectural marvel on Sydney Harbour",
  160. "Mount Everest The tallest peak on Earth",
  161. "Niagara Falls A majestic natural wonder on the US-Canada border",
  162. "Bora Bora A tropical paradise with crystal-clear waters",
  163. "Angkor Wat A stunning temple complex in Cambodia",
  164. "Petra A historic city carved into rose-colored rock",
  165. "Acropolis An ancient citadel overlooking Athens",
  166. "Stonehenge A prehistoric monument in Wiltshire",
  167. "Times Square A bustling commercial and entertainment hub",
  168. "Big Ben An iconic clock tower in London",
  169. "Kremlin A historic fortress in the heart of Moscow",
  170. "Hollywood Walk of Fame A sidewalk tribute to entertainment icons",
  171. "Neuschwanstein Castle A fairytale castle nestled in the Bavarian Alps",
  172. "Mount Fuji An iconic volcanic peak in Japan",
  173. "Forbidden City A vast imperial palace complex in Beijing",
  174. "Easter Island Moai Enigmatic stone statues on a remote island",
  175. "Sistine Chapel Home to Michelangelo's masterpiece",
  176. "Burj Khalifa The tallest building in the world",
  177. "Mount Rushmore A monumental sculpture carved into granite",
  178. "Christ the Redeemer A towering monument in Rio de Janeiro",
  179. "Alhambra A stunning Moorish palace in Granada",
  180. "Golden Gate Bridge An iconic symbol of San Francisco",
  181. ]
  182.  
  183. FICTIONAL_CHARACTERS_PUZZLES = [
  184. "Hannibal Lecter A brilliant yet twisted psychiatrist and serial killer",
  185. "Sherlock Holmes A master detective with keen powers of observation",
  186. "Atticus Finch A principled lawyer defending justice in the South",
  187. "Darth Vader A dark lord of the Sith with a tragic past",
  188. "Katniss Everdeen A courageous rebel fighting against tyranny",
  189. "Lara Croft A fearless archaeologist exploring ancient ruins",
  190. "Dorothy Gale A plucky girl on a fantastical journey through Oz",
  191. "Captain Jack Sparrow A witty and eccentric pirate captain",
  192. "Hermione Granger A brilliant witch and loyal friend",
  193. "Frodo Baggins A humble hobbit tasked with saving Middle-earth",
  194. "Indiana Jones An adventurous archaeologist and treasure hunter",
  195. "Lisbeth Salander A fierce and enigmatic hacker seeking justice",
  196. "James Bond A suave and sophisticated MI6 agent",
  197. "Wolverine A fierce mutant with retractable claws and rapid healing",
  198. "Princess Leia A fearless leader of the Rebel Alliance",
  199. "Don Quixote An idealistic knight-errant on a quest for chivalry",
  200. "Winnie the Pooh A lovable bear with a penchant for honey",
  201. "The Joker A chaotic and unpredictable criminal mastermind",
  202. "Wonder Woman A powerful Amazonian warrior fighting for justice",
  203. "Peter Pan A mischievous boy who refuses to grow up",
  204. "Captain Ahab A obsessed captain on a quest for vengeance",
  205. "Spartacus A slave who leads a revolt against the Roman Empire",
  206. "Tarzan A jungle-dwelling hero raised by apes",
  207. "Mulan A courageous warrior who disguises herself as a man",
  208. "Luke Skywalker A farm boy who becomes a Jedi Knight",
  209. "The Wicked Witch of the West A malevolent sorceress from Oz",
  210. "Dracula A charismatic vampire with a thirst for blood",
  211. "Bilbo Baggins A reluctant hero on a journey to reclaim treasure",
  212. "Hercules A demi-god with superhuman strength",
  213. "Puss in Boots A charming and cunning feline adventurer",
  214. ]
  215.  
  216. WHAT_ARE_YOU_DOING_PUZZLES = [
  217. "Exploring the depths of a mysterious ancient ruin",
  218. "Embarking on a perilous journey across uncharted seas",
  219. "Deciphering the cryptic clues of a hidden treasure map",
  220. "Venturing into the heart of a dense and enchanted forest",
  221. "Unraveling the dark secrets of a haunted mansion",
  222. "Surviving in a post-apocalyptic wasteland overrun by mutants",
  223. "Navigating the treacherous waters of a pirate-infested sea",
  224. "Fighting alongside valiant knights in a medieval battlefield",
  225. "Confronting the ultimate evil in a battle for the fate of the world",
  226. "Embarking on a quest to save a kidnapped princess from a dragon",
  227. "Traversing the vast expanse of a desert kingdom on camelback",
  228. "Solving the riddles of an enigmatic sphinx in the desert sands",
  229. "Outwitting a cunning and ruthless bandit king in a high-stakes heist",
  230. "Exploring the mystical realms of the fae in search of hidden treasures",
  231. "Engaging in a deadly game of cat-and-mouse with a notorious assassin",
  232. "Surviving the harsh conditions of an unforgiving arctic wilderness",
  233. "Fulfilling an ancient prophecy to bring balance to the world",
  234. "Discovering the lost civilization of an ancient and forgotten people",
  235. "Rescuing a group of hostages from a terrorist stronghold",
  236. "Escaping from a maximum-security prison with cunning and stealth",
  237. "Sailing the high seas in search of fame, fortune, and adventure",
  238. "Defeating a horde of rampaging monsters threatening a peaceful village",
  239. "Challenging a powerful sorcerer to a magical duel of wits and wills",
  240. "Exploring the dark and twisted corridors of a cursed castle",
  241. "Surviving a zombie apocalypse with quick thinking and resourcefulness",
  242. "Embarking on an epic quest to recover a stolen artifact of immense power",
  243. "Confronting the ghostly inhabitants of a haunted mansion",
  244. "Braving the dangers of a dense and forbidding jungle",
  245. "Racing against time to stop an impending cataclysmic event",
  246. "Battling against hordes of demons to save the world from eternal darkness",
  247. ]
  248.  
  249. WHAT_ARE_YOU_WEARING_PUZZLES = [
  250. "A suit of shining armor adorned with intricate engravings",
  251. "A flowing robe woven from the finest silk and embroidered with gold thread",
  252. "A cloak of invisibility that renders its wearer unseen to all but the keenest eyes",
  253. "A pendant imbued with ancient magic that grants its wearer protection from harm",
  254. "A crown of shimmering diamonds that glitters in the light of the full moon",
  255. "A pair of enchanted boots that allow their wearer to walk on water",
  256. "A mask of cunning disguise that conceals its wearer's true identity",
  257. "A cloak of shadows that renders its wearer invisible to mortal eyes",
  258. "A pair of wings fashioned from feathers of purest white that grant their wearer the gift of flight",
  259. "A circlet of starlight that bestows upon its wearer visions of the future",
  260. "A robe of flowing lava that grants its wearer mastery over fire",
  261. "A helm of shining steel that protects its wearer from all harm",
  262. "A pair of gauntlets forged from the heart of a fallen star that grant their wearer the strength of a titan",
  263. "A cloak of whispers that grants its wearer the power of persuasion",
  264. "A mask of many faces that grants its wearer the ability to change their appearance at will",
  265. "A pair of sandals that grant their wearer the speed of Hermes",
  266. "A crown of flames that grants its wearer the power of pyrokinesis",
  267. "A helm of shadows that grants its wearer the power to command the darkness",
  268. "A cloak of shimmering moonlight that grants its wearer the power of illusion",
  269. "A pair of gloves that grant their wearer mastery over the elements",
  270. "A belt of stars that grants its wearer the power to control the heavens",
  271. ]
  272.  
  273. SONG_TITLES_PUZZLES = [
  274. "Tears Dry on Their Own",
  275. "Killing Me Softly with His Song",
  276. "Dancing Queen in the Moonlight",
  277. "A Whiter Shade of Pale",
  278. "The Sound of Silence",
  279. "You're the One That I Want",
  280. "The Thrill Is Gone Away",
  281. "I Can't Help Falling in Love",
  282. "You Can't Always Get What You Want",
  283. "With or Without You",
  284. "Come As You Are",
  285. "Bridge Over Troubled Water",
  286. "Wish You Were Here with Me",
  287. "Don't Let the Sun Go Down on Me",
  288. "I Heard It Through the Grapevine",
  289. "A Horse with No Name",
  290. "When You Were Young and Free",
  291. "Girls Just Want to Have Fun",
  292. "Dream a Little Dream of Me",
  293. "What's Love Got to Do with It"
  294. ]
  295.  
  296. RIDDLES_AND_RHYMES_PUZZLES = [
  297. "Measure of Time, Yet Subjective in Length",
  298. "Once in a Minute, Yet Fleeting as Thought",
  299. "Head and Tail, Yet Mobility Without Limbs",
  300. "Take and Leave, Yet Always Equally Balanced",
  301. "Keys to Gates, Yet Doors Remain Shut",
  302. "Neck Without Head, Yet Graceful in Form",
  303. "Made and Sold, Yet Never Truly Owned",
  304. "Broken Before Use, Yet Intact in Concept",
  305. "Wet and Dry, Yet Both in Simultaneous State",
  306. "Speech Without Words, Yet Communicative in Nature",
  307. "Sightless Gaze, Yet Perceptive in Insight",
  308. "Many Keys, Yet None Fit the Lock",
  309. "Yours to Hold, Yet Others to Employ",
  310. "Endless Journey, Yet Stationary in Space",
  311. "Face and Hands, Yet Bodyless and Free",
  312. "Head and Tail, Yet Earthy in Hue",
  313. "Grows in Absence, Yet Shrinks in Presence",
  314. "Balanced Step, Yet Straddled Between Realms",
  315. "Descends Forever, Yet Never Soars",
  316. "Cracked, Made, Told, Played, Yet Eternal Cycle",
  317. "Civilization's Map, Yet Nature's Dominion",
  318. "Catches Dreams, Yet Lets Realities Slip",
  319. "Expands Limitlessly, Yet Occupies No Volume",
  320. "Letter of Start and Finish, Yet Infinite in Between",
  321. "Grip of Right, Yet Released by the Left",
  322. "Shattered by Force, Yet Never Felled by Gravity",
  323. "Sees All, Yet Remains Blind to Truth",
  324. "Speaks of Hunger, Yet Nourishes Not",
  325. "Quantified for Preparation, Yet Unmeasured in Impact",
  326. ]
  327.  
  328. PUZZLES = {
  329. "Animals": ANIMALS_PUZZLES,
  330. "Food and Drink": FOOD_DRINK_PUZZLES,
  331. "Quotations": QUOTES_PUZZLES,
  332. "Movie Quotes": MOVIES_PUZZLES,
  333. "Places": PLACES_PUZZLES,
  334. "Fictional Characters": FICTIONAL_CHARACTERS_PUZZLES,
  335. "What Are You Doing": WHAT_ARE_YOU_DOING_PUZZLES,
  336. "What Are You Wearing": WHAT_ARE_YOU_WEARING_PUZZLES,
  337. "Song Titles": SONG_TITLES_PUZZLES,
  338. "Riddles and Rhymes": RIDDLES_AND_RHYMES_PUZZLES,
  339. }
  340.  
  341. # Define possible outcomes for spinning the wheel
  342. WHEEL_OUTCOMES = [
  343. "Robbed",
  344. "Spin Lost",
  345. "Spin Again",
  346. "100",
  347. "200",
  348. "300",
  349. "400",
  350. "500",
  351. "600",
  352. "700",
  353. "800",
  354. "900",
  355. "1000",
  356. "1500"
  357. ]
  358.  
  359. SUPER_WHEEL_OUTCOMES = [
  360. "1000",
  361. "1500",
  362. "2500"
  363. ]
  364.  
  365. ULTRA_WHEEL_OUTCOMES = [
  366. "2000",
  367. "3000",
  368. "4000"
  369. ]
  370.  
  371. MEGA_WHEEL_OUTCOMES = [
  372. "2500",
  373. "4000",
  374. "5000"
  375. ]
  376.  
  377. # Define a dictionary of commands and their descriptions
  378. commands_dict = {
  379. '!ssw': 'Start a new game',
  380. '!join': 'Join the game.',
  381. '!joint': 'Special command for joey',
  382. '!spin': 'Spin the wheel.',
  383. '!guess [letter]': 'Guess a letter in the puzzle.',
  384. '!solve [puzzle]': 'Attempt to solve the puzzle.',
  385. '!superspin': 'Spin the wheel with extra chance of winning (requires win count between 10 and 24).',
  386. '!ultraspin': 'Spin the wheel with extra chance of winning (requires win count between 25 and 49).',
  387. '!megaspin': 'Spin the wheel with extra chance of winning (requires win count of 50 or more).',
  388. '!commands': 'Display the list of available commands.'
  389. }
  390.  
  391. special_players = {
  392. "480539285607546910": "WELCOME QUEEN LIZZY! YOU ARE AMAZING!\nhttps://tenor.com/view/lizard-elmo-liz-hi-liz-hi-lizzy-elmo-lizzy-gif-26781052",
  393. "1222299615538450465": "SUPREMEEE VICTORYYY!\nhttps://tenor.com/view/sabrewulf-video-games-gaming-xbox-killer-instinct-gif-3538282248554946598",
  394. "1197590901741076601": "Welcome the coup queen!\nhttps://tenor.com/view/hi-kira-e-chill-gif-24196509",
  395. "725242689498513458": "Soft kitty...Warm Kitty... I AM ANGRY KITTY... WOMP WOMP\nhttps://tenor.com/view/annoyed-disappointed-mad-upset-gif-26051038",
  396. "1063542949314560092": "JOEY HAS ARRIVED PUFF PUFF PASS!\nhttps://tenor.com/view/sister-joe-dirt-david-spade-hands-up-gif-16731619"
  397. }
  398.  
  399. # Global variables
  400. game_created = False
  401. game_started = False # Flag to track if the game has started
  402. players = {}
  403. current_player = None
  404. current_puzzle = ""
  405. current_category = None # Define current_category globally
  406. revealed_letters = []
  407. scoreboard = {}
  408. guessed_correctly = False
  409. outcome = None # Define outcome here to avoid reference error
  410. solve_attempted = False # Flag to track if a solve attempt was made
  411. game_initiator = None # Store the user who initiated the game
  412. guessed_letters = [] # GUESSED LETTERS
  413. win_counts = {} # Initialize win counts dictionary
  414.  
  415.  
  416. # Initialize players dictionary with win counts
  417. def initialize_players():
  418. global players
  419. win_counts = read_win_counts()
  420. # Initialize players with win counts
  421. for player_id in win_counts.keys():
  422. players[player_id] = {'win_count': win_counts[player_id], 'spun': False, 'superspun': False, 'ultraspun': False,
  423. 'megaspun': False}
  424.  
  425.  
  426. # Function to reset game state
  427. def reset_game():
  428. global game_created, game_started, players, current_player, current_puzzle, revealed_letters, scoreboard, \
  429. guessed_correctly, outcome, solve_attempted, game_initiator
  430. game_created = False
  431. game_started = False
  432. players.clear()
  433. current_player = None
  434. current_puzzle = ""
  435. revealed_letters = []
  436. scoreboard = {}
  437. guessed_correctly = False
  438. outcome = None
  439. solve_attempted = False
  440. game_initiator = None
  441. global guessed_letters
  442. guessed_letters = []
  443. current_category = None
  444.  
  445.  
  446. # Event: Bot is ready
  447. @bot.event
  448. async def on_ready():
  449. print(f'Logged in as {bot.user}')
  450.  
  451. # Function to load win counts from file
  452. def load_win_counts():
  453. win_counts = {}
  454. with open('wincount.txt', 'r') as file:
  455. for line in file:
  456. user_id, count = line.strip().split(':')
  457. win_counts[user_id] = int(count)
  458. return win_counts
  459.  
  460. # Function to initialize players dictionary with win counts from the file
  461. def initialize_players():
  462. players = {}
  463. win_counts = load_win_counts()
  464. for user_id in win_counts:
  465. players[user_id] = {'win_count': win_counts[user_id], 'spun': False,
  466. 'superspun': False} # Include 'spun' and 'superspun'
  467. return players
  468.  
  469. # Event: Message received
  470. @bot.event
  471. async def on_message(message):
  472. global game_created, game_started, current_player, current_puzzle, revealed_letters, scoreboard, \
  473. guessed_correctly, outcome, solve_attempted, game_initiator, players
  474. if message.author == bot.user:
  475. return
  476.  
  477. elif message.content == '!ssw':
  478. # Create a new game if one isn't already in progress
  479. if not game_created:
  480. reset_game()
  481. game_initiator = message.author # Store the user who initiated the game
  482. game_created = True
  483. await message.channel.send('Saberwulfs Spin Wheel! Type !join to join the game! and !start to start')
  484. await message.channel.send("Copyright Disclaimer:\n"
  485. "This Wheel of Fortune game is inspired by the original "
  486. "\"Wheel of Fortune\" television show created by Merv Griffin. "
  487. "All rights for the original concept, format, and trademarks belong "
  488. "to their respective owners. This game is created purely for entertainment "
  489. "purposes and is not affiliated with, endorsed by, or sponsored by the creators "
  490. "of the original \"Wheel of Fortune\" show.")
  491. # Add the user who typed !ssw to the game
  492. if message.author not in players:
  493. players[message.author] = {'spun': False, 'superspun': False, 'ultraspun': False,
  494. 'megaspun': False} # Initialize spun status for the player
  495. await message.channel.send(f'{message.author.mention} joined the game!')
  496.  
  497. join_button = Button(label="Join!", style=discord.ButtonStyle.green, custom_id="join_button")
  498. start_button = Button(label="Start!", style=discord.ButtonStyle.green, custom_id="start_button")
  499.  
  500. async def button_callback(interaction):
  501. global game_started, current_category, current_player
  502. if interaction.data['custom_id'] == "join_button":
  503. # Add the player to the game if it's created and not started
  504. if game_created and not game_started:
  505. if interaction.user not in players:
  506. # Initialize spun and superspun status for the player
  507. players[interaction.user] = {'spun': False, 'superspun': False, 'ultraspun': False,
  508. 'megaspun': False}
  509. await interaction.channel.send(f'{interaction.user.mention} joined the game!')
  510. # Send a message after the command is entered
  511. await interaction.channel.send("Thank you for joining the game!")
  512. # Send a list of players who have joined the game
  513. if players:
  514. player_list = '\n'.join([p.mention for p in players.keys()])
  515. await interaction.channel.send(f'Players in the game: {player_list}')
  516. # Special messages for specific users
  517. if str(interaction.user.id) == "480539285607546910": # Lizzy's ID
  518. await interaction.channel.send("WELCOME QUEEN LIZZY! YOU ARE AMAZING!")
  519. await interaction.channel.send(
  520. "https://tenor.com/view/lizard-elmo-liz-hi-liz-hi-lizzy-elmo-lizzy-gif-26781052")
  521. elif str(interaction.user.id) == "1222299615538450465": # SABERS's ID
  522. await interaction.channel.send("SUPREME VICTORYYY!")
  523. await interaction.channel.send(
  524. "https://tenor.com/view/sabrewulf-video-games-gaming-xbox-killer-instinct-gif-3538282248554946598")
  525. elif str(interaction.user.id) == "1197590901741076601": # Kira's ID
  526. await interaction.channel.send("Welcome the coup queen!")
  527. await interaction.channel.send(
  528. "https://tenor.com/view/hi-kira-e-chill-gif-24196509")
  529. elif str(interaction.user.id) == "725242689498513458": # Rere's ID
  530. await interaction.channel.send(
  531. "Soft kitty...Warm Kitty... I AM ANGRY KITTY... WOMP WOMP")
  532. await interaction.channel.send(
  533. "https://tenor.com/view/annoyed-disappointed-mad-upset-gif-26051038")
  534. else:
  535. await interaction.channel.send('You have already joined the game.')
  536. elif game_started:
  537. await interaction.channel.send('Sorry, the game has already started. You cannot join now.')
  538. else:
  539. await interaction.channel.send(
  540. 'There is no game currently. Please create a game using !ssw.')
  541. elif interaction.data['custom_id'] == "start_button":
  542. # Start the game
  543. if interaction.user == game_initiator and not current_player:
  544. # Your existing logic for starting the game
  545. game_started = True # Mark the game as started
  546. await interaction.channel.send('Game started! Waiting for spins...')
  547. # Prompt the player to select a category
  548. await interaction.channel.send('Please pick a category for the puzzles:\n'
  549. 'Categories:\n'
  550. '1. Riddles and Rhymes\n'
  551. '2. Food and Drink\n'
  552. '3. Places\n'
  553. '4. Fictional Characters\n'
  554. '5. Movie Quotes\n'
  555. '6. Quotations\n'
  556. '7. What Are You Doing\n'
  557. '8. What Are You Wearing\n'
  558. '9. Song Titles\n'
  559. '10. Animals')
  560. # Store the selected category
  561. selected_category = None
  562. category_names = {
  563. 1: "Riddles and Rhymes",
  564. 2: "Food and Drink",
  565. 3: "Places",
  566. 4: "Fictional Characters",
  567. 5: "Movie Quotes",
  568. 6: "Quotations",
  569. 7: "What Are You Doing",
  570. 8: "What Are You Wearing",
  571. 9: "Song Titles",
  572. 10: "Animals"
  573. }
  574.  
  575. puzzles = None
  576.  
  577. def check_category(m):
  578. return m.author == interaction.user and m.content.isdigit() and 1 <= int(
  579. m.content) <= 10
  580.  
  581. try:
  582. category_message = await bot.wait_for('message', check=check_category, timeout=30)
  583. selected_category = int(category_message.content)
  584. except asyncio.TimeoutError:
  585. await interaction.channel.send(
  586. 'You took too long to select a category. Game ended.')
  587. reset_game()
  588. return
  589.  
  590. # Define puzzles for each category
  591. if selected_category == 1:
  592. puzzles = RIDDLES_AND_RHYMES_PUZZLES
  593. elif selected_category == 2:
  594. puzzles = FOOD_DRINK_PUZZLES
  595. elif selected_category == 3:
  596. puzzles = PLACES_PUZZLES
  597. elif selected_category == 4:
  598. puzzles = FICTIONAL_CHARACTERS_PUZZLES
  599. elif selected_category == 5:
  600. puzzles = MOVIES_PUZZLES
  601. elif selected_category == 6:
  602. puzzles = QUOTES_PUZZLES
  603. elif selected_category == 7:
  604. puzzles = WHAT_ARE_YOU_DOING_PUZZLES
  605. elif selected_category == 8:
  606. puzzles = WHAT_ARE_YOU_WEARING_PUZZLES
  607. elif selected_category == 9:
  608. puzzles = SONG_TITLES_PUZZLES
  609. elif selected_category == 10:
  610. puzzles = ANIMALS_PUZZLES
  611.  
  612. current_puzzle = random.choice(puzzles)
  613. # Check if the current puzzle contains a category name
  614. if ":" in current_puzzle:
  615. category, puzzle_text = current_puzzle.split(":", 1)
  616. else:
  617. # If the puzzle text contains colons, consider the entire puzzle text as the puzzle and choose a default category name
  618. category = category_names[selected_category]
  619. puzzle_text = current_puzzle
  620. revealed_letters = ['-' if char.isalpha() else char for char in puzzle_text]
  621. # Display the puzzle with "-" for unrevealed letters and guessed letters underneath
  622. puzzle_display = ' '.join(revealed_letters)
  623. # Save the current category
  624. current_category = category_names[selected_category]
  625. await interaction.channel.send(
  626. f'Category: {current_category}\nPuzzle: {puzzle_display}')
  627. # Initialize scoreboard
  628. for player in players.keys():
  629. scoreboard[player] = 0
  630. # Select a random player to start
  631. current_player = random.choice(list(players.keys()))
  632. if current_player is not None:
  633. await interaction.channel.send(
  634. f"It's {current_player.mention}'s turn to spin! Use !spin")
  635. spin_button = Button(label="Spin!", style=discord.ButtonStyle.green,
  636. custom_id="spin_button")
  637.  
  638. # Define the spin button callback function
  639. async def spin_button_callback(inter, current_player):
  640. outcome = random.choice(WHEEL_OUTCOMES)
  641. if current_player is not None:
  642. await inter.channel.send(
  643. f'{current_player.mention} spun the wheel and got: {outcome}')
  644. # Display the puzzle with correctly guessed letters
  645. puzzle_display = ' '.join(revealed_letters)
  646. await inter.channel.send(f'Current Puzzle: {puzzle_display}')
  647. await inter.channel.send(f"The current category is: {current_category}")
  648. guessed_letters_display = ', '.join(guessed_letters)
  649. await inter.channel.send(f'Letters Already Guessed: {guessed_letters_display}')
  650. players[current_player]['spun'] = True
  651. # If outcome allows, prompt the player to guess a letter
  652. # Handle the outcome of the spin
  653. if outcome.isdigit():
  654. await inter.channel.send('Guess a letter using !guess or !solve to Solve.')
  655. guessed_correctly = False
  656. elif outcome == "Spin Again":
  657. await inter.channel.send('You got Spin Again! Please !spin again...')
  658. await inter.channel.send(
  659. 'https://tenor.com/view/zach-galifianakis-angry-intense-mad-rage-gif-20192527')
  660. # Reset the spin status for the player
  661. players[current_player]['spun'] = False
  662. # Remind the player to spin again
  663. if current_player is not None:
  664. await inter.channel.send(
  665. f'{current_player.mention}, it\'s your turn to spin again! use !spin')
  666. elif outcome == "Robbed":
  667. await inter.channel.send(
  668. 'You spun "Robbed"! You lose all your points. WOMP WOMP!')
  669. await inter.channel.send(
  670. 'https://tenor.com/view/spongebob-money-in-the-bag-gif-21484249')
  671. scoreboard[current_player] = 0 # Reset player's score to 0
  672. await inter.channel.send('Your score has been reset to 0.')
  673. current_player = next_player()
  674. for player in players.keys():
  675. players[player]['spun'] = False
  676. if current_player is not None:
  677. await inter.channel.send(
  678. f'It\'s {current_player.mention}\'s turn to spin! use !spin')
  679. else:
  680. await inter.channel.send(
  681. 'You Lose your turn! It\'s now the next player\'s turn.')
  682. await inter.channel.send(
  683. 'https://tenor.com/view/hehe-not-hehe-no-angry-cat-angry-gif-23436666')
  684. current_player = next_player()
  685. for player in players.keys():
  686. players[player]['spun'] = False
  687. if current_player is not None:
  688. await inter.channel.send(
  689. f'It\'s {current_player.mention}\'s turn to spin! use !spin')
  690.  
  691. # Start a timer for 90 seconds for the player to guess or solve
  692. try:
  693. msg = await bot.wait_for('message', timeout=30,
  694. check=lambda m: m.author == current_player
  695. and not guessed_correctly
  696. and (m.content.startswith(
  697. '!solve') or m.content.startswith('!guess')
  698. or m.content.startswith('!spin')))
  699. if msg.content == '!solve' or msg.content == '!guess':
  700. # Proceed with guessing or solving
  701. # Your existing logic here
  702. pass
  703. else:
  704. # Ignore the message and allow the player to continue their turn
  705. pass
  706. except asyncio.TimeoutError:
  707. await inter.channel.send(
  708. "You took too long to guess or solve. It's now the next player's turn.")
  709. current_player = next_player()
  710. for player in players.keys():
  711. players[player]['spun'] = False
  712. if current_player is not None:
  713. await inter.channel.send(
  714. f"It's {current_player.mention}'s turn to spin! use !spin")
  715.  
  716. spin_button.callback = lambda inter: spin_button_callback(inter, current_player)
  717. view = View()
  718. view.add_item(spin_button)
  719. await interaction.channel.send("Click the button below to spin the wheel!", view=view)
  720.  
  721. # Define the guess button
  722. guess_button = Button(label="Guess!", style=discord.ButtonStyle.green,
  723. custom_id="guess_button")
  724.  
  725. # Define the spin button callback function
  726. async def spin_button_callback(inter, current_player):
  727. outcome = random.choice(WHEEL_OUTCOMES)
  728. if current_player is not None:
  729. await inter.channel.send(
  730. f'{current_player.mention} spun the wheel and got: {outcome}')
  731. # Display the puzzle with correctly guessed letters
  732. puzzle_display = ' '.join(revealed_letters)
  733. await inter.channel.send(f'Current Puzzle: {puzzle_display}')
  734. await inter.channel.send(f"The current category is: {current_category}")
  735. guessed_letters_display = ', '.join(guessed_letters)
  736. await inter.channel.send(f'Letters Already Guessed: {guessed_letters_display}')
  737.  
  738. # Add the guess button
  739. view = View()
  740. view.add_item(guess_button)
  741. await inter.channel.send("Click the button below to guess a letter!", view=view)
  742.  
  743. players[current_player]['spun'] = True
  744. # Your existing logic for handling spin outcomes...
  745.  
  746. async def guess_button_callback(inter, current_player):
  747. global current_puzzle, guessed_letters, revealed_letters, scoreboard, outcome
  748.  
  749. # Check if it's the player's turn and the game conditions are met for guessing
  750. if current_player and inter.user == current_player and players[current_player][
  751. 'spun']:
  752. # Ask the player to guess a letter
  753. await inter.channel.send('Which letter would you like to guess?')
  754.  
  755. def check(m):
  756. return m.author == current_player and len(
  757. m.content) == 1 and m.content.isalpha()
  758.  
  759. try:
  760. # Wait for the player's response with a timeout of 60 seconds
  761. guess_message = await bot.wait_for('message', check=check, timeout=60)
  762. # Get the guessed letter from the message content
  763. guessed_letter = guess_message.content.strip().lower()
  764. # Check if the guessed letter has already been guessed
  765. if guessed_letter in guessed_letters:
  766. await inter.channel.send(
  767. 'This letter has already been guessed! Skipping your turn.')
  768. # Move on to the next player
  769. current_player = next_player()
  770. if current_player is not None:
  771. await inter.channel.send(
  772. f"It's {current_player.mention}'s turn to spin! use !spin")
  773. return # Skip the rest of the handling for this guess
  774.  
  775. if guessed_letter not in guessed_letters:
  776. guessed_letters.append(guessed_letter)
  777. # Check if the guessed letter is in the puzzle
  778. if guessed_letter in current_puzzle.lower():
  779. for i, char in enumerate(current_puzzle):
  780. if char.lower() == guessed_letter:
  781. revealed_letters[i] = char
  782.  
  783. # Reconstruct the updated puzzle with revealed letters
  784. updated_puzzle = ''.join(
  785. char if char.isalpha() or char == ' ' else '-' for char in
  786. current_puzzle.lower())
  787.  
  788. # Display the updated puzzle
  789. await inter.channel.send(
  790. f'Current Puzzle: {updated_puzzle.capitalize()}')
  791.  
  792. # Update the scoreboard with the points from the spin
  793. if outcome.isdigit():
  794. # Calculate points based on the occurrence of the guessed letter
  795. if guessed_letter in current_puzzle.lower():
  796. points = int(outcome)
  797. scoreboard[current_player] += points
  798. # Display the current scoreboard
  799. await inter.channel.send('Turn ended! Scores:')
  800. for player, score in scoreboard.items():
  801. await inter.channel.send(f'{player.mention}: {score}')
  802.  
  803. # Check if all letters have been guessed correctly and prompt the player to solve the puzzle
  804. guessed_correctly = all(
  805. char.isalpha() or char == ' ' for char in revealed_letters)
  806. if guessed_correctly:
  807. await inter.channel.send(
  808. 'All letters have been guessed correctly! Use !spin then !solve to solve the puzzle.')
  809.  
  810. # Display guessed letters
  811. guessed_letters_display = ', '.join(guessed_letters)
  812. await inter.channel.send(
  813. f'Letters Already Guessed: {guessed_letters_display}')
  814.  
  815. else:
  816. await inter.channel.send(
  817. 'Sorry, the guessed letter is not in the puzzle.')
  818. # Move on to the next player
  819. current_player = next_player()
  820. if current_player is not None:
  821. await inter.channel.send(
  822. f"It's {current_player.mention}'s turn to spin! use !spin")
  823.  
  824. except asyncio.TimeoutError:
  825. await inter.channel.send('You took too long to guess.')
  826. # Move on to the next player
  827. current_player = next_player()
  828. if current_player is not None:
  829. await inter.channel.send(
  830. f"It's {current_player.mention}'s turn to spin! use !spin")
  831. else:
  832. await inter.channel.send("It's not your turn!")
  833.  
  834. # Set the callback for the guess button
  835. guess_button.callback = lambda inter: guess_button_callback(inter, current_player)
  836.  
  837. # Set the callbacks for the buttons
  838. spin_button.callback = lambda inter: spin_button_callback(inter, current_player)
  839.  
  840.  
  841. join_button.callback = button_callback
  842. start_button.callback = button_callback
  843.  
  844. view = View()
  845. view.add_item(join_button)
  846. if not game_started: # Add start button only if the game hasn't started yet
  847. view.add_item(start_button)
  848. await message.channel.send("Click the buttons below to join or start the game!", view=view)
  849.  
  850. elif message.content == '!joint':
  851. # Check if the author of the message is the allowed user
  852. if str(message.author.id) == "1063542949314560092": # Replace this ID with the desired user's ID
  853. # Add the player to the game if it's created and not started
  854. if game_created and not game_started:
  855. if message.author not in players:
  856. # Initialize spun and superspun status for the player
  857. players[message.author] = {'spun': False, 'superspun': False, 'ultraspun': False, 'megaspun': False}
  858. await message.channel.send(f'{message.author.mention} joined the game!')
  859. # Send a message after the command is entered
  860. await message.channel.send("Thank you for joining the game!")
  861. await message.channel.send("JOEY HAS ARRIVED PUFF PUFF PASS!")
  862. await message.channel.send(
  863. "https://tenor.com/view/sister-joe-dirt-david-spade-hands-up-gif-16731619") # Additional message for !joint
  864. # Send a list of players who have joined the game
  865. if players:
  866. player_list = '\n'.join([p.mention for p in players.keys()])
  867. await message.channel.send(f'Players in the game: {player_list}')
  868. elif game_started:
  869. await message.channel.send('Sorry, the game has already started. You cannot join now.')
  870. else:
  871. await message.channel.send('There is no game currently. Please create a game using !ssw.')
  872. else:
  873. await message.channel.send("You are not authorized to use this command.")
  874.  
  875.  
  876.  
  877. elif message.content == '!superspin':
  878. # Read win counts from the file
  879. win_counts = {}
  880. with open('wincount.txt', 'r') as file:
  881. for line in file:
  882. # Split the line based on whitespace
  883. parts = line.strip().split()
  884. if len(parts) >= 2: # Ensure there are at least two parts
  885. user_id = parts[0]
  886. count = int(parts[1])
  887. win_counts[user_id] = count
  888. else:
  889. print(f"Ignoring invalid line in wincount.txt: {line.strip()}")
  890.  
  891. if current_player is not None:
  892. # Check if the author is the current player, the command hasn't been used yet in this game,
  893. # and the win count is between 10 and 24
  894. if message.author == current_player and not players[current_player]['spun'] and not players[current_player][
  895. 'superspun']:
  896. # Check if the player has the required win count
  897. author_id = str(message.author.id)
  898. if author_id in win_counts and 10 <= win_counts[author_id] <= 24: # Adjust range as needed
  899. outcome = random.choice(SUPER_WHEEL_OUTCOMES)
  900. if message.author:
  901. await message.channel.send(f'{message.author.mention} spun the wheel and got: {outcome}')
  902. # Display the puzzle with correctly guessed letters
  903. puzzle_display = ' '.join(revealed_letters)
  904. await message.channel.send(f'Current Puzzle: {puzzle_display}')
  905. await message.channel.send(f"The current category is: {current_category}")
  906. guessed_letters_display = ', '.join(guessed_letters)
  907. await message.channel.send(f'Letters Already Guessed: {guessed_letters_display}')
  908. else:
  909. await message.channel.send("Sorry, I couldn't determine who spun the wheel.")
  910. players[current_player]['superspun'] = True # Mark that the command has been used in this game
  911. players[current_player]['spun'] = True # Mark that the player has spun
  912. # Handle other logic based on outcome
  913. if outcome.isdigit():
  914. await message.channel.send('Guess a letter using !guess or !solve to Solve.')
  915. guessed_correctly = False
  916. update_win_count(current_player) # Update win count
  917. else:
  918. # Inform the player that they don't have the proper win count
  919. await message.channel.send(
  920. "Sorry, you need to have a win count between 10 and 24 to use !superspin.")
  921. elif message.author == current_player and players[current_player]['spun']:
  922. # Check if the player needs to guess or solve
  923. if not guessed_correctly:
  924. await message.channel.send('Please guess a letter using !guess or solve the puzzle using !solve.')
  925. else:
  926. await message.channel.send('Please wait for your next turn.')
  927. elif message.author == current_player and players[current_player]['superspun']:
  928. # Inform the player that they have already used the !superspin command in this game
  929. await message.channel.send("Sorry, you can only use the !superspin command once per game.")
  930. else:
  931. await message.channel.send('You already super spun')
  932. else:
  933. await message.channel.send('An error occurred: Current player is None.')
  934.  
  935.  
  936.  
  937. elif message.content == '!ultraspin':
  938. # Read win counts from the file
  939. win_counts = {}
  940. with open('wincount.txt', 'r') as file:
  941. for line in file:
  942. # Split the line based on whitespace
  943. parts = line.strip().split()
  944. if len(parts) >= 2: # Ensure there are at least two parts
  945. user_id = parts[0]
  946. count = int(parts[1])
  947. win_counts[user_id] = count
  948. else:
  949. print(f"Ignoring invalid line in wincount.txt: {line.strip()}")
  950.  
  951. if current_player is None:
  952. await message.channel.send("Sorry, there's no current player.")
  953. return
  954.  
  955. if message.author == current_player and not players[current_player]['spun'] and not players[current_player][
  956. 'ultraspun']:
  957. # Check if the author's win count is within the required range
  958. author_id = str(message.author.id)
  959. if author_id in win_counts and 25 <= win_counts[author_id] <= 49: # Adjust range as needed
  960. outcome = random.choice(ULTRA_WHEEL_OUTCOMES)
  961. if message.author:
  962. await message.channel.send(f'{message.author.mention} spun the wheel and got: {outcome}')
  963. # Display the puzzle with correctly guessed letters
  964. puzzle_display = ' '.join(revealed_letters)
  965. await message.channel.send(f'Current Puzzle: {puzzle_display}')
  966. await message.channel.send(f"The current category is: {current_category}")
  967. guessed_letters_display = ', '.join(guessed_letters)
  968. await message.channel.send(f'Letters Already Guessed: {guessed_letters_display}')
  969. else:
  970. await message.channel.send("Sorry, I couldn't determine who spun the wheel.")
  971. players[current_player]['ultraspun'] = True
  972. players[current_player]['spun'] = True
  973. # Handle other logic based on outcome
  974. if outcome.isdigit():
  975. await message.channel.send('Guess a letter using !guess or !solve to Solve.')
  976. guessed_correctly = False
  977. try:
  978. msg = await bot.wait_for('message', timeout=30,
  979. check=lambda m: m.author == current_player
  980. and not guessed_correctly
  981. and (m.content.startswith(
  982. '!solve') or m.content.startswith('!guess')))
  983. if msg.content.startswith('!solve') or msg.content.startswith('!guess'):
  984. # Proceed with guessing or solving
  985. pass
  986. else:
  987. # Inform the player and allow the player to continue their turn
  988. await message.channel.send("Invalid command. Please use !guess or !solve to proceed.")
  989. except asyncio.TimeoutError:
  990. await message.channel.send("You took too long to guess or solve. It's now the next player's turn.")
  991. current_player = next_player()
  992. for player in players.keys():
  993. players[player]['spun'] = False
  994. if current_player is not None:
  995. await message.channel.send(f"It's {current_player.mention}'s turn to spin! use !spin")
  996. else:
  997. await message.channel.send("Sorry, you need to have a win count between 25 and 49 to use !ultraspin.")
  998. else:
  999. await message.channel.send('You already ultra spun')
  1000.  
  1001.  
  1002. elif message.content == '!megaspin':
  1003. # Read win counts from the file
  1004. win_counts = {}
  1005. with open('wincount.txt', 'r') as file:
  1006. for line in file:
  1007. # Split the line based on whitespace
  1008. parts = line.strip().split()
  1009. if len(parts) >= 2: # Ensure there are at least two parts
  1010. user_id = parts[0]
  1011. count = int(parts[1])
  1012. win_counts[user_id] = count
  1013. else:
  1014. print(f"Ignoring invalid line in wincount.txt: {line.strip()}")
  1015.  
  1016. if current_player is None:
  1017. await message.channel.send("Sorry, there's no current player.")
  1018. return
  1019.  
  1020. if message.author == current_player and not players[current_player]['spun'] and not players[current_player][
  1021. 'megaspun']:
  1022. # Check if the author's win count is above the threshold
  1023. author_id = str(message.author.id)
  1024. if author_id in win_counts and win_counts[author_id] >= 50: # Adjust threshold as needed
  1025. outcome = random.choice(MEGA_WHEEL_OUTCOMES)
  1026. if message.author:
  1027. await message.channel.send(f'{message.author.mention} spun the wheel and got: {outcome}')
  1028. # Display the puzzle with correctly guessed letters
  1029. puzzle_display = ' '.join(revealed_letters)
  1030. await message.channel.send(f'Current Puzzle: {puzzle_display}')
  1031. await message.channel.send(f"The current category is: {current_category}")
  1032. guessed_letters_display = ', '.join(guessed_letters)
  1033. await message.channel.send(f'Letters Already Guessed: {guessed_letters_display}')
  1034. else:
  1035. await message.channel.send("Sorry, I couldn't determine who spun the wheel.")
  1036. players[current_player]['megaspun'] = True
  1037. players[current_player]['spun'] = True
  1038. # Handle other logic based on outcome
  1039. if outcome.isdigit():
  1040. await message.channel.send('Guess a letter using !guess or !solve to Solve.')
  1041. guessed_correctly = False
  1042. try:
  1043. msg = await bot.wait_for('message', timeout=30,
  1044. check=lambda m: m.author == current_player
  1045. and not guessed_correctly
  1046. and (m.content.startswith(
  1047. '!solve') or m.content.startswith('!guess')))
  1048. if msg.content.startswith('!solve') or msg.content.startswith('!guess'):
  1049. # Proceed with guessing or solving
  1050. pass
  1051. else:
  1052. # Inform the player and allow the player to continue their turn
  1053. await message.channel.send("Invalid command. Please use !guess or !solve to proceed.")
  1054. except asyncio.TimeoutError:
  1055. await message.channel.send("You took too long to guess or solve. It's now the next player's turn.")
  1056. current_player = next_player()
  1057. for player in players.keys():
  1058. players[player]['spun'] = False
  1059. if current_player is not None:
  1060. await message.channel.send(f"It's {current_player.mention}'s turn to spin! use !spin")
  1061. else:
  1062. await message.channel.send("Sorry, you need to have a win count of 50 or more to use !megaspin.")
  1063. else:
  1064. await message.channel.send('You already mega spun')
  1065.  
  1066.  
  1067. elif message.content == '!guess':
  1068. # Handle letter guessing
  1069. if current_player and message.author == current_player and players[current_player][
  1070. 'spun'] and not guessed_correctly:
  1071. # Ask the player to guess a letter
  1072. await message.channel.send('Which letter would you like to guess?')
  1073.  
  1074. def check(m):
  1075. return m.author == current_player and len(m.content) == 1 and m.content.isalpha()
  1076.  
  1077. try:
  1078. # Wait for the player's response with a timeout of 30 seconds
  1079. guess_message = await bot.wait_for('message', check=check, timeout=60)
  1080. # Get the guessed letter from the message content
  1081. guessed_letter = guess_message.content.strip().lower()
  1082. # Check if the guessed letter has already been guessed
  1083. if guessed_letter in guessed_letters:
  1084. await message.channel.send('This letter has already been guessed! Skipping your turn.')
  1085. # Move on to the next player
  1086. current_player = next_player()
  1087. for player in players.keys():
  1088. players[player]['spun'] = False
  1089. if current_player is not None:
  1090. await message.channel.send(f'It\'s {current_player.mention}\'s turn to spin! use !spin')
  1091. return # Skip the rest of the handling for this guess
  1092. if guessed_letter not in guessed_letters:
  1093. guessed_letters.append(guessed_letter)
  1094. # Check if the guessed letter is in the puzzle
  1095. if guessed_letter in current_puzzle.lower():
  1096. for i, char in enumerate(current_puzzle):
  1097. if char.lower() == guessed_letter:
  1098. revealed_letters[i] = char
  1099.  
  1100. # Update the scoreboard with the points from the spin
  1101. if outcome.isdigit():
  1102. # Calculate points based on the occurrence of the guessed letter
  1103. if guessed_letter in current_puzzle.lower():
  1104. points = int(outcome)
  1105. scoreboard[current_player] += points
  1106. # Display the current scoreboard
  1107. await message.channel.send('Turn ended! Scores:')
  1108. for player, score in scoreboard.items():
  1109. await message.channel.send(f'{player.mention}: {score}')
  1110. # Check if all letters have been guessed correctly
  1111. guessed_correctly = all(char.isalpha() or char == ' ' for char in revealed_letters)
  1112. players[current_player]['spun'] = False
  1113. # If outcome was "Spin Again", prompt the player to spin again
  1114. if outcome == "Spin Again":
  1115. await message.channel.send('Use !spin to spin again.')
  1116. else:
  1117. # Remind the player to spin again
  1118. if current_player is not None:
  1119. await message.channel.send(
  1120. f'{current_player.mention}, it\'s your turn to spin again! use !spin')
  1121.  
  1122. # Display guessed letters
  1123. guessed_letters_display = ', '.join(guessed_letters)
  1124. await message.channel.send(f'Letters Already Guessed: {guessed_letters_display}')
  1125.  
  1126. else:
  1127. await message.channel.send('Sorry, the guessed letter is not in the puzzle.')
  1128. # Move on to the next player
  1129. current_player = next_player()
  1130. for player in players.keys():
  1131. players[player]['spun'] = False
  1132. if current_player is not None:
  1133. await message.channel.send(f'It\'s {current_player.mention}\'s turn to spin! use !spin')
  1134.  
  1135. # Check if all letters have been guessed correctly and prompt the player to solve the puzzle
  1136. if '-' not in revealed_letters:
  1137. await message.channel.send(
  1138. 'All letters have been guessed correctly! Use !spin then !solve to solve the puzzle.')
  1139.  
  1140. except asyncio.TimeoutError:
  1141. await message.channel.send('You took too long to guess.')
  1142. # Move on to the next player
  1143. current_player = next_player()
  1144. for player in players.keys():
  1145. players[player]['spun'] = False
  1146. if current_player is not None:
  1147. await message.channel.send(f'It\'s {current_player.mention}\'s turn to spin! use !spin')
  1148. else:
  1149. await message.channel.send('It\'s not your turn!')
  1150.  
  1151.  
  1152.  
  1153. elif message.content == '!solve':
  1154. # Handle solving the puzzle
  1155. # Handle solving the puzzle
  1156. if current_player and message.author == current_player and players[current_player]['spun']:
  1157. await message.channel.send('Type the puzzle to solve it.')
  1158.  
  1159. def check_solution(m):
  1160. return m.author == current_player
  1161.  
  1162. try:
  1163. # Wait for the player's response with a timeout of 90 seconds
  1164. solve_message = await bot.wait_for('message', check=check_solution, timeout=120)
  1165. # Check if the solution matches the current puzzle (case-insensitive comparison)
  1166. if solve_message.content.strip().lower() == current_puzzle.lower():
  1167. # Award the player their current wheel outcome
  1168. if outcome.isdigit():
  1169. points = int(outcome)
  1170. scoreboard[current_player] += points
  1171. await message.channel.send(
  1172. f'Congratulations! You solved the puzzle and earned {points} points!')
  1173. # Display the current scoreboard
  1174. await message.channel.send('Final Scores:')
  1175. for player, score in scoreboard.items():
  1176. await message.channel.send(f'{player.mention}: {score}')
  1177. await end_game(message.channel)
  1178. else:
  1179. await message.channel.send('You cannot earn points for a non-numeric wheel outcome.')
  1180. # Move on to the next player
  1181. current_player = next_player()
  1182. if current_player is not None:
  1183. await message.channel.send(f'It\'s {current_player.mention}\'s turn to spin! use !spin')
  1184. # Reset solve_attempted flag
  1185. solve_attempted = False
  1186. else:
  1187. await message.channel.send(
  1188. 'Sorry, that is not the correct solution. It\'s now the next player\'s turn.')
  1189. # Move on to the next player
  1190. current_player = next_player()
  1191. for player in players.keys():
  1192. players[player]['spun'] = False
  1193. if current_player is not None:
  1194. await message.channel.send(f'It\'s {current_player.mention}\'s turn to spin! use !spin')
  1195. solve_attempted = False # Reset the solve_attempted flag
  1196. except asyncio.TimeoutError:
  1197. await message.channel.send('You took too long to solve the puzzle.')
  1198. # Move on to the next player
  1199. current_player = next_player()
  1200. for player in players.keys():
  1201. players[player]['spun'] = False
  1202. if current_player is not None:
  1203. await message.channel.send(f'It\'s {current_player.mention}\'s turn to spin! use !spin')
  1204. elif current_player and message.author == current_player and not players[current_player]['spun']:
  1205. await message.channel.send('Please spin before solving.')
  1206. else:
  1207. await message.channel.send('It\'s not your turn!')
  1208.  
  1209. elif solve_attempted:
  1210. # Check if the solve_attempted flag is True
  1211. if current_player and message.author == current_player and players[current_player]['spun']:
  1212. # Skip the player's turn if they attempted to solve the puzzle but provided an incorrect solution
  1213. await message.channel.send('That is incorrect. It\'s now the next player\'s turn.')
  1214. current_player = next_player()
  1215. for player in players.keys():
  1216. players[player]['spun'] = False
  1217. if current_player is not None:
  1218. await message.channel.send(f'It\'s {current_player.mention}\'s turn to spin! use !spin')
  1219. solve_attempted = False # Reset the solve_attempted flag
  1220.  
  1221. # Handle the !reset command
  1222. elif message.content == '!reset':
  1223. # Check if the user who sent the command is authorized to reset the game
  1224. if message.author == game_initiator:
  1225. # Call the reset_game function to end the current game
  1226. reset_game()
  1227. await message.channel.send('Game reset! You can start a new game using !ssw.')
  1228. else:
  1229. await message.channel.send('You are not authorized to reset the game.')
  1230.  
  1231.  
  1232. # Function to update win count for a player
  1233. def update_win_count(player_id):
  1234. wincount_file = "wincount.txt"
  1235. if os.path.exists(wincount_file):
  1236. with open(wincount_file, "r") as file:
  1237. lines = file.readlines()
  1238. win_counts = {}
  1239. for line in lines:
  1240. parts = line.split()
  1241. if len(parts) >= 2:
  1242. player = parts[0]
  1243. wins = int(parts[1])
  1244. win_counts[player] = wins
  1245.  
  1246. if str(player_id) in win_counts:
  1247. win_counts[str(player_id)] += 1
  1248. else:
  1249. win_counts[str(player_id)] = 1
  1250.  
  1251. with open(wincount_file, "w") as file:
  1252. for player, wins in win_counts.items():
  1253. file.write(f"{player} {wins}\n")
  1254.  
  1255.  
  1256. def read_win_counts():
  1257. win_counts = {}
  1258. with open('wincount.txt', 'r') as file:
  1259. for line in file:
  1260. player_id, win_count = line.strip().split()
  1261. win_counts[player_id] = int(win_count)
  1262. return win_counts
  1263.  
  1264.  
  1265. # Function to end the game
  1266. async def end_game(channel):
  1267. global game_created, game_started, current_player, current_puzzle, revealed_letters, scoreboard, \
  1268. guessed_correctly, outcome, solve_attempted, game_initiator, current_category
  1269.  
  1270. # Determine the winner based on the scores
  1271. winner = max(scoreboard, key=scoreboard.get) if scoreboard else None
  1272.  
  1273. # Display the winner if there is one
  1274. if winner:
  1275. # Update win count
  1276. update_win_count(winner.id) # Assuming winner is a Discord Member object
  1277. # Read win count from file
  1278. with open("wincount.txt", "r") as file:
  1279. win_counts = {line.split()[0]: int(line.split()[1]) for line in file.readlines()}
  1280. # Display the winner and their win count
  1281. await channel.send(
  1282. f'Congratulations to {winner.mention} for winning with a score of {scoreboard[winner]} points! ')
  1283. await channel.send(f'Total win count: {win_counts.get(str(winner.id), 0)}')
  1284. else:
  1285. await channel.send('Thank you for playing!')
  1286.  
  1287. # Reset game state
  1288. game_created = False
  1289. game_started = False
  1290. current_player = None
  1291. current_puzzle = ""
  1292. revealed_letters = []
  1293. scoreboard = {}
  1294. guessed_correctly = False
  1295. outcome = None
  1296. solve_attempted = False
  1297. game_initiator = None
  1298. current_category = None
  1299.  
  1300.  
  1301. # Function to switch to the next player
  1302. def next_player():
  1303. global players, current_player
  1304. if current_player is not None:
  1305. players_list = list(players.keys())
  1306. current_index = players_list.index(current_player)
  1307. next_index = (current_index + 1) % len(players_list)
  1308. return players_list[next_index]
  1309. else:
  1310. return None
  1311.  
  1312.  
  1313. # Run the bot
  1314. bot.run('')
Add Comment
Please, Sign In to add comment