mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-05-02 04:22:04 -04:00
fix chat message ID handling and index out of bounds error (#63)
* fix chat message ID handling and index out of bounds error fix chat message ID handling and index out of bounds error * fix feature incorrectly showing for some reason idk why this started happening hopefully this fixes it, actual features might still be broken though
This commit is contained in:
@@ -186,7 +186,7 @@ public class SlotsCommand : ICommand
|
|||||||
public decimal RunningTotalDisplay = 0;
|
public decimal RunningTotalDisplay = 0;
|
||||||
private int _activeFeatureTier = 0, _currentFeatureSpin = 0;
|
private int _activeFeatureTier = 0, _currentFeatureSpin = 0;
|
||||||
private bool _showGoldCircle = false;
|
private bool _showGoldCircle = false;
|
||||||
|
private bool _currentlyInFeature = false;
|
||||||
|
|
||||||
private readonly RandomShim<StandardRng> _rand = RandomShim.Create(StandardRng.Create());
|
private readonly RandomShim<StandardRng> _rand = RandomShim.Create(StandardRng.Create());
|
||||||
private static readonly List<char> ExpanderWild =
|
private static readonly List<char> ExpanderWild =
|
||||||
@@ -323,7 +323,7 @@ public class SlotsCommand : ICommand
|
|||||||
DrawAutoScaledText($"BET: ${_userBet.FormatKasinoCurrencyAsync(wrapInPlainBbCode: false).Result}", largeFont, Color.White, new RectangleF(20, 700, 180, 100));
|
DrawAutoScaledText($"BET: ${_userBet.FormatKasinoCurrencyAsync(wrapInPlainBbCode: false).Result}", largeFont, Color.White, new RectangleF(20, 700, 180, 100));
|
||||||
DrawAutoScaledText($"WIN: ${RunningTotalDisplay.FormatKasinoCurrencyAsync(wrapInPlainBbCode: false).Result}", largeFont, Color.Gold, new RectangleF(380, 700, 200, 100));
|
DrawAutoScaledText($"WIN: ${RunningTotalDisplay.FormatKasinoCurrencyAsync(wrapInPlainBbCode: false).Result}", largeFont, Color.Gold, new RectangleF(380, 700, 200, 100));
|
||||||
|
|
||||||
if (_currentFeatureSpin > 0) {
|
if (_currentFeatureSpin > 0 && _currentlyInFeature) {
|
||||||
var total = _activeFeatureTier switch { 3 => 3, 4 => 5, 5 => 10, _ => 0 };
|
var total = _activeFeatureTier switch { 3 => 3, 4 => 5, 5 => 10, _ => 0 };
|
||||||
DrawAutoScaledText($"SPIN {_currentFeatureSpin}/{total}", largeFont, Color.SkyBlue, new RectangleF(210, 700, 160, 100));
|
DrawAutoScaledText($"SPIN {_currentFeatureSpin}/{total}", largeFont, Color.SkyBlue, new RectangleF(210, 700, 160, 100));
|
||||||
}
|
}
|
||||||
@@ -378,8 +378,9 @@ public class SlotsCommand : ICommand
|
|||||||
if (featureSpins == 0) {
|
if (featureSpins == 0) {
|
||||||
_activeFeatureTier = fCount >= 5 ? 5 : (fCount >= 3 ? fCount : 0);
|
_activeFeatureTier = fCount >= 5 ? 5 : (fCount >= 3 ? fCount : 0);
|
||||||
_showGoldCircle = _activeFeatureTier >= 3; _currentFeatureSpin = 0;
|
_showGoldCircle = _activeFeatureTier >= 3; _currentFeatureSpin = 0;
|
||||||
|
_currentlyInFeature = false;
|
||||||
} else {
|
} else {
|
||||||
_showGoldCircle = true; _currentFeatureSpin = featureSpins;
|
_showGoldCircle = true; _currentFeatureSpin = featureSpins; _currentlyInFeature = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessReelsAndWins();
|
ProcessReelsAndWins();
|
||||||
|
|||||||
@@ -68,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 (LastMessageId != msg.ChatMessageId)
|
if (LastMessageId != msg.ChatMessageId.Value)
|
||||||
{
|
{
|
||||||
await ResetMessage(msg);
|
await ResetMessage(msg);
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ public class KasinoMines
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await _kfChatBot.KfClient.EditMessageAsync(msg.ChatMessageId!.Value, $"{str}[br]{Creator.User.FormatUsername()}");
|
await _kfChatBot.KfClient.EditMessageAsync(LastMessageId, $"{str}[br]{Creator.User.FormatUsername()}");
|
||||||
}
|
}
|
||||||
|
|
||||||
await Task.Delay(TimeSpan.FromSeconds(10));
|
await Task.Delay(TimeSpan.FromSeconds(10));
|
||||||
@@ -291,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.LastMessageId != msg.ChatMessageId)
|
if (game.LastMessageId != msg.ChatMessageId.Value)
|
||||||
{
|
{
|
||||||
await game.ResetMessage(msg);
|
await game.ResetMessage(msg);
|
||||||
}
|
}
|
||||||
@@ -299,7 +299,7 @@ public class KasinoMines
|
|||||||
(int r, int c) coord;
|
(int r, int c) coord;
|
||||||
while (betCoords.Count != count)//creates a list of coordinates to bet on using the coordinate bet function
|
while (betCoords.Count != count)//creates a list of coordinates to bet on using the coordinate bet function
|
||||||
{
|
{
|
||||||
coord = (Money.GetRandomNumber(game.Creator, 0, game.Size), Money.GetRandomNumber(game.Creator, 0, game.Size));
|
coord = (Money.GetRandomNumber(game.Creator, 0, game.Size-1), Money.GetRandomNumber(game.Creator, 0, game.Size-1));
|
||||||
if (!betCoords.Contains(coord) && !game.BetsPlaced.Contains(coord)) betCoords.Add(coord);
|
if (!betCoords.Contains(coord) && !game.BetsPlaced.Contains(coord)) betCoords.Add(coord);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,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.LastMessageId != msg.ChatMessageId)
|
if (game.LastMessageId != msg.ChatMessageId.Value)
|
||||||
{
|
{
|
||||||
await game.ResetMessage(msg);
|
await game.ResetMessage(msg);
|
||||||
}
|
}
|
||||||
@@ -322,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());
|
||||||
await game.Explode((coord.r, coord.c), msg);
|
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()}",
|
||||||
@@ -338,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());
|
||||||
await game.Explode(coord, msg);
|
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()}",
|
||||||
|
|||||||
Reference in New Issue
Block a user