mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-05-02 12:32:03 -04:00
wheel fix maybe (#10)
* fix dice lose print * dice can now display rigged results * lambchop * removed GetRandomNext * updated lambchop randomness to use GetRandomNumber() * Change lambchop game timeout to 12 seconds * lambchop quickfix * sync * wheel game * new newBalance calculation * wheel quickfix * experimental lambchop fix. Increased wheel animation time. * Wheel fix maybe?
This commit is contained in:
committed by
GitHub
parent
061cbaea9e
commit
85a5eb4dfd
@@ -73,7 +73,7 @@ public class WheelCommand : 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}");
|
||||||
var difficulty = arguments["difficulty"].Success ? Convert.ToString(arguments["difficulty"].Value) : new[] {"low", "medium", "high"}[Money.GetRandomNumber(gambler, 0,3)];
|
var difficulty = arguments["difficulty"].Success ? Convert.ToString(arguments["difficulty"].Value) : new[] {"low", "medium", "high"}[Money.GetRandomNumber(gambler, 0,2)];
|
||||||
if (difficulty.ToLower() is not ("l" or "low" or "m" or "medium" or "h" or "high"))
|
if (difficulty.ToLower() is not ("l" or "low" or "m" or "medium" or "h" or "high"))
|
||||||
{
|
{
|
||||||
await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, unrecognized difficulty selection, please choose between: low, medium, high", true, autoDeleteAfter: cleanupDelay);
|
await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, unrecognized difficulty selection, please choose between: low, medium, high", true, autoDeleteAfter: cleanupDelay);
|
||||||
@@ -116,7 +116,7 @@ public class WheelCommand : ICommand
|
|||||||
double t = (double)i / (stepsToTarget - 1);
|
double t = (double)i / (stepsToTarget - 1);
|
||||||
double easeOut = 1 - Math.Pow(1 - t, 3); // cubic ease-out curve for 'realistic' wheelspin animation
|
double easeOut = 1 - Math.Pow(1 - t, 3); // cubic ease-out curve for 'realistic' wheelspin animation
|
||||||
|
|
||||||
int delay = (int)(MIN_WHEELSPIN_DELAY + easeOut * (MAX_WHEELSPIN_DELAY - MAX_WHEELSPIN_DELAY));
|
int delay = (int)(MIN_WHEELSPIN_DELAY + easeOut * (MAX_WHEELSPIN_DELAY - MIN_WHEELSPIN_DELAY));
|
||||||
await Task.Delay(delay, ctx);
|
await Task.Delay(delay, ctx);
|
||||||
wheel.RotateWheelOnce();
|
wheel.RotateWheelOnce();
|
||||||
await botInstance.KfClient.EditMessageAsync(wheelDisplayMessage.ChatMessageId!.Value,
|
await botInstance.KfClient.EditMessageAsync(wheelDisplayMessage.ChatMessageId!.Value,
|
||||||
@@ -186,7 +186,7 @@ public class Wheel
|
|||||||
|
|
||||||
private void RandomizeInitialState()
|
private void RandomizeInitialState()
|
||||||
{
|
{
|
||||||
int shift = Money.GetRandomNumber(_gambler, 0, 20);
|
int shift = Money.GetRandomNumber(_gambler, 0, 19);
|
||||||
RotateWheel(shift);
|
RotateWheel(shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,7 +207,7 @@ public class Wheel
|
|||||||
public int ComputeGameStepsToTarget(string target)
|
public int ComputeGameStepsToTarget(string target)
|
||||||
{
|
{
|
||||||
// start by first doing 1-3 full rotations of the wheel
|
// start by first doing 1-3 full rotations of the wheel
|
||||||
int fullRotations = Money.GetRandomNumber(_gambler, 1, 4);
|
int fullRotations = Money.GetRandomNumber(_gambler, 1, 3);
|
||||||
int steps = fullRotations * 20;
|
int steps = fullRotations * 20;
|
||||||
// find how many more steps until wheel index 4 (top middle) == target
|
// find how many more steps until wheel index 4 (top middle) == target
|
||||||
int extra = StepsUntilIndex4Match(target);
|
int extra = StepsUntilIndex4Match(target);
|
||||||
|
|||||||
Reference in New Issue
Block a user