From 73f933db4a6096a0e8cb7cb7b3b787320fde6bb0 Mon Sep 17 00:00:00 2001 From: alogindtractor <251821224+A-Log-In-D-Tractor@users.noreply.github.com> Date: Wed, 7 Jan 2026 20:27:01 -0800 Subject: [PATCH] plinko fix frfrfr (#32) * Update cleanup delay settings for PlinkoCommand, use plinko delay instead of limbo Update cleanup delay settings for PlinkoCommand, use plinko delay instead of limbo * wait for chat message id update wait for chat message id update * update plinko to fix shit update plinko to fix shit * add underline to final blackjack message add underline to final blackjack message to make it easier to read which game is which when many games are happening at once * plinko fix frfr this time plinko fix frfr this time * settings fix as requested settings fix as requested * plinko payout fix? not exactly sure why its not correct this should maybe fix it? * Add logger for max win in PlinkoCommand Added logging for maximum win condition in Plinko game. * fix loop and other bugs fix loop and other bugs --- .../Commands/Kasino/PlinkoCommand.cs | 43 +++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/KfChatDotNetBot/Commands/Kasino/PlinkoCommand.cs b/KfChatDotNetBot/Commands/Kasino/PlinkoCommand.cs index c33d48c..3a0fb1f 100644 --- a/KfChatDotNetBot/Commands/Kasino/PlinkoCommand.cs +++ b/KfChatDotNetBot/Commands/Kasino/PlinkoCommand.cs @@ -47,7 +47,16 @@ public class PlinkoCommand : ICommand {6, 25}, }; - + private static readonly List<(int row, int col)> validPositions = new() //would need to come up with a formula to make this to have user defined difficulty, good luck + { + (0, 3), + (1, 2), (1, 4), + (2, 2), (2, 3), (2, 4), + (3, 1),(3, 2), (3, 4), (3, 5), + (4, 1),(4, 2), (4, 3), (4, 4), (4, 5), + (5, 0), (5, 1),(5, 2), (5, 4), (5, 5), (5, 6), + (6, 0), (6, 1),(6, 2), (6, 3), (6, 4), (6, 5), (6, 6) + }; public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx) @@ -120,7 +129,7 @@ public class PlinkoCommand : ICommand while (ballsNotInPlay.Count > 0 || ballsInPlay.Count > 0) { breakCounter++; - if (breakCounter >= 1000) throw new Exception("stuck in while loop in plinko"); + if (breakCounter >= numberOfBalls * 10) throw new Exception("stuck in while loop in plinko"); currentPayout = 0; if (ballsNotInPlay.Count > 0) { @@ -143,6 +152,7 @@ public class PlinkoCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, you [color={settings[BuiltIn.Keys.KiwiFarmsRedColor].Value!}lost[/color] ${wager-currentPayout} KKK from a plinko ball worth {wager}.", true, autoDeleteAfter: TimeSpan.FromSeconds(5)); } + ballsInPlay.RemoveAt(0); } foreach (var ball in ballsInPlay) { @@ -164,16 +174,7 @@ public class PlinkoCommand : ICommand string board = ""; bool spaceIsBall = false; bool spaceIsValid = false; - List<(int row, int col)> validPositions = new() //would need to come up with a formula to make this to have user defined difficulty, good luck - { - (0, 3), - (1, 2), (1, 4), - (2, 2), (2, 3), (2, 4), - (3, 1), (3,2), (3, 4), (3, 5), - (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), - (5, 0), (5, 1), (5, 2), (5, 4), (5, 5), (5, 6), - (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6,6) - }; + for (int row = 0; row < DIFFICULTY; row++) { for (int col = 0; col < DIFFICULTY; col++) @@ -212,10 +213,18 @@ public class PlinkoCommand : ICommand { private RandomShim RAND = RandomShim.Create(StandardRng.Create()); public (int row, int col) POSITION; - + private Dictionary> validColumnsForRow; public PlinkoBall() { POSITION = (0, 3); + validColumnsForRow = new Dictionary>(); + foreach (var position in validPositions){ + if (!validColumnsForRow.ContainsKey(position.row)) validColumnsForRow.Add(position.row, new List() + { + position.col + }); //if no current key for that row add it + else validColumnsForRow[position.row].Add(position.col); + } } public void Iterate() { @@ -232,12 +241,11 @@ public class PlinkoCommand : ICommand switch (rng) { case >= 0.5: - if (!evenrow && Math.Abs(POSITION.col) > POSITION.row / 2) POSITION.col--; - else if (evenrow) POSITION.col--; + if (validColumnsForRow[POSITION.row+1].Contains(POSITION.col-1)) POSITION.col--; break; + case < 0.5: - if (!evenrow && POSITION.col > POSITION.row / 2) POSITION.col++; - else if (evenrow) POSITION.col++; + if (validColumnsForRow[POSITION.row+1].Contains(POSITION.col+1)) POSITION.col++; break; default: throw new Exception("generated an incorrect number"); @@ -249,4 +257,3 @@ public class PlinkoCommand : ICommand } -