Untitled
using System; using System.Linq; using System.Collections.Generic; public class CPHInline { public bool Execute() { var user = args["userName"].ToString(); var upoints = CPH.GetTwitchUserVar<int>(user, "points", true); int betAmount; // Determine bet amount if (string.IsNullOrWhiteSpace(args["rawInput"].ToString())) { betAmount = Convert.ToInt32(args["defaultBet"].ToString()); } else if (args["rawInput"].ToString().ToUpper() == "ALL") { betAmount = upoints; // Set bet amount to all user's points } else if (args["rawInput"].ToString().ToUpper() == "HALF") { betAmount = upoints / 2; // Set bet amount to half of user's points } else { betAmount = Convert.ToInt32(args["rawInput"].ToString()); } // Check for invalid bets if (betAmount <= 0) { if (upoints == 0) { CPH.SendAction($"{user}, you do not have enough points to gamble."); } else { CPH.SendAction($"{user}, stop trolling! You cannot bet zero or negative points."); } return false; } // Check user points if (upoints < betAmount) { CPH.SendAction($"{user}, you do not have enough points to make that bet!"); return false; } CPH.SetGlobalVar("bettedpoint", betAmount, true); // Dynamic slot list and weights var slotList = CPH.GetGlobalVar<List<string>>("slotlist", true); // Dynamic emote list var emoteWeights = CPH.GetGlobalVar<Dictionary<string, double>>("emoteWeights", true); // Dynamic weights for emotes int maxEmotes = Convert.ToInt32(args["numOfEmotes"].ToString()); // Get the number of emotes to use maxEmotes = Math.Min(maxEmotes, slotList.Count); // Limit to the size of the slotList Random rng = new Random(); // Generate four random slots from the allowed number of emotes int slotA = rng.Next(0, maxEmotes); int slotB = rng.Next(0, maxEmotes); int slotC = rng.Next(0, maxEmotes); int slotD = rng.Next(0, maxEmotes); // Display slots result in chat CPH.SendMessage($"|| {slotList[slotA]} || {slotList[slotB]} || {slotList[slotC]} || {slotList[slotD]} ||"); // Get weights for the emotes in the slots double weightA = emoteWeights[slotList[slotA]]; double weightB = emoteWeights[slotList[slotB]]; double weightC = emoteWeights[slotList[slotC]]; double weightD = emoteWeights[slotList[slotD]]; double averageWeight = (weightA + weightB + weightC + weightD) / 4; // Average weight for the slots // Hardcoded Jackpot Multiplier (300% to 500%) int jackpotMultiplier = rng.Next(300, 501); // Jackpot logic (all four emotes must match) if (slotA == slotB && slotB == slotC && slotC == slotD) { var pname = CPH.GetGlobalVar<string>("pointsname", true); int jackpotWin = (int)(betAmount * (jackpotMultiplier / 100.0) * averageWeight); // Jackpot with weight int newpoints = upoints + jackpotWin; // Update points and notify jackpot win CPH.SetTwitchUserVar(user, "points", newpoints, true); CPH.SendAction($"@{user} you gambled {betAmount} {pname} on the slots and hit the JACKPOT, winning {jackpotWin}! You now have {newpoints} {pname}! Kreygasm"); return true; } // Hardcoded Partial Win Multiplier (50% to 150%) int partialWinMultiplier = rng.Next(50, 151); // Partial win logic (at least two matching emotes) int matchingSlots = 0; if (slotA == slotB) matchingSlots++; if (slotA == slotC) matchingSlots++; if (slotA == slotD) matchingSlots++; if (slotB == slotC) matchingSlots++; if (slotB == slotD) matchingSlots++; if (slotC == slotD) matchingSlots++; if (matchingSlots >= 2) // Partial win if at least 2 pairs match { var pname = CPH.GetGlobalVar<string>("pointsname", true); int partialWinBonus = (int)(betAmount * (partialWinMultiplier / 100.0) * averageWeight); // Partial win with weight int partialWinTotal = betAmount + partialWinBonus; // Total win = bet + bonus int newpoints = upoints + partialWinBonus; // Update total points with the bonus // Update points and notify partial win CPH.SetTwitchUserVar(user, "points", newpoints, true); CPH.SendAction($"@{user} you gambled {betAmount} {pname} on the slots and WON a partial prize of {partialWinTotal}! You now have {newpoints} {pname}! PogChamp"); return true; } // Loss logic (no matching emotes) int newpointsOnLoss = upoints - betAmount; // Update points and notify loss var pnameLoss = CPH.GetGlobalVar<string>("pointsname", true); CPH.SetTwitchUserVar(user, "points", newpointsOnLoss, true); CPH.SendAction($"@{user} you gambled {betAmount} {pnameLoss} on the slots and LOST {betAmount}! You now have {newpointsOnLoss} {pnameLoss}! NotLikeThis"); return true; } }
Leave a Comment