mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-05-15 10:32:44 -04:00
Fixed compiler warnings
This commit is contained in:
@@ -31,8 +31,8 @@ public class KenoCommand : ICommand
|
|||||||
Window = TimeSpan.FromSeconds(10)
|
Window = TimeSpan.FromSeconds(10)
|
||||||
};
|
};
|
||||||
|
|
||||||
private List<int> playerNumbers;
|
private List<int> _playerNumbers = [];
|
||||||
private List<int> casinoNumbers;
|
private List<int> _casinoNumbers = [];
|
||||||
private decimal HOUSE_EDGE = (decimal)0.98;
|
private decimal HOUSE_EDGE = (decimal)0.98;
|
||||||
private const string PlayerNumberDisplay = "⬜";
|
private const string PlayerNumberDisplay = "⬜";
|
||||||
private const string CasinoNumberDisplay = "🔶";
|
private const string CasinoNumberDisplay = "🔶";
|
||||||
@@ -165,12 +165,12 @@ public class KenoCommand : ICommand
|
|||||||
{ "classic", payoutMultipliersClassic}
|
{ "classic", payoutMultipliersClassic}
|
||||||
};
|
};
|
||||||
|
|
||||||
playerNumbers = GenerateKenoNumbers(numbers, gambler);
|
_playerNumbers = GenerateKenoNumbers(numbers, gambler);
|
||||||
casinoNumbers = GenerateKenoNumbers(10, gambler, true);
|
_casinoNumbers = GenerateKenoNumbers(10, gambler, true);
|
||||||
var matches = playerNumbers.Intersect(casinoNumbers).ToList();
|
var matches = _playerNumbers.Intersect(_casinoNumbers).ToList();
|
||||||
var payoutMulti = payoutMultipliers[difficultyString][numbers - 1, matches.Count];
|
var payoutMulti = payoutMultipliers[difficultyString][numbers - 1, matches.Count];
|
||||||
|
|
||||||
await AnimatedDisplayTable(playerNumbers, casinoNumbers, matches, botInstance);
|
await AnimatedDisplayTable(_playerNumbers, _casinoNumbers, matches, botInstance);
|
||||||
var colors =
|
var colors =
|
||||||
await SettingsProvider.GetMultipleValuesAsync([
|
await SettingsProvider.GetMultipleValuesAsync([
|
||||||
BuiltIn.Keys.KiwiFarmsGreenColor, BuiltIn.Keys.KiwiFarmsRedColor
|
BuiltIn.Keys.KiwiFarmsGreenColor, BuiltIn.Keys.KiwiFarmsRedColor
|
||||||
@@ -281,7 +281,7 @@ public class KenoCommand : ICommand
|
|||||||
var randomNum = Money.GetRandomNumber(gambler, 1, 40);
|
var randomNum = Money.GetRandomNumber(gambler, 1, 40);
|
||||||
if (numbers.Contains(randomNum)) continue;
|
if (numbers.Contains(randomNum)) continue;
|
||||||
if (kasino && Money.GetRandomDouble(gambler) > (double)HOUSE_EDGE &&
|
if (kasino && Money.GetRandomDouble(gambler) > (double)HOUSE_EDGE &&
|
||||||
playerNumbers.Contains(randomNum)) continue; //rigging function
|
_playerNumbers.Contains(randomNum)) continue; //rigging function
|
||||||
numbers.Add(randomNum);
|
numbers.Add(randomNum);
|
||||||
repeatNum = false;
|
repeatNum = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -448,7 +448,6 @@ public class SlotsCommand : ICommand
|
|||||||
for (var i = 0; i < 5; i++) {
|
for (var i = 0; i < 5; i++) {
|
||||||
for (var j = 0; j < 5; j++)
|
for (var j = 0; j < 5; j++)
|
||||||
{
|
{
|
||||||
int loopCounter = 0;
|
|
||||||
var r = _rand.NextDouble() * 100.6;
|
var r = _rand.NextDouble() * 100.6;
|
||||||
if (f != 0 && j > 2) r *= 1.1;
|
if (f != 0 && j > 2) r *= 1.1;
|
||||||
if (rigged == 'L') r = _rand.NextDouble() * 97.01;
|
if (rigged == 'L') r = _rand.NextDouble() * 97.01;
|
||||||
@@ -601,13 +600,11 @@ public class SlotsCommand : ICommand
|
|||||||
{
|
{
|
||||||
int totalRuns = 0;
|
int totalRuns = 0;
|
||||||
double r;
|
double r;
|
||||||
List<(int r, int c)> positionsToCheck;
|
|
||||||
for (int row = 0; row < 5; row++)
|
for (int row = 0; row < 5; row++)
|
||||||
{
|
{
|
||||||
for (int col = 0; col < 5; col++)
|
for (int col = 0; col < 5; col++)
|
||||||
{
|
{
|
||||||
int loopCounter = 0;
|
int loopCounter = 0;
|
||||||
if (row == 0 && col == 0) ; //do nothing
|
|
||||||
if (row == 0 && col == 1)
|
if (row == 0 && col == 1)
|
||||||
{
|
{
|
||||||
//check 1 slot behind
|
//check 1 slot behind
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ public class KasinoMines
|
|||||||
{
|
{
|
||||||
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
||||||
private IDatabase? _redisDb;
|
private IDatabase? _redisDb;
|
||||||
private static ChatBot _kfChatBot;
|
private static ChatBot _kfChatBot = null!;
|
||||||
public Dictionary<int, KasinoMinesGame>? ActiveGames;
|
public Dictionary<int, KasinoMinesGame> ActiveGames = new();
|
||||||
private decimal HOUSE_EDGE = (decimal)0.98; //used to rig win rate, payout is 100% fair. with shop i plan to implement a sort of kasino shop profile holding the investments and buffs and tracking the gamblers current house edge
|
private decimal HOUSE_EDGE = (decimal)0.98; //used to rig win rate, payout is 100% fair. with shop i plan to implement a sort of kasino shop profile holding the investments and buffs and tracking the gamblers current house edge
|
||||||
public class KasinoMinesGame
|
public class KasinoMinesGame
|
||||||
{
|
{
|
||||||
@@ -26,22 +26,23 @@ public class KasinoMines
|
|||||||
public int Size { get; set; }
|
public int Size { get; set; }
|
||||||
public int Mines { get; set; }
|
public int Mines { get; set; }
|
||||||
public List<(int r, int c)> BetsPlaced = new();
|
public List<(int r, int c)> BetsPlaced = new();
|
||||||
public SentMessageTrackerModel? LastMessage;
|
public int LastMessageId;
|
||||||
|
|
||||||
|
|
||||||
public KasinoMinesGame(GamblerDbModel creator, decimal wager, int size, int mines)
|
public KasinoMinesGame(GamblerDbModel creator, decimal wager, int size, int mines)
|
||||||
{
|
{
|
||||||
this.Creator = creator;
|
Creator = creator;
|
||||||
this.Size = size;
|
Size = size;
|
||||||
this.Mines = mines;
|
Mines = mines;
|
||||||
this.Wager = wager;
|
Wager = wager;
|
||||||
MinesBoard = CreateBoard();
|
MinesBoard = CreateBoard();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task ResetMessage(SentMessageTrackerModel msg)
|
public async Task ResetMessage(SentMessageTrackerModel msg)
|
||||||
{
|
{
|
||||||
await _kfChatBot.KfClient.DeleteMessageAsync(LastMessage.ChatMessageId.Value);
|
await _kfChatBot.KfClient.DeleteMessageAsync(LastMessageId);
|
||||||
LastMessage = msg;
|
if (msg.ChatMessageId == null) throw new InvalidOperationException($"ChatMessageId was null for {msg.Reference}");
|
||||||
|
LastMessageId = msg.ChatMessageId.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task RigBoard((int r, int c) coord) //moves one of the mines to a specified coordinate for house edge rigging
|
public async Task RigBoard((int r, int c) coord) //moves one of the mines to a specified coordinate for house edge rigging
|
||||||
@@ -67,7 +68,7 @@ public class KasinoMines
|
|||||||
}
|
}
|
||||||
public async Task Explode((int r, int c) mineLocation, SentMessageTrackerModel msg)
|
public async Task Explode((int r, int c) mineLocation, SentMessageTrackerModel msg)
|
||||||
{
|
{
|
||||||
if (LastMessage != msg)
|
if (LastMessageId != msg.ChatMessageId)
|
||||||
{
|
{
|
||||||
await ResetMessage(msg);
|
await ResetMessage(msg);
|
||||||
}
|
}
|
||||||
@@ -127,11 +128,11 @@ public class KasinoMines
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await _kfChatBot.KfClient.EditMessageAsync(msg.ChatMessageId.Value, $"{str}[br]{Creator.User.FormatUsername()}");
|
await _kfChatBot.KfClient.EditMessageAsync(msg.ChatMessageId!.Value, $"{str}[br]{Creator.User.FormatUsername()}");
|
||||||
}
|
}
|
||||||
|
|
||||||
await Task.Delay(TimeSpan.FromSeconds(10));
|
await Task.Delay(TimeSpan.FromSeconds(10));
|
||||||
await _kfChatBot.KfClient.DeleteMessageAsync(msg.ChatMessageId.Value);
|
await _kfChatBot.KfClient.DeleteMessageAsync(msg.ChatMessageId!.Value);
|
||||||
|
|
||||||
(int vertical, int horizontal) DistanceFromMine((int r, int c) coord)
|
(int vertical, int horizontal) DistanceFromMine((int r, int c) coord)
|
||||||
{
|
{
|
||||||
@@ -139,7 +140,7 @@ public class KasinoMines
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ToString()
|
public new string ToString()
|
||||||
{
|
{
|
||||||
string value = "";
|
string value = "";
|
||||||
bool revealedSpace;
|
bool revealedSpace;
|
||||||
@@ -232,6 +233,7 @@ public class KasinoMines
|
|||||||
var game = ActiveGames[gamblerId];
|
var game = ActiveGames[gamblerId];
|
||||||
game.LastInteracted = DateTimeOffset.UtcNow;
|
game.LastInteracted = DateTimeOffset.UtcNow;
|
||||||
var msg = await _kfChatBot.SendChatMessageAsync($"{game.ToString()}", true);
|
var msg = await _kfChatBot.SendChatMessageAsync($"{game.ToString()}", true);
|
||||||
|
await _kfChatBot.WaitForChatMessageAsync(msg);
|
||||||
await game.ResetMessage(msg);
|
await game.ResetMessage(msg);
|
||||||
ActiveGames[gamblerId] = game;
|
ActiveGames[gamblerId] = game;
|
||||||
await SaveActiveGames();
|
await SaveActiveGames();
|
||||||
@@ -242,9 +244,14 @@ public class KasinoMines
|
|||||||
if (_redisDb == null) throw new InvalidOperationException("Kasino mines service isn't initialized");
|
if (_redisDb == null) throw new InvalidOperationException("Kasino mines service isn't initialized");
|
||||||
var json = await _redisDb.StringGetAsync("Mines.State");
|
var json = await _redisDb.StringGetAsync("Mines.State");
|
||||||
if (string.IsNullOrEmpty(json)) return;
|
if (string.IsNullOrEmpty(json)) return;
|
||||||
ActiveGames = JsonSerializer.Deserialize<Dictionary<int, KasinoMinesGame>>(json.ToString());
|
try
|
||||||
if (ActiveGames == null)
|
|
||||||
{
|
{
|
||||||
|
ActiveGames = JsonSerializer.Deserialize<Dictionary<int, KasinoMinesGame>>(json.ToString()) ??
|
||||||
|
throw new InvalidOperationException();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_logger.Error(e);
|
||||||
_logger.Error("Potentially failed to deserialize active mines games in GetSavedGames() in KasinoMines in Services");
|
_logger.Error("Potentially failed to deserialize active mines games in GetSavedGames() in KasinoMines in Services");
|
||||||
ActiveGames = new Dictionary<int, KasinoMinesGame>();
|
ActiveGames = new Dictionary<int, KasinoMinesGame>();
|
||||||
}
|
}
|
||||||
@@ -284,7 +291,7 @@ public class KasinoMines
|
|||||||
await GetSavedGames();
|
await GetSavedGames();
|
||||||
var game = ActiveGames[gamblerId];
|
var game = ActiveGames[gamblerId];
|
||||||
game.LastInteracted = DateTimeOffset.UtcNow;
|
game.LastInteracted = DateTimeOffset.UtcNow;
|
||||||
if (game.LastMessage != msg)
|
if (game.LastMessageId != msg.ChatMessageId)
|
||||||
{
|
{
|
||||||
await game.ResetMessage(msg);
|
await game.ResetMessage(msg);
|
||||||
}
|
}
|
||||||
@@ -304,7 +311,7 @@ public class KasinoMines
|
|||||||
await GetSavedGames();
|
await GetSavedGames();
|
||||||
var game = ActiveGames[gamblerId];
|
var game = ActiveGames[gamblerId];
|
||||||
game.LastInteracted = DateTimeOffset.UtcNow;
|
game.LastInteracted = DateTimeOffset.UtcNow;
|
||||||
if (game.LastMessage != msg)
|
if (game.LastMessageId != msg.ChatMessageId)
|
||||||
{
|
{
|
||||||
await game.ResetMessage(msg);
|
await game.ResetMessage(msg);
|
||||||
}
|
}
|
||||||
@@ -315,7 +322,7 @@ public class KasinoMines
|
|||||||
{
|
{
|
||||||
game.BetsPlaced.Add(coord);
|
game.BetsPlaced.Add(coord);
|
||||||
await _kfChatBot.KfClient.EditMessageAsync(msg.ChatMessageId!.Value, game.ToString());
|
await _kfChatBot.KfClient.EditMessageAsync(msg.ChatMessageId!.Value, game.ToString());
|
||||||
game.Explode((coord.r, coord.c), msg);
|
await game.Explode((coord.r, coord.c), msg);
|
||||||
var newBalance = await Money.NewWagerAsync(game.Creator.Id, game.Wager, -game.Wager, WagerGame.Mines);
|
var newBalance = await Money.NewWagerAsync(game.Creator.Id, game.Wager, -game.Wager, WagerGame.Mines);
|
||||||
await _kfChatBot.SendChatMessageAsync(
|
await _kfChatBot.SendChatMessageAsync(
|
||||||
$"{game.Creator.User.FormatUsername()}, you lost your {game.Wager.FormatKasinoCurrencyAsync()} bet on mines, collecting {game.BetsPlaced.Count} gems until you hit one of {game.Mines} mines. Net: {(-game.Wager).FormatKasinoCurrencyAsync()}. Balance: {newBalance.FormatKasinoCurrencyAsync()}",
|
$"{game.Creator.User.FormatUsername()}, you lost your {game.Wager.FormatKasinoCurrencyAsync()} bet on mines, collecting {game.BetsPlaced.Count} gems until you hit one of {game.Mines} mines. Net: {(-game.Wager).FormatKasinoCurrencyAsync()}. Balance: {newBalance.FormatKasinoCurrencyAsync()}",
|
||||||
@@ -331,7 +338,7 @@ public class KasinoMines
|
|||||||
await game.RigBoard(coord);
|
await game.RigBoard(coord);
|
||||||
await Task.Delay(50);
|
await Task.Delay(50);
|
||||||
await _kfChatBot.KfClient.EditMessageAsync(msg.ChatMessageId!.Value, game.ToString());
|
await _kfChatBot.KfClient.EditMessageAsync(msg.ChatMessageId!.Value, game.ToString());
|
||||||
game.Explode(coord, msg);
|
await game.Explode(coord, msg);
|
||||||
var newBalance = await Money.NewWagerAsync(game.Creator.Id, game.Wager, -game.Wager, WagerGame.Mines);
|
var newBalance = await Money.NewWagerAsync(game.Creator.Id, game.Wager, -game.Wager, WagerGame.Mines);
|
||||||
await _kfChatBot.SendChatMessageAsync(
|
await _kfChatBot.SendChatMessageAsync(
|
||||||
$"{game.Creator.User.FormatUsername()}, you lost your {game.Wager.FormatKasinoCurrencyAsync()} bet on mines, collecting {game.BetsPlaced.Count} gems until you hit one of {game.Mines} mines. Net: {(-game.Wager).FormatKasinoCurrencyAsync()}. Balance: {newBalance.FormatKasinoCurrencyAsync()}",
|
$"{game.Creator.User.FormatUsername()}, you lost your {game.Wager.FormatKasinoCurrencyAsync()} bet on mines, collecting {game.BetsPlaced.Count} gems until you hit one of {game.Mines} mines. Net: {(-game.Wager).FormatKasinoCurrencyAsync()}. Balance: {newBalance.FormatKasinoCurrencyAsync()}",
|
||||||
@@ -354,7 +361,7 @@ public class KasinoMines
|
|||||||
public async Task CreateGame(GamblerDbModel gambler, decimal bet, int size, int mines)
|
public async Task CreateGame(GamblerDbModel gambler, decimal bet, int size, int mines)
|
||||||
{
|
{
|
||||||
await GetSavedGames();
|
await GetSavedGames();
|
||||||
ActiveGames?.Add(gambler.Id, new KasinoMinesGame(gambler, bet, size, mines));
|
ActiveGames.Add(gambler.Id, new KasinoMinesGame(gambler, bet, size, mines));
|
||||||
await SaveActiveGames();
|
await SaveActiveGames();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user