Refactored and corrected compiler warnings on Keno and Planes

This commit is contained in:
barelyprofessional
2025-11-16 00:45:41 -06:00
parent e2ae5c20c2
commit e99434f5df
2 changed files with 31 additions and 37 deletions

View File

@@ -34,7 +34,7 @@ public class KenoCommand : ICommand
private const string MatchRevealDisplay = "💠"; private const string MatchRevealDisplay = "💠";
private const string BlankSpaceDisplay = "⬛"; private const string BlankSpaceDisplay = "⬛";
private SentMessageTrackerModel _kenoTable; private SentMessageTrackerModel? _kenoTable;
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
CancellationToken ctx) CancellationToken ctx)
@@ -97,7 +97,7 @@ public class KenoCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, you [color={colors[BuiltIn.Keys.KiwiFarmsRedColor].Value}]lost {await wager.FormatKasinoCurrencyAsync()}[/color]. Your balance is now: {await newBalance.FormatKasinoCurrencyAsync()}.", $"{user.FormatUsername()}, you [color={colors[BuiltIn.Keys.KiwiFarmsRedColor].Value}]lost {await wager.FormatKasinoCurrencyAsync()}[/color]. Your balance is now: {await newBalance.FormatKasinoCurrencyAsync()}.",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
botInstance.ScheduleMessageAutoDelete(_kenoTable, cleanupDelay); botInstance.ScheduleMessageAutoDelete(_kenoTable ?? throw new Exception("Cannot clean up _kenoTable as it's null"), cleanupDelay);
return; return;
} }
@@ -109,7 +109,7 @@ public class KenoCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, you [color={colors[BuiltIn.Keys.KiwiFarmsGreenColor].Value}]won {await win.FormatKasinoCurrencyAsync()} with a {payoutMulti}x multi![/color]. Your balance is now: {await newBalance.FormatKasinoCurrencyAsync()}.", $"{user.FormatUsername()}, you [color={colors[BuiltIn.Keys.KiwiFarmsGreenColor].Value}]won {await win.FormatKasinoCurrencyAsync()} with a {payoutMulti}x multi![/color]. Your balance is now: {await newBalance.FormatKasinoCurrencyAsync()}.",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
botInstance.ScheduleMessageAutoDelete(_kenoTable, cleanupDelay); botInstance.ScheduleMessageAutoDelete(_kenoTable ?? throw new Exception("Cannot clean up _kenotable as it's null"), cleanupDelay);
} }
private async Task AnimatedDisplayTable(List<int> playerNumbers, List<int> casinoNumbers, List<int> matches, ChatBot botInstance) private async Task AnimatedDisplayTable(List<int> playerNumbers, List<int> casinoNumbers, List<int> matches, ChatBot botInstance)
@@ -141,6 +141,11 @@ public class KenoCommand : ICommand
await Task.Delay(100); await Task.Delay(100);
} }
if (_kenoTable.ChatMessageId == null)
{
throw new Exception($"_kenoTable chat message ID never got populated. Tracker status is: {_kenoTable?.Status}");
}
var frameDelay = (await SettingsProvider.GetValueAsync(BuiltIn.Keys.KasinoKenoFrameDelay)).ToType<int>(); var frameDelay = (await SettingsProvider.GetValueAsync(BuiltIn.Keys.KasinoKenoFrameDelay)).ToType<int>();
//FIRST FRAME 11111111111111111111111111111 //FIRST FRAME 11111111111111111111111111111
for (var frame = 0; frame < 10; frame++) //1 frame per casino number for (var frame = 0; frame < 10; frame++) //1 frame per casino number

View File

@@ -39,8 +39,8 @@ public class Planes : ICommand
private const string Water = "🌊"; private const string Water = "🌊";
private const string Air = "\u2B1C"; // White square private const string Air = "\u2B1C"; // White square
private const string BlankSpace = ""; //need 35? private const string BlankSpace = ""; //need 35?
private bool rigged = false; private bool _rigged;
private bool superRigged = false; private bool _superRigged;
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
CancellationToken ctx) CancellationToken ctx)
{ {
@@ -68,21 +68,19 @@ public class Planes : ICommand
return; return;
} }
var carrierCount = 6; const int carrierCount = 6;
var planesBoard = CreatePlanesBoard(gambler,0); var planesBoard = CreatePlanesBoard(gambler,0);
var planesBoard2 = CreatePlanesBoard(gambler); var planesBoard2 = CreatePlanesBoard(gambler);
var planesBoard3 = CreatePlanesBoard(gambler); var planesBoard3 = CreatePlanesBoard(gambler);
if (rigged) if (_rigged)
{ {
planesBoard2 = RigPlanesBoard(planesBoard2, carrierCount, 0); planesBoard2 = RigPlanesBoard(planesBoard2, carrierCount, 0);
planesBoard3 = RigPlanesBoard(planesBoard3, carrierCount, 0); planesBoard3 = RigPlanesBoard(planesBoard3, carrierCount, 0);
} }
List<int[,]> planesBoards = new List<int[,]>(){planesBoard, planesBoard2, planesBoard3}; List<int[,]> planesBoards = [planesBoard, planesBoard2, planesBoard3];
var plane = new Plane(gambler); var plane = new Plane(gambler);
var frameLength = 1000.0; const double frameLength = 1000.0;
var fullCounter = 0; var fullCounter = 0;
bool firstBoard = true;
var counter = 0;
var noseUp = true; var noseUp = true;
var planesDisplay = GetPreGameBoard(-3, planesBoard2, plane, carrierCount, noseUp); var planesDisplay = GetPreGameBoard(-3, planesBoard2, plane, carrierCount, noseUp);
var msgId = await botInstance.SendChatMessageAsync(planesDisplay, true); var msgId = await botInstance.SendChatMessageAsync(planesDisplay, true);
@@ -102,8 +100,7 @@ public class Planes : ICommand
*/ */
do do
{ {
if ((fullCounter-3) > 19) firstBoard = false; var counter = (fullCounter - 3) % 20;
counter = (fullCounter - 3) % 20;
await Task.Delay(TimeSpan.FromMilliseconds(frameLength / 3), ctx); await Task.Delay(TimeSpan.FromMilliseconds(frameLength / 3), ctx);
@@ -217,20 +214,20 @@ public class Planes : ICommand
plane.Gravity(); plane.Gravity();
if ((fullCounter - 3) % 20 == 0 && fullCounter != 3)//removes old planesboard, adds new planeboard when necessary **********************************************************************NEEDS MORE UPDATES if ((fullCounter - 3) % 20 == 0 && fullCounter != 3)//removes old planesboard, adds new planeboard when necessary **********************************************************************NEEDS MORE UPDATES
{ {
if (Money.GetRandomNumber(gambler, 0, 100) == 0 && settings[BuiltIn.Keys.KasinoPlanesRandomRiggeryEnabled].ToBoolean()) rigged = true; if (Money.GetRandomNumber(gambler, 0, 100) == 0 && settings[BuiltIn.Keys.KasinoPlanesRandomRiggeryEnabled].ToBoolean()) _rigged = true;
if (settings[BuiltIn.Keys.KasinoPlanesTargetedRiggeryEnabled].ToBoolean() && if (settings[BuiltIn.Keys.KasinoPlanesTargetedRiggeryEnabled].ToBoolean() &&
settings[BuiltIn.Keys.KasinoPlanesTargetedRiggeryVictims].JsonDeserialize<List<int>>()!.Contains(user.KfId)) settings[BuiltIn.Keys.KasinoPlanesTargetedRiggeryVictims].JsonDeserialize<List<int>>()!.Contains(user.KfId))
{ {
rigged = true; _rigged = true;
} }
logger.Info($"Switching planes boards. FullCounter: {fullCounter} | Counter: {counter}"); logger.Info($"Switching planes boards. FullCounter: {fullCounter} | Counter: {counter}");
planesBoards.RemoveAt(0); planesBoards.RemoveAt(0);
planesBoards.Add(CreatePlanesBoard(gambler)); planesBoards.Add(CreatePlanesBoard(gambler));
if (rigged && Money.GetRandomNumber(gambler, 0, 100) == 0) { if (_rigged && Money.GetRandomNumber(gambler, 0, 100) == 0) {
planesBoards[1] = CreatePlanesBoard(gambler, 1); //1% chance to update to a board full of rockets if rigged planesBoards[1] = CreatePlanesBoard(gambler, 1); //1% chance to update to a board full of rockets if rigged
superRigged = true; _superRigged = true;
} }
else if (rigged) else if (_rigged)
{ {
planesBoards[1] = RigPlanesBoard(planesBoards[1], carrierCount, fullCounter); planesBoards[1] = RigPlanesBoard(planesBoards[1], carrierCount, fullCounter);
planesBoards[2] = RigPlanesBoard(planesBoards[2], carrierCount, fullCounter); planesBoards[2] = RigPlanesBoard(planesBoards[2], carrierCount, fullCounter);
@@ -334,8 +331,6 @@ public class Planes : ICommand
private string GetGameBoard(int fullCounter, List<int[,]> planesBoards, Plane plane, int carrierCount, bool noseUp) private string GetGameBoard(int fullCounter, List<int[,]> planesBoards, Plane plane, int carrierCount, bool noseUp)
{ {
var output = ""; var output = "";
int counter;
var logger = LogManager.GetCurrentClassLogger();
for (var row = 0; row < 8; row++) for (var row = 0; row < 8; row++)
{ {
@@ -344,6 +339,7 @@ public class Planes : ICommand
column++) //plane starts out 3 space behind to give some space to the view, column++) //plane starts out 3 space behind to give some space to the view,
{ {
var useBoard = 1; var useBoard = 1;
int counter;
if (fullCounter < 23) counter = fullCounter % 23 - 3; if (fullCounter < 23) counter = fullCounter % 23 - 3;
else counter = (fullCounter - 3) % 20; else counter = (fullCounter - 3) % 20;
//--- //---
@@ -404,7 +400,7 @@ public class Planes : ICommand
} }
// Was https://i.postimg.cc/rmX59qtV/avelloonaircall2.webp previously // Was https://i.postimg.cc/rmX59qtV/avelloonaircall2.webp previously
if (superRigged && row == 0) output += "[img]https://i.ddos.lgbt/u/6v8WJ5.webp[/img]"; if (_superRigged && row == 0) output += "[img]https://i.ddos.lgbt/u/6v8WJ5.webp[/img]";
output += "[br]"; output += "[br]";
} }
return output; return output;
@@ -419,18 +415,13 @@ public class Planes : ICommand
{ {
var randomNum = Money.GetRandomNumber(gambler, 1, 100); var randomNum = Money.GetRandomNumber(gambler, 1, 100);
if (forceTiles != -1) board[row, column] = forceTiles; if (forceTiles != -1) board[row, column] = forceTiles;
else if (randomNum < 49)
{
board[row, column] = 0; //neutral
}
else if (randomNum > 79)
{
board[row, column] = 1; //rocket
}
else else
board[row, column] = randomNum switch
{ {
board[row, column] = 2; //multi < 49 => 0,
} > 79 => 1,
_ => 2
};
} }
} }
return board; return board;
@@ -438,11 +429,9 @@ public class Planes : ICommand
private int[,] RigPlanesBoard(int[,] planesBoard, int carrierCount, int fullCounter) private int[,] RigPlanesBoard(int[,] planesBoard, int carrierCount, int fullCounter)
{ {
int[,] returnBoard = new int[6,20]; var returnBoard = new int[6,20];
int boardCounter = (fullCounter-3) / 20; bool startUpdating;
var spaceToUpdate = 0; var spaceToUpdate = (fullCounter-3) % 20; //how far along is the game into the current board
bool startUpdating = true;
spaceToUpdate = (fullCounter-3) % 20; //how far along is the game into the current board
if (spaceToUpdate > 0) startUpdating = false; if (spaceToUpdate > 0) startUpdating = false;
for (var row = 0; row < 6; row++) for (var row = 0; row < 6; row++)