mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-05-02 04:22:04 -04:00
plinko update, minor blackjack update (#29)
* Update cleanup delay settings for PlinkoCommand, use plinko delay instead of limbo Update cleanup delay settings for PlinkoCommand, use plinko delay instead of limbo * wait for chat message id update wait for chat message id update * update plinko to fix shit update plinko to fix shit * add underline to final blackjack message add underline to final blackjack message to make it easier to read which game is which when many games are happening at once
This commit is contained in:
@@ -619,7 +619,7 @@ public class BlackjackCommand : ICommand
|
|||||||
var newBalance = await Money.ModifyBalanceAsync(gambler.Id, balanceAdjustment, TransactionSourceEventType.Gambling,
|
var newBalance = await Money.ModifyBalanceAsync(gambler.Id, balanceAdjustment, TransactionSourceEventType.Gambling,
|
||||||
$"Blackjack outcome from wager {wager.Id}", null, ctx);
|
$"Blackjack outcome from wager {wager.Id}", null, ctx);
|
||||||
|
|
||||||
message += $"[B]Net:[/B] {(totalEffect >= 0 ? "+" : "")}{await totalEffect.FormatKasinoCurrencyAsync()} | Balance: {await newBalance.FormatKasinoCurrencyAsync()}";
|
message += $"[u][B]Net:[/B] {(totalEffect >= 0 ? "+" : "")}{await totalEffect.FormatKasinoCurrencyAsync()} | Balance: {await newBalance.FormatKasinoCurrencyAsync()}";
|
||||||
|
|
||||||
await botInstance.SendChatMessageAsync(message, true, autoDeleteAfter: cleanupDelay);
|
await botInstance.SendChatMessageAsync(message, true, autoDeleteAfter: cleanupDelay);
|
||||||
}
|
}
|
||||||
@@ -634,4 +634,4 @@ public class BlackjackCommand : ICommand
|
|||||||
$"{user.FormatUsername()}, your blackjack game timed out and you forfeited {await wager.WagerAmount.FormatKasinoCurrencyAsync()}",
|
$"{user.FormatUsername()}, your blackjack game timed out and you forfeited {await wager.WagerAmount.FormatKasinoCurrencyAsync()}",
|
||||||
true, autoDeleteAfter: cleanupDelay);
|
true, autoDeleteAfter: cleanupDelay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ public class PlinkoCommand : ICommand
|
|||||||
{
|
{
|
||||||
decimal payout = 0;
|
decimal payout = 0;
|
||||||
decimal currentPayout = 0;
|
decimal currentPayout = 0;
|
||||||
Group? number;
|
|
||||||
var settings = await SettingsProvider.GetMultipleValuesAsync([
|
var settings = await SettingsProvider.GetMultipleValuesAsync([
|
||||||
BuiltIn.Keys.KasinoPlinkoCleanupDelay, BuiltIn.Keys.KiwiFarmsGreenColor, BuiltIn.Keys.KiwiFarmsRedColor
|
BuiltIn.Keys.KasinoPlinkoCleanupDelay, BuiltIn.Keys.KiwiFarmsGreenColor, BuiltIn.Keys.KiwiFarmsRedColor
|
||||||
]);
|
]);
|
||||||
@@ -64,11 +63,19 @@ public class PlinkoCommand : ICommand
|
|||||||
var gambler = await Money.GetGamblerEntityAsync(user.Id, ct: ctx);
|
var gambler = await Money.GetGamblerEntityAsync(user.Id, ct: ctx);
|
||||||
if (gambler == null)
|
if (gambler == null)
|
||||||
throw new InvalidOperationException($"Caught a null when retrieving gambler for {user.KfUsername}");
|
throw new InvalidOperationException($"Caught a null when retrieving gambler for {user.KfUsername}");
|
||||||
if (!arguments.TryGetValue("number", out number))
|
int numberOfBalls = 0;
|
||||||
|
if (!arguments.TryGetValue("number", out var number))
|
||||||
{
|
{
|
||||||
number = null;
|
numberOfBalls = 1;
|
||||||
|
}
|
||||||
|
else numberOfBalls = Convert.ToInt32(number.Value);
|
||||||
|
|
||||||
|
if (numberOfBalls < 1 || numberOfBalls > 10)
|
||||||
|
{
|
||||||
|
await botInstance.SendChatMessageAsync(
|
||||||
|
$"{user.FormatUsername()}, you can only play with 1 - 10 balls at a time", true, autoDeleteAfter: cleanupDelay);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
int numberOfBalls = number == null ? 1 : Convert.ToInt32(number.Value);
|
|
||||||
if (gambler.Balance < wager * numberOfBalls)
|
if (gambler.Balance < wager * numberOfBalls)
|
||||||
{
|
{
|
||||||
await botInstance.SendChatMessageAsync(
|
await botInstance.SendChatMessageAsync(
|
||||||
@@ -84,7 +91,7 @@ public class PlinkoCommand : ICommand
|
|||||||
ballsNotInPlay.Add(new PlinkoBall());
|
ballsNotInPlay.Add(new PlinkoBall());
|
||||||
}
|
}
|
||||||
//game starts here
|
//game starts here
|
||||||
int breakCounter = 0
|
int breakCounter = 0;
|
||||||
var plinkoMessageID = await botInstance.SendChatMessageAsync(PlinkoBoardDisplay(ballsInPlay), true, autoDeleteAfter: cleanupDelay);
|
var plinkoMessageID = await botInstance.SendChatMessageAsync(PlinkoBoardDisplay(ballsInPlay), true, autoDeleteAfter: cleanupDelay);
|
||||||
while (plinkoMessageID.ChatMessageId == null && breakCounter < 1000) {
|
while (plinkoMessageID.ChatMessageId == null && breakCounter < 1000) {
|
||||||
await Task.Delay(100);
|
await Task.Delay(100);
|
||||||
@@ -99,8 +106,11 @@ public class PlinkoCommand : ICommand
|
|||||||
breakCounter++;
|
breakCounter++;
|
||||||
if (breakCounter >= 1000) throw new Exception("stuck in while loop in plinko");
|
if (breakCounter >= 1000) throw new Exception("stuck in while loop in plinko");
|
||||||
currentPayout = 0;
|
currentPayout = 0;
|
||||||
ballsInPlay.Add(ballsNotInPlay[0]);
|
if (ballsNotInPlay.Count > 0)
|
||||||
ballsNotInPlay.RemoveAt(0);
|
{
|
||||||
|
ballsInPlay.Add(ballsNotInPlay[0]);
|
||||||
|
ballsNotInPlay.RemoveAt(0);
|
||||||
|
}
|
||||||
await botInstance.KfClient.EditMessageAsync(plinkoMessageID.ChatMessageId!.Value,PlinkoBoardDisplay(ballsInPlay));
|
await botInstance.KfClient.EditMessageAsync(plinkoMessageID.ChatMessageId!.Value,PlinkoBoardDisplay(ballsInPlay));
|
||||||
if (ballsInPlay[0].POSITION.row == DIFFICULTY - 1) //once your ball has reached the bottom calculate the payout
|
if (ballsInPlay[0].POSITION.row == DIFFICULTY - 1) //once your ball has reached the bottom calculate the payout
|
||||||
{
|
{
|
||||||
@@ -109,12 +119,12 @@ public class PlinkoCommand : ICommand
|
|||||||
if (currentPayout > wager)
|
if (currentPayout > wager)
|
||||||
{
|
{
|
||||||
await botInstance.SendChatMessageAsync(
|
await botInstance.SendChatMessageAsync(
|
||||||
$"{user.FormatUsername()}, you [color={settings[BuiltIn.Keys.KiwiFarmsGreenColor].Value!}]win![/color]. Payout: {currentPayout} KKK", true, autoDeleteAfter: TimeSpan.FromSeconds(5));
|
$"{user.FormatUsername()}, you [color={settings[BuiltIn.Keys.KiwiFarmsGreenColor].Value!}]won[/color] ${currentPayout} KKK from a plinko ball worth {wager}!", true, autoDeleteAfter: TimeSpan.FromSeconds(5));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await botInstance.SendChatMessageAsync(
|
await botInstance.SendChatMessageAsync(
|
||||||
$"{user.FormatUsername()}, you [color={settings[BuiltIn.Keys.KiwiFarmsRedColor].Value!}lose. Payout: {currentPayout} KKK", true, autoDeleteAfter: TimeSpan.FromSeconds(5));
|
$"{user.FormatUsername()}, you [color={settings[BuiltIn.Keys.KiwiFarmsRedColor].Value!}lost[/color] ${wager-currentPayout} KKK from a plinko ball worth {wager}.", true, autoDeleteAfter: TimeSpan.FromSeconds(5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (var ball in ballsInPlay)
|
foreach (var ball in ballsInPlay)
|
||||||
@@ -123,10 +133,12 @@ public class PlinkoCommand : ICommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
await Task.Delay(100);
|
await Task.Delay(100);
|
||||||
|
await botInstance.KfClient.EditMessageAsync(plinkoMessageID.ChatMessageId!.Value,PlinkoBoardDisplay(ballsInPlay));
|
||||||
|
await Task.Delay(100);
|
||||||
|
|
||||||
}
|
}
|
||||||
var newBalance = await Money.NewWagerAsync(gambler.Id, wager*numberOfBalls, payout, WagerGame.Plinko, ct: ctx);
|
var newBalance = await Money.NewWagerAsync(gambler.Id, wager*numberOfBalls, payout, WagerGame.Plinko, ct: ctx);
|
||||||
await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, you won ${payout} KKK from {numberOfBalls} plinko balls worth ${wager} KKK. Balance: ${newBalance} KKK", true, autoDeleteAfter: cleanupDelay);
|
await botInstance.SendChatMessageAsync($"[u]{user.FormatUsername()}, you won ${payout} KKK from {numberOfBalls} plinko balls worth ${wager} KKK. Balance: ${newBalance} KKK", true, autoDeleteAfter: cleanupDelay);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,6 +185,8 @@ public class PlinkoCommand : ICommand
|
|||||||
if (!spaceIsValid) board += NULLSPACE;
|
if (!spaceIsValid) board += NULLSPACE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
board += "[br]";
|
||||||
}
|
}
|
||||||
|
|
||||||
return board;
|
return board;
|
||||||
|
|||||||
Reference in New Issue
Block a user