From d71dd304fd7d835346656f428ca9914066d35d0f Mon Sep 17 00:00:00 2001 From: alogindtractor <251821224+A-Log-In-D-Tractor@users.noreply.github.com> Date: Tue, 10 Feb 2026 06:40:43 -0800 Subject: [PATCH] update mines (#77) * Update MinesCommand.cs better cashout handling? also limit mines to 8 * Update KasinoMines.cs update cashout to have a delay before removing board message and add auto delete * update cashout calculation update cashout calculation fair payout but house edge based chance for rigging --- KfChatDotNetBot/Commands/Kasino/MinesCommand.cs | 11 +++++++++-- KfChatDotNetBot/Services/KasinoMines.cs | 14 ++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/KfChatDotNetBot/Commands/Kasino/MinesCommand.cs b/KfChatDotNetBot/Commands/Kasino/MinesCommand.cs index e251802..23c0fdd 100644 --- a/KfChatDotNetBot/Commands/Kasino/MinesCommand.cs +++ b/KfChatDotNetBot/Commands/Kasino/MinesCommand.cs @@ -13,7 +13,7 @@ public class MinesCommand : ICommand { public List Patterns => [ //cashout - new Regex(@"^mines\s+cashout$", RegexOptions.IgnoreCase), + new Regex(@"^mines\s+(?cashout)$", RegexOptions.IgnoreCase), //refresh new Regex(@"^mines\s+refresh$", RegexOptions.IgnoreCase), //clear - admin only @@ -72,8 +72,13 @@ public class MinesCommand : ICommand if (user.UserRight >= UserRight.TrueAndHonest) { await KasinoMines.GetSavedGames(gambler.Id); + foreach (var game in KasinoMines.ActiveGames.Values) + { + await botInstance.KfClient.DeleteMessageAsync(game.LastMessageId); + } KasinoMines.ActiveGames.Clear(); await KasinoMines.SaveActiveGames(gambler.Id); + await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, cleared all mines games.", true, autoDeleteAfter: cleanupDelay); return; } await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, you don't have permission to clear saved games.", true, autoDeleteAfter: cleanupDelay); @@ -174,7 +179,7 @@ public class MinesCommand : ICommand return; } int boardSize = Convert.ToInt32(size.Value); - if (boardSize < 2 || boardSize > 9) + if (boardSize < 2 || boardSize > 8) { await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, board size must be between 2 and 9.",true, autoDeleteAfter: cleanupDelay); return; @@ -244,6 +249,7 @@ public class MinesCommand : ICommand } else //if they didn't put anything { + if (message.Message.Contains("cashout")) cashout = true; if (cashout) { await KasinoMines.Cashout(KasinoMines.ActiveGames[gambler.Id]); @@ -252,6 +258,7 @@ public class MinesCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, you already have a game running. !mines to reveal more spaces, !mines cashout to cash out, !mines to place precise picks. Tool: {ToolUrl}", true, autoDeleteAfter: cleanupDelay); + return; } diff --git a/KfChatDotNetBot/Services/KasinoMines.cs b/KfChatDotNetBot/Services/KasinoMines.cs index 90bfbb5..257cf4c 100644 --- a/KfChatDotNetBot/Services/KasinoMines.cs +++ b/KfChatDotNetBot/Services/KasinoMines.cs @@ -294,7 +294,7 @@ public class KasinoMines { await GetSavedGames(gamblerId); //attempt to delete the message if its there - if (ActiveGames[gamblerId].LastMessageId != 0) _kfChatBot.KfClient.DeleteMessage(ActiveGames[gamblerId].LastMessageId); + if (ActiveGames[gamblerId].LastMessageId != 0) await _kfChatBot.KfClient.DeleteMessageAsync(ActiveGames[gamblerId].LastMessageId); ActiveGames?.Remove(gamblerId); await SaveActiveGames(gamblerId); } @@ -302,17 +302,19 @@ public class KasinoMines public async Task Cashout(KasinoMinesGame game) { decimal payout = 0; - decimal numGems = game.Size * game.Size - game.Mines; + decimal mines = game.Mines; + decimal size2 = game.Size * game.Size; + decimal gems = size2 - mines; for (int i = 0; i < game.BetsPlaced.Count; i++) { - payout += game.Wager * (game.Size * game.Size / numGems); - numGems--; + payout += game.Wager * ((size2 - i) / gems); } var newBalance = await Money.NewWagerAsync(game.Creator.Id, game.Wager, payout, WagerGame.Mines); var net = payout - game.Wager; await _kfChatBot.SendChatMessageAsync( - $"{game.Creator.User.FormatUsername()}, you won {await payout.FormatKasinoCurrencyAsync()} from your {await game.Wager.FormatKasinoCurrencyAsync()} bet on mines, collecting {game.BetsPlaced.Count} gems while avoiding {game.Mines} mines. Net: {await net.FormatKasinoCurrencyAsync()}. Balance: {await newBalance.FormatKasinoCurrencyAsync()}"); + $"{game.Creator.User.FormatUsername()}, you won {await payout.FormatKasinoCurrencyAsync()} from your {await game.Wager.FormatKasinoCurrencyAsync()} bet on mines, collecting {game.BetsPlaced.Count} gems while avoiding {game.Mines} mines. Net: {await net.FormatKasinoCurrencyAsync()}. Balance: {await newBalance.FormatKasinoCurrencyAsync()}", true, autoDeleteAfter: TimeSpan.FromSeconds(15)); + await Task.Delay(TimeSpan.FromSeconds(15)); await RemoveGame(game.Creator.Id); } @@ -413,7 +415,7 @@ public class KasinoMines { await _kfChatBot.KfClient.EditMessageAsync(invalidBetMsg.ChatMessageId!.Value, $"{game.Creator.User.FormatUsername()}, invalid bet of {bet.r},{bet.c} removed (already placed, duplicate, or invalid coordinate)"); - await Task.Delay(3); + await Task.Delay(5); } else bets.Add(bet); }