From 1de4d3b47532e03cdd9752bb584a47fdd949af60 Mon Sep 17 00:00:00 2001 From: barelyprofessional <150058423+barelyprofessional@users.noreply.github.com> Date: Sat, 27 Dec 2025 09:28:43 -0600 Subject: [PATCH] Cleaned up compiler warnings --- .../Commands/Kasino/SlotsCommand.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/KfChatDotNetBot/Commands/Kasino/SlotsCommand.cs b/KfChatDotNetBot/Commands/Kasino/SlotsCommand.cs index 1fcac4b..8cdc833 100644 --- a/KfChatDotNetBot/Commands/Kasino/SlotsCommand.cs +++ b/KfChatDotNetBot/Commands/Kasino/SlotsCommand.cs @@ -70,6 +70,10 @@ public class SlotsCommand : ICommand board.ExecuteGameLoop(); using (var finalImageStream = board.ExportAndCleanup()) { + if (finalImageStream == null) + { + throw new InvalidOperationException("board.ExportAndCleanup returned null"); + } var imageUrl = await Zipline.Upload(finalImageStream, new MediaTypeHeaderValue("image/webp"), "1h", ctx); await botInstance.SendChatMessageAsync($"[img]{imageUrl}[/img]", true, autoDeleteAfter: TimeSpan.FromSeconds(150)); @@ -103,10 +107,10 @@ public class SlotsCommand : ICommand private class KiwiSlotBoard : IDisposable { private const char WILD = 'K', FEATURE = 'L', EXPANDER = 'M'; - private Image _headerImg; + private Image? _headerImg; private Dictionary> _symbolImgs = new(); private Dictionary> _expanderImgs = new(); - private Font _font; + private Font? _font; // Optimized Animation Container private Image AnimatedImage { get; set; } @@ -157,6 +161,10 @@ public class SlotsCommand : ICommand private void RenderFrame(int dropOffset = 500, List? activeWins = null) { + if (_font == null || _headerImg == null) + { + throw new InvalidOperationException("_font or _headerImg was null"); + } using var frame = new Image(600, 800); frame.Mutate(ctx => { ctx.Fill(Color.Black); @@ -260,7 +268,7 @@ public class SlotsCommand : ICommand AnimatedImage.Frames.AddFrame(frame.Frames.RootFrame); } - public MemoryStream ExportAndCleanup() + public MemoryStream? ExportAndCleanup() { if (AnimatedImage.Frames.Count <= 1) return null; @@ -312,7 +320,7 @@ public class SlotsCommand : ICommand for (var c = i; c < 5; c++) if (_preboard[c, j] == WILD) hitWild = true; var mSym = hitWild ? multis[_rand.Next(multis.Count)] : EXPANDER; for (var r = i; r < 5; r++) _board[r, j] = mSym; - RenderFrame(500); break; + RenderFrame(); break; } } } @@ -322,7 +330,7 @@ public class SlotsCommand : ICommand var inc = win.Amount / 10.0; for (var f = 0; f < 10; f++) { RunningTotalDisplay += inc; RenderFrame(500, [win]); } } - RunningTotalDisplay = target; RenderFrame(500); + RunningTotalDisplay = target; RenderFrame(); } private List GetWinningLinesCoordsWithPayouts()