From 6f6359b6daf0c5bcf49fbf63c95d17c132b77ef2 Mon Sep 17 00:00:00 2001 From: alogindtractor <251821224+A-Log-In-D-Tractor@users.noreply.github.com> Date: Wed, 7 Jan 2026 18:19:57 -0800 Subject: [PATCH] plinko update, minor blackjack update (#29) * 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 --- .../Commands/Kasino/BlackjackCommand.cs | 4 +-- .../Commands/Kasino/PlinkoCommand.cs | 34 +++++++++++++------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/KfChatDotNetBot/Commands/Kasino/BlackjackCommand.cs b/KfChatDotNetBot/Commands/Kasino/BlackjackCommand.cs index c7dfea0..62e684e 100644 --- a/KfChatDotNetBot/Commands/Kasino/BlackjackCommand.cs +++ b/KfChatDotNetBot/Commands/Kasino/BlackjackCommand.cs @@ -619,7 +619,7 @@ public class BlackjackCommand : ICommand var newBalance = await Money.ModifyBalanceAsync(gambler.Id, balanceAdjustment, TransactionSourceEventType.Gambling, $"Blackjack outcome from wager {wager.Id}", null, ctx); - message += $"[B]Net:[/B] {(totalEffect >= 0 ? "+" : "")}{await totalEffect.FormatKasinoCurrencyAsync()} | Balance: {await newBalance.FormatKasinoCurrencyAsync()}"; + message += $"[u][B]Net:[/B] {(totalEffect >= 0 ? "+" : "")}{await totalEffect.FormatKasinoCurrencyAsync()} | Balance: {await newBalance.FormatKasinoCurrencyAsync()}"; await botInstance.SendChatMessageAsync(message, true, autoDeleteAfter: cleanupDelay); } @@ -634,4 +634,4 @@ public class BlackjackCommand : ICommand $"{user.FormatUsername()}, your blackjack game timed out and you forfeited {await wager.WagerAmount.FormatKasinoCurrencyAsync()}", true, autoDeleteAfter: cleanupDelay); } -} \ No newline at end of file +} diff --git a/KfChatDotNetBot/Commands/Kasino/PlinkoCommand.cs b/KfChatDotNetBot/Commands/Kasino/PlinkoCommand.cs index fce9c70..17e6e85 100644 --- a/KfChatDotNetBot/Commands/Kasino/PlinkoCommand.cs +++ b/KfChatDotNetBot/Commands/Kasino/PlinkoCommand.cs @@ -49,7 +49,6 @@ public class PlinkoCommand : ICommand { decimal payout = 0; decimal currentPayout = 0; - Group? number; var settings = await SettingsProvider.GetMultipleValuesAsync([ BuiltIn.Keys.KasinoPlinkoCleanupDelay, BuiltIn.Keys.KiwiFarmsGreenColor, BuiltIn.Keys.KiwiFarmsRedColor ]); @@ -64,11 +63,19 @@ public class PlinkoCommand : ICommand var gambler = await Money.GetGamblerEntityAsync(user.Id, ct: ctx); if (gambler == null) throw new InvalidOperationException($"Caught a null when retrieving gambler for {user.KfUsername}"); - if (!arguments.TryGetValue("number", out number)) + int numberOfBalls = 0; + if (!arguments.TryGetValue("number", out var number)) { - number = null; + numberOfBalls = 1; + } + else numberOfBalls = Convert.ToInt32(number.Value); + + if (numberOfBalls < 1 || numberOfBalls > 10) + { + await botInstance.SendChatMessageAsync( + $"{user.FormatUsername()}, you can only play with 1 - 10 balls at a time", true, autoDeleteAfter: cleanupDelay); + return; } - int numberOfBalls = number == null ? 1 : Convert.ToInt32(number.Value); if (gambler.Balance < wager * numberOfBalls) { await botInstance.SendChatMessageAsync( @@ -84,7 +91,7 @@ public class PlinkoCommand : ICommand ballsNotInPlay.Add(new PlinkoBall()); } //game starts here - int breakCounter = 0 + int breakCounter = 0; var plinkoMessageID = await botInstance.SendChatMessageAsync(PlinkoBoardDisplay(ballsInPlay), true, autoDeleteAfter: cleanupDelay); while (plinkoMessageID.ChatMessageId == null && breakCounter < 1000) { await Task.Delay(100); @@ -99,8 +106,11 @@ public class PlinkoCommand : ICommand breakCounter++; if (breakCounter >= 1000) throw new Exception("stuck in while loop in plinko"); currentPayout = 0; - ballsInPlay.Add(ballsNotInPlay[0]); - ballsNotInPlay.RemoveAt(0); + if (ballsNotInPlay.Count > 0) + { + ballsInPlay.Add(ballsNotInPlay[0]); + ballsNotInPlay.RemoveAt(0); + } await botInstance.KfClient.EditMessageAsync(plinkoMessageID.ChatMessageId!.Value,PlinkoBoardDisplay(ballsInPlay)); if (ballsInPlay[0].POSITION.row == DIFFICULTY - 1) //once your ball has reached the bottom calculate the payout { @@ -109,12 +119,12 @@ public class PlinkoCommand : ICommand if (currentPayout > wager) { await botInstance.SendChatMessageAsync( - $"{user.FormatUsername()}, you [color={settings[BuiltIn.Keys.KiwiFarmsGreenColor].Value!}]win![/color]. Payout: {currentPayout} KKK", true, autoDeleteAfter: TimeSpan.FromSeconds(5)); + $"{user.FormatUsername()}, you [color={settings[BuiltIn.Keys.KiwiFarmsGreenColor].Value!}]won[/color] ${currentPayout} KKK from a plinko ball worth {wager}!", true, autoDeleteAfter: TimeSpan.FromSeconds(5)); } else { await botInstance.SendChatMessageAsync( - $"{user.FormatUsername()}, you [color={settings[BuiltIn.Keys.KiwiFarmsRedColor].Value!}lose. Payout: {currentPayout} KKK", true, autoDeleteAfter: TimeSpan.FromSeconds(5)); + $"{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)); } } foreach (var ball in ballsInPlay) @@ -123,10 +133,12 @@ public class PlinkoCommand : ICommand } await Task.Delay(100); + await botInstance.KfClient.EditMessageAsync(plinkoMessageID.ChatMessageId!.Value,PlinkoBoardDisplay(ballsInPlay)); + await Task.Delay(100); } var newBalance = await Money.NewWagerAsync(gambler.Id, wager*numberOfBalls, payout, WagerGame.Plinko, ct: ctx); - await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, you won ${payout} KKK from {numberOfBalls} plinko balls worth ${wager} KKK. Balance: ${newBalance} KKK", true, autoDeleteAfter: cleanupDelay); + await botInstance.SendChatMessageAsync($"[u]{user.FormatUsername()}, you won ${payout} KKK from {numberOfBalls} plinko balls worth ${wager} KKK. Balance: ${newBalance} KKK", true, autoDeleteAfter: cleanupDelay); } @@ -173,6 +185,8 @@ public class PlinkoCommand : ICommand if (!spaceIsValid) board += NULLSPACE; } + + board += "[br]"; } return board;