mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-05-02 04:22:04 -04:00
plinko fix frfrfr (#32)
* 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 * plinko fix frfr this time plinko fix frfr this time * settings fix as requested settings fix as requested * plinko payout fix? not exactly sure why its not correct this should maybe fix it? * Add logger for max win in PlinkoCommand Added logging for maximum win condition in Plinko game. * fix loop and other bugs fix loop and other bugs
This commit is contained in:
@@ -47,7 +47,16 @@ public class PlinkoCommand : ICommand
|
|||||||
{6, 25},
|
{6, 25},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
private static readonly List<(int row, int col)> validPositions = new() //would need to come up with a formula to make this to have user defined difficulty, good luck
|
||||||
|
{
|
||||||
|
(0, 3),
|
||||||
|
(1, 2), (1, 4),
|
||||||
|
(2, 2), (2, 3), (2, 4),
|
||||||
|
(3, 1),(3, 2), (3, 4), (3, 5),
|
||||||
|
(4, 1),(4, 2), (4, 3), (4, 4), (4, 5),
|
||||||
|
(5, 0), (5, 1),(5, 2), (5, 4), (5, 5), (5, 6),
|
||||||
|
(6, 0), (6, 1),(6, 2), (6, 3), (6, 4), (6, 5), (6, 6)
|
||||||
|
};
|
||||||
|
|
||||||
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)
|
||||||
@@ -120,7 +129,7 @@ public class PlinkoCommand : ICommand
|
|||||||
while (ballsNotInPlay.Count > 0 || ballsInPlay.Count > 0)
|
while (ballsNotInPlay.Count > 0 || ballsInPlay.Count > 0)
|
||||||
{
|
{
|
||||||
breakCounter++;
|
breakCounter++;
|
||||||
if (breakCounter >= 1000) throw new Exception("stuck in while loop in plinko");
|
if (breakCounter >= numberOfBalls * 10) throw new Exception("stuck in while loop in plinko");
|
||||||
currentPayout = 0;
|
currentPayout = 0;
|
||||||
if (ballsNotInPlay.Count > 0)
|
if (ballsNotInPlay.Count > 0)
|
||||||
{
|
{
|
||||||
@@ -143,6 +152,7 @@ public class PlinkoCommand : ICommand
|
|||||||
await botInstance.SendChatMessageAsync(
|
await botInstance.SendChatMessageAsync(
|
||||||
$"{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));
|
$"{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));
|
||||||
}
|
}
|
||||||
|
ballsInPlay.RemoveAt(0);
|
||||||
}
|
}
|
||||||
foreach (var ball in ballsInPlay)
|
foreach (var ball in ballsInPlay)
|
||||||
{
|
{
|
||||||
@@ -164,16 +174,7 @@ public class PlinkoCommand : ICommand
|
|||||||
string board = "";
|
string board = "";
|
||||||
bool spaceIsBall = false;
|
bool spaceIsBall = false;
|
||||||
bool spaceIsValid = false;
|
bool spaceIsValid = false;
|
||||||
List<(int row, int col)> validPositions = new() //would need to come up with a formula to make this to have user defined difficulty, good luck
|
|
||||||
{
|
|
||||||
(0, 3),
|
|
||||||
(1, 2), (1, 4),
|
|
||||||
(2, 2), (2, 3), (2, 4),
|
|
||||||
(3, 1), (3,2), (3, 4), (3, 5),
|
|
||||||
(4, 1), (4, 2), (4, 3), (4, 4), (4, 5),
|
|
||||||
(5, 0), (5, 1), (5, 2), (5, 4), (5, 5), (5, 6),
|
|
||||||
(6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6,6)
|
|
||||||
};
|
|
||||||
for (int row = 0; row < DIFFICULTY; row++)
|
for (int row = 0; row < DIFFICULTY; row++)
|
||||||
{
|
{
|
||||||
for (int col = 0; col < DIFFICULTY; col++)
|
for (int col = 0; col < DIFFICULTY; col++)
|
||||||
@@ -212,10 +213,18 @@ public class PlinkoCommand : ICommand
|
|||||||
{
|
{
|
||||||
private RandomShim<StandardRng> RAND = RandomShim.Create(StandardRng.Create());
|
private RandomShim<StandardRng> RAND = RandomShim.Create(StandardRng.Create());
|
||||||
public (int row, int col) POSITION;
|
public (int row, int col) POSITION;
|
||||||
|
private Dictionary<int, List<int>> validColumnsForRow;
|
||||||
public PlinkoBall()
|
public PlinkoBall()
|
||||||
{
|
{
|
||||||
POSITION = (0, 3);
|
POSITION = (0, 3);
|
||||||
|
validColumnsForRow = new Dictionary<int, List<int>>();
|
||||||
|
foreach (var position in validPositions){
|
||||||
|
if (!validColumnsForRow.ContainsKey(position.row)) validColumnsForRow.Add(position.row, new List<int>()
|
||||||
|
{
|
||||||
|
position.col
|
||||||
|
}); //if no current key for that row add it
|
||||||
|
else validColumnsForRow[position.row].Add(position.col);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void Iterate()
|
public void Iterate()
|
||||||
{
|
{
|
||||||
@@ -232,12 +241,11 @@ public class PlinkoCommand : ICommand
|
|||||||
switch (rng)
|
switch (rng)
|
||||||
{
|
{
|
||||||
case >= 0.5:
|
case >= 0.5:
|
||||||
if (!evenrow && Math.Abs(POSITION.col) > POSITION.row / 2) POSITION.col--;
|
if (validColumnsForRow[POSITION.row+1].Contains(POSITION.col-1)) POSITION.col--;
|
||||||
else if (evenrow) POSITION.col--;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case < 0.5:
|
case < 0.5:
|
||||||
if (!evenrow && POSITION.col > POSITION.row / 2) POSITION.col++;
|
if (validColumnsForRow[POSITION.row+1].Contains(POSITION.col+1)) POSITION.col++;
|
||||||
else if (evenrow) POSITION.col++;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Exception("generated an incorrect number");
|
throw new Exception("generated an incorrect number");
|
||||||
@@ -249,4 +257,3 @@ public class PlinkoCommand : ICommand
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user