mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-05-02 04:22:04 -04:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
367
KfChatDotNetBot/Commands/Kasino/KasinoEventCommands.cs
Normal file
367
KfChatDotNetBot/Commands/Kasino/KasinoEventCommands.cs
Normal file
@@ -0,0 +1,367 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Humanizer;
|
||||
using KfChatDotNetBot.Extensions;
|
||||
using KfChatDotNetBot.Models;
|
||||
using KfChatDotNetBot.Models.DbModels;
|
||||
using KfChatDotNetBot.Services;
|
||||
using KfChatDotNetBot.Settings;
|
||||
using KfChatDotNetWsClient.Models.Events;
|
||||
|
||||
namespace KfChatDotNetBot.Commands.Kasino;
|
||||
|
||||
public class KasinoNewEventCommand : ICommand
|
||||
{
|
||||
public List<Regex> Patterns =>
|
||||
[
|
||||
new Regex("^kasino event new$", RegexOptions.IgnoreCase),
|
||||
new Regex(@"^kasino event new (?<type>\w+)$", RegexOptions.IgnoreCase),
|
||||
new Regex(@"^kasino event new (?<type>\w+) (?<description>.+)$", RegexOptions.IgnoreCase),
|
||||
];
|
||||
|
||||
public string? HelpText => "Create a new kasino event";
|
||||
public UserRight RequiredRight => UserRight.TrueAndHonest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
var settings = await SettingsProvider.GetMultipleValuesAsync([
|
||||
BuiltIn.Keys.KasinoEventWeightWinAgainstSelectionTime, BuiltIn.Keys.KasinoEventData,
|
||||
BuiltIn.Keys.KasinoEventTextLengthLimit
|
||||
]);
|
||||
if (!arguments.TryGetValue("type", out var type))
|
||||
{
|
||||
await botInstance.SendChatMessageAsync(
|
||||
$"{user.FormatUsername()}, not enough arguments. !kasino event new <win-lose, time-prediction> <description>",
|
||||
true, autoDeleteAfter: TimeSpan.FromSeconds(60));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!arguments.TryGetValue("description", out var description))
|
||||
{
|
||||
await botInstance.SendChatMessageAsync(
|
||||
$"{user.FormatUsername()}, not enough arguments. !kasino event new <win-lose, time-prediction> <description>",
|
||||
true, autoDeleteAfter: TimeSpan.FromSeconds(60));
|
||||
return;
|
||||
}
|
||||
|
||||
if (description.Length > settings[BuiltIn.Keys.KasinoEventTextLengthLimit].ToType<int>())
|
||||
{
|
||||
await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, your event description / text with a length of " +
|
||||
$"{description.Length} characters exceeds the limit of " +
|
||||
$"{settings[BuiltIn.Keys.KasinoEventTextLengthLimit].ToType<int>()} " +
|
||||
$"characters", true);
|
||||
return;
|
||||
}
|
||||
|
||||
var useTimeWeightedPayout = settings[BuiltIn.Keys.KasinoEventWeightWinAgainstSelectionTime].ToBoolean();
|
||||
KasinoEventType eventType;
|
||||
var guide = string.Empty;
|
||||
if (type.Value.Equals("win-lose", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
eventType = KasinoEventType.WinLose;
|
||||
guide = "Add option: !kasino event {EventId} options add|new <text>[br]" +
|
||||
"Remove option: !kasino event {EventId} options del|remove <option id>";
|
||||
}
|
||||
else if (type.Value.Equals("time-prediction", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
eventType = KasinoEventType.Prediction;
|
||||
}
|
||||
else
|
||||
{
|
||||
await botInstance.SendChatMessageAsync(
|
||||
$"{user.FormatUsername()}, unknown event type given. Options are win-lose or time-prediction",
|
||||
true, autoDeleteAfter: TimeSpan.FromSeconds(60));
|
||||
return;
|
||||
}
|
||||
|
||||
var eventData = settings[BuiltIn.Keys.KasinoEventData].JsonDeserialize<List<KasinoEventModel>>() ?? [];
|
||||
var newEvent = new KasinoEventModel
|
||||
{
|
||||
EventText = description.Value,
|
||||
EventId = Money.GenerateEventId(),
|
||||
Options = [],
|
||||
EventType = eventType,
|
||||
EventAnnouncementReceived = null,
|
||||
EventState = KasinoEventState.Incomplete,
|
||||
SelectionTimeWeightedPayout = useTimeWeightedPayout
|
||||
};
|
||||
eventData.Add(newEvent);
|
||||
await SettingsProvider.SetValueAsJsonObjectAsync(BuiltIn.Keys.KasinoEventData, eventData);
|
||||
await botInstance.SendChatMessageAsync(
|
||||
$"{user.FormatUsername()}, new incomplete kasino event created. Event ID is {newEvent.EventId}.[br]" +
|
||||
guide.Replace("{EventId}", newEvent.EventId) +
|
||||
$"Start the event: !kasino event {newEvent.EventId} start[br]" +
|
||||
$"Abandon the event: !kasino event {newEvent.EventId} abandon[br]" +
|
||||
$"Get event info: !kasino event {newEvent.EventId} info", true);
|
||||
}
|
||||
}
|
||||
|
||||
public class KasinoEventStart : ICommand
|
||||
{
|
||||
public List<Regex> Patterns =>
|
||||
[
|
||||
new Regex(@"^kasino event (?<event_id>\w+) start$", RegexOptions.IgnoreCase),
|
||||
];
|
||||
|
||||
public string? HelpText => "Start a Kasino event";
|
||||
public UserRight RequiredRight => UserRight.TrueAndHonest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(300);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
var settings = await SettingsProvider.GetMultipleValuesAsync([
|
||||
BuiltIn.Keys.KasinoEventData
|
||||
]);
|
||||
var eventId = arguments["event_id"].Value;
|
||||
var eventList = settings[BuiltIn.Keys.KasinoEventData].JsonDeserialize<List<KasinoEventModel>>() ?? [];
|
||||
var targetEvent = eventList.FirstOrDefault(x => x.EventId == eventId);
|
||||
if (targetEvent == null)
|
||||
{
|
||||
await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, this event does not exist", true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetEvent.EventState != KasinoEventState.Incomplete)
|
||||
{
|
||||
await botInstance.SendChatMessageAsync(
|
||||
$"{user.FormatUsername()}, the event is in state '{targetEvent.EventState.Humanize()}'. Only incomplete events can be started",
|
||||
true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var guide = $"Submit your prediction: !predict {targetEvent.EventId} <wager> 1h30m15s";
|
||||
if (targetEvent.EventType == KasinoEventType.WinLose)
|
||||
{
|
||||
if (targetEvent.Options.Count == 0)
|
||||
{
|
||||
await botInstance.SendChatMessageAsync(
|
||||
$"{user.FormatUsername()}, you can't start a win-lose event with no options.", true);
|
||||
return;
|
||||
}
|
||||
|
||||
guide = targetEvent.Options.Aggregate(string.Empty,
|
||||
(current, option) => current + $"{option.OptionId}: {option.OptionText}[br]");
|
||||
guide += "Submit your choice: !";
|
||||
}
|
||||
targetEvent.EventState = KasinoEventState.PendingAnnouncement;
|
||||
await SettingsProvider.SetValueAsJsonObjectAsync(BuiltIn.Keys.KasinoEventData, eventList);
|
||||
var msg = $":!: :!: A Keno Kasino event has started! :!: :!:[br]{targetEvent.EventText}[br]{guide}";
|
||||
var msgIds = await botInstance.SendChatMessagesAsync(msg.FancySplitMessage(partSeparator: "[br]"), true);
|
||||
var i = 0;
|
||||
while (msgIds[0].ChatMessageId != null)
|
||||
{
|
||||
i++;
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(100), ctx);
|
||||
if (i > 3000) return;
|
||||
}
|
||||
|
||||
targetEvent.EventState = KasinoEventState.Started;
|
||||
targetEvent.EventAnnouncementReceived = msgIds[0].SentAt;
|
||||
await SettingsProvider.SetValueAsJsonObjectAsync(BuiltIn.Keys.KasinoEventData, eventList);
|
||||
}
|
||||
}
|
||||
|
||||
public class KasinoNewEventOption : ICommand
|
||||
{
|
||||
public List<Regex> Patterns =>
|
||||
[
|
||||
new Regex(@"^kasino event (?<event_id>\w+) options add (?<option_text>\.+)$", RegexOptions.IgnoreCase),
|
||||
new Regex(@"^kasino event (?<event_id>\w+) options new (?<option_text>\.+)$", RegexOptions.IgnoreCase),
|
||||
];
|
||||
|
||||
public string? HelpText => "Add an option to a Kasino event";
|
||||
public UserRight RequiredRight => UserRight.TrueAndHonest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
var settings = await SettingsProvider.GetMultipleValuesAsync([
|
||||
BuiltIn.Keys.KasinoEventData, BuiltIn.Keys.KasinoEventOptionTextLengthLimit
|
||||
]);
|
||||
var eventId = arguments["event_id"].Value;
|
||||
var eventList = settings[BuiltIn.Keys.KasinoEventData].JsonDeserialize<List<KasinoEventModel>>() ?? [];
|
||||
var targetEvent = eventList.FirstOrDefault(x => x.EventId == eventId);
|
||||
if (targetEvent == null)
|
||||
{
|
||||
await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, this event does not exist", true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetEvent.EventState != KasinoEventState.Incomplete)
|
||||
{
|
||||
await botInstance.SendChatMessageAsync(
|
||||
$"{user.FormatUsername()}, the event is in state '{targetEvent.EventState.Humanize()}'. Only incomplete events can have their options modified",
|
||||
true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetEvent.EventType == KasinoEventType.Prediction)
|
||||
{
|
||||
await botInstance.SendChatMessageAsync(
|
||||
$"{user.FormatUsername()}, events based around time predictions can't have options", true);
|
||||
return;
|
||||
}
|
||||
|
||||
var optionText = arguments["option_text"].Value;
|
||||
if (optionText.Length > settings[BuiltIn.Keys.KasinoEventOptionTextLengthLimit].ToType<int>())
|
||||
{
|
||||
await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, your option text with a length of " +
|
||||
$"{optionText.Length} characters exceeds the limit of " +
|
||||
$"{settings[BuiltIn.Keys.KasinoEventOptionTextLengthLimit].ToType<int>()} " +
|
||||
$"characters", true);
|
||||
return;
|
||||
}
|
||||
var newOption = new KasinoEventOptionModel
|
||||
{
|
||||
OptionId = Money.GenerateEventId(),
|
||||
OptionText = optionText,
|
||||
Won = false
|
||||
};
|
||||
targetEvent.Options.Add(newOption);
|
||||
await SettingsProvider.SetValueAsJsonObjectAsync(BuiltIn.Keys.KasinoEventData, eventList);
|
||||
await botInstance.SendChatMessageAsync(
|
||||
$"{user.FormatUsername()}, created new option with id {newOption.OptionId}[br]To remove this option, run: !kasino event {targetEvent.EventId} options remove {newOption.OptionId}", true);
|
||||
}
|
||||
}
|
||||
|
||||
public class KasinoRemoveEventOption : ICommand
|
||||
{
|
||||
public List<Regex> Patterns =>
|
||||
[
|
||||
new Regex(@"^kasino event (?<event_id>\w+) options del (?<option_id>\.+)$", RegexOptions.IgnoreCase),
|
||||
new Regex(@"^kasino event (?<event_id>\w+) options remove (?<option_id>\.+)$", RegexOptions.IgnoreCase),
|
||||
];
|
||||
|
||||
public string? HelpText => "Remove an option from a Kasino event";
|
||||
public UserRight RequiredRight => UserRight.TrueAndHonest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
var settings = await SettingsProvider.GetMultipleValuesAsync([
|
||||
BuiltIn.Keys.KasinoEventData
|
||||
]);
|
||||
var eventId = arguments["event_id"].Value;
|
||||
var eventList = settings[BuiltIn.Keys.KasinoEventData].JsonDeserialize<List<KasinoEventModel>>() ?? [];
|
||||
var targetEvent = eventList.FirstOrDefault(x => x.EventId == eventId);
|
||||
if (targetEvent == null)
|
||||
{
|
||||
await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, this event does not exist", true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetEvent.EventState != KasinoEventState.Incomplete)
|
||||
{
|
||||
await botInstance.SendChatMessageAsync(
|
||||
$"{user.FormatUsername()}, the event is in state '{targetEvent.EventState.Humanize()}'. Only incomplete events can have their options modified",
|
||||
true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetEvent.EventType == KasinoEventType.Prediction)
|
||||
{
|
||||
await botInstance.SendChatMessageAsync(
|
||||
$"{user.FormatUsername()}, events based around time predictions can't have options", true);
|
||||
return;
|
||||
}
|
||||
|
||||
var optionId = arguments["optionId"].Value.ToLower();
|
||||
var targetOption = targetEvent.Options.FirstOrDefault(x => x.OptionId == optionId);
|
||||
if (targetOption == null)
|
||||
{
|
||||
await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, the option ID you provided does not exist", true);
|
||||
return;
|
||||
}
|
||||
|
||||
targetEvent.Options.Remove(targetOption);
|
||||
await SettingsProvider.SetValueAsJsonObjectAsync(BuiltIn.Keys.KasinoEventData, eventList);
|
||||
await botInstance.SendChatMessageAsync(
|
||||
$"{user.FormatUsername()}, removed option with id {targetOption.OptionId}", true);
|
||||
}
|
||||
}
|
||||
|
||||
public class KasinoGetEventInfo : ICommand
|
||||
{
|
||||
public List<Regex> Patterns =>
|
||||
[
|
||||
new Regex(@"^kasino event (?<event_id>\w+) info$", RegexOptions.IgnoreCase),
|
||||
];
|
||||
|
||||
public string? HelpText => "Get Kasino event info";
|
||||
public UserRight RequiredRight => UserRight.TrueAndHonest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
var settings = await SettingsProvider.GetMultipleValuesAsync([
|
||||
BuiltIn.Keys.KasinoEventData
|
||||
]);
|
||||
var eventId = arguments["event_id"].Value;
|
||||
var eventList = settings[BuiltIn.Keys.KasinoEventData].JsonDeserialize<List<KasinoEventModel>>() ?? [];
|
||||
var targetEvent = eventList.FirstOrDefault(x => x.EventId == eventId);
|
||||
if (targetEvent == null)
|
||||
{
|
||||
await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, this event does not exist", true);
|
||||
return;
|
||||
}
|
||||
|
||||
var response = $"{user.FormatUsername()}, Event ID {targetEvent.EventId} with type {targetEvent.EventType.Humanize()} " +
|
||||
$"which is in state {targetEvent.EventState.Humanize()} and has the following text:" +
|
||||
$"[br]{targetEvent.EventText.TrimStart('/')}";
|
||||
if (targetEvent.EventType == KasinoEventType.WinLose)
|
||||
{
|
||||
response += "[br]Options:";
|
||||
foreach (var option in targetEvent.Options)
|
||||
{
|
||||
response += $"[br]{option.OptionId}: {option.OptionText}";
|
||||
}
|
||||
}
|
||||
|
||||
response += $"[br]Event Announcement Received: {targetEvent.EventAnnouncementReceived?.ToString("o")}";
|
||||
response += $"[br]Selection Time Weighted Payout: {targetEvent.SelectionTimeWeightedPayout}";
|
||||
await botInstance.SendChatMessagesAsync(response.FancySplitMessage(partSeparator: "[br]"), true);
|
||||
}
|
||||
}
|
||||
|
||||
public class KasinoGetEvents : ICommand
|
||||
{
|
||||
public List<Regex> Patterns =>
|
||||
[
|
||||
new Regex(@"^kasino events$", RegexOptions.IgnoreCase),
|
||||
new Regex(@"^kasino event list$", RegexOptions.IgnoreCase),
|
||||
|
||||
];
|
||||
|
||||
public string? HelpText => "Get Kasino events";
|
||||
public UserRight RequiredRight => UserRight.TrueAndHonest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
var settings = await SettingsProvider.GetMultipleValuesAsync([
|
||||
BuiltIn.Keys.KasinoEventData
|
||||
]);
|
||||
var eventList = settings[BuiltIn.Keys.KasinoEventData].JsonDeserialize<List<KasinoEventModel>>() ?? [];
|
||||
|
||||
var response = $"{user.FormatUsername()}, there are {eventList.Count} events in the database";
|
||||
foreach (var targetEvent in eventList)
|
||||
{
|
||||
response += $"[br]{targetEvent.EventId} ({targetEvent.EventState.Humanize()}): {targetEvent.EventText}";
|
||||
}
|
||||
|
||||
await botInstance.SendChatMessagesAsync(response.FancySplitMessage(partSeparator: "[br]"), true);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Humanizer;
|
||||
using Humanizer.Localisation;
|
||||
using KfChatDotNetBot.Extensions;
|
||||
using KfChatDotNetBot.Models;
|
||||
using KfChatDotNetBot.Models.DbModels;
|
||||
@@ -268,4 +267,36 @@ public class AbandonKasinoCommand : ICommand
|
||||
await db.SaveChangesAsync(ctx);
|
||||
await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, Kasino account with ID {gambler.Id} has been marked as abandoned.", true);
|
||||
}
|
||||
}
|
||||
|
||||
[KasinoCommand]
|
||||
public class PocketWatchCommand : ICommand
|
||||
{
|
||||
public List<Regex> Patterns => [
|
||||
new Regex(@"^pocketwatch (?<user_id>\d+)", RegexOptions.IgnoreCase),
|
||||
];
|
||||
public string? HelpText => "Check a user's balance";
|
||||
public UserRight RequiredRight => UserRight.Loser;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
await using var db = new ApplicationDbContext();
|
||||
var targetUser = await db.Users.FirstOrDefaultAsync(u => u.KfId == int.Parse(arguments["user_id"].Value), ctx);
|
||||
if (targetUser == null)
|
||||
{
|
||||
await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, the user ID you gave doesn't exist.", true);
|
||||
return;
|
||||
}
|
||||
|
||||
var targetGambler = await Money.GetGamblerEntityAsync(targetUser.Id, ct: ctx);
|
||||
if (targetGambler == null)
|
||||
{
|
||||
await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, this user is excluded from the kasino", true);
|
||||
return;
|
||||
}
|
||||
|
||||
await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, {targetUser.KfUsername} has {await targetGambler.Balance.FormatKasinoCurrencyAsync()}", true);
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public class KenoCommand : ICommand
|
||||
private const string MatchRevealDisplay = "💠";
|
||||
private const string BlankSpaceDisplay = "⬛";
|
||||
|
||||
private SentMessageTrackerModel _kenoTable;
|
||||
private SentMessageTrackerModel? _kenoTable;
|
||||
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
@@ -97,7 +97,7 @@ public class KenoCommand : ICommand
|
||||
await botInstance.SendChatMessageAsync(
|
||||
$"{user.FormatUsername()}, you [color={colors[BuiltIn.Keys.KiwiFarmsRedColor].Value}]lost {await wager.FormatKasinoCurrencyAsync()}[/color]. Your balance is now: {await newBalance.FormatKasinoCurrencyAsync()}.",
|
||||
true, autoDeleteAfter: cleanupDelay);
|
||||
botInstance.ScheduleMessageAutoDelete(_kenoTable, cleanupDelay);
|
||||
botInstance.ScheduleMessageAutoDelete(_kenoTable ?? throw new Exception("Cannot clean up _kenoTable as it's null"), cleanupDelay);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ public class KenoCommand : ICommand
|
||||
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()}.",
|
||||
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)
|
||||
@@ -141,6 +141,11 @@ public class KenoCommand : ICommand
|
||||
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>();
|
||||
//FIRST FRAME 11111111111111111111111111111
|
||||
for (var frame = 0; frame < 10; frame++) //1 frame per casino number
|
||||
|
||||
@@ -39,8 +39,8 @@ public class Planes : ICommand
|
||||
private const string Water = "🌊";
|
||||
private const string Air = "\u2B1C"; // White square
|
||||
private const string BlankSpace = "⠀"; //need 35?
|
||||
private bool rigged = false;
|
||||
private bool superRigged = false;
|
||||
private bool _rigged;
|
||||
private bool _superRigged;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
@@ -68,21 +68,19 @@ public class Planes : ICommand
|
||||
return;
|
||||
}
|
||||
|
||||
var carrierCount = 6;
|
||||
const int carrierCount = 6;
|
||||
var planesBoard = CreatePlanesBoard(gambler,0);
|
||||
var planesBoard2 = CreatePlanesBoard(gambler);
|
||||
var planesBoard3 = CreatePlanesBoard(gambler);
|
||||
if (rigged)
|
||||
if (_rigged)
|
||||
{
|
||||
planesBoard2 = RigPlanesBoard(planesBoard2, 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 frameLength = 1000.0;
|
||||
const double frameLength = 1000.0;
|
||||
var fullCounter = 0;
|
||||
bool firstBoard = true;
|
||||
var counter = 0;
|
||||
var noseUp = true;
|
||||
var planesDisplay = GetPreGameBoard(-3, planesBoard2, plane, carrierCount, noseUp);
|
||||
var msgId = await botInstance.SendChatMessageAsync(planesDisplay, true);
|
||||
@@ -102,8 +100,7 @@ public class Planes : ICommand
|
||||
*/
|
||||
do
|
||||
{
|
||||
if ((fullCounter-3) > 19) firstBoard = false;
|
||||
counter = (fullCounter - 3) % 20;
|
||||
var counter = (fullCounter - 3) % 20;
|
||||
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(frameLength / 3), ctx);
|
||||
|
||||
@@ -217,20 +214,20 @@ public class Planes : ICommand
|
||||
plane.Gravity();
|
||||
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() &&
|
||||
settings[BuiltIn.Keys.KasinoPlanesTargetedRiggeryVictims].JsonDeserialize<List<int>>()!.Contains(user.KfId))
|
||||
{
|
||||
rigged = true;
|
||||
_rigged = true;
|
||||
}
|
||||
logger.Info($"Switching planes boards. FullCounter: {fullCounter} | Counter: {counter}");
|
||||
planesBoards.RemoveAt(0);
|
||||
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
|
||||
superRigged = true;
|
||||
_superRigged = true;
|
||||
}
|
||||
else if (rigged)
|
||||
else if (_rigged)
|
||||
{
|
||||
planesBoards[1] = RigPlanesBoard(planesBoards[1], 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)
|
||||
{
|
||||
var output = "";
|
||||
int counter;
|
||||
var logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
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,
|
||||
{
|
||||
var useBoard = 1;
|
||||
int counter;
|
||||
if (fullCounter < 23) counter = fullCounter % 23 - 3;
|
||||
else counter = (fullCounter - 3) % 20;
|
||||
//---
|
||||
@@ -404,7 +400,7 @@ public class Planes : ICommand
|
||||
|
||||
}
|
||||
// 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]";
|
||||
}
|
||||
return output;
|
||||
@@ -419,18 +415,13 @@ public class Planes : ICommand
|
||||
{
|
||||
var randomNum = Money.GetRandomNumber(gambler, 1, 100);
|
||||
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
|
||||
{
|
||||
board[row, column] = 2; //multi
|
||||
}
|
||||
board[row, column] = randomNum switch
|
||||
{
|
||||
< 49 => 0,
|
||||
> 79 => 1,
|
||||
_ => 2
|
||||
};
|
||||
}
|
||||
}
|
||||
return board;
|
||||
@@ -438,11 +429,9 @@ public class Planes : ICommand
|
||||
|
||||
private int[,] RigPlanesBoard(int[,] planesBoard, int carrierCount, int fullCounter)
|
||||
{
|
||||
int[,] returnBoard = new int[6,20];
|
||||
int boardCounter = (fullCounter-3) / 20;
|
||||
var spaceToUpdate = 0;
|
||||
bool startUpdating = true;
|
||||
spaceToUpdate = (fullCounter-3) % 20; //how far along is the game into the current board
|
||||
var returnBoard = new int[6,20];
|
||||
bool startUpdating;
|
||||
var spaceToUpdate = (fullCounter-3) % 20; //how far along is the game into the current board
|
||||
if (spaceToUpdate > 0) startUpdating = false;
|
||||
|
||||
for (var row = 0; row < 6; row++)
|
||||
|
||||
Reference in New Issue
Block a user