move or stay almost complete
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -14,28 +15,54 @@ namespace NadekoBot.Modules.Gambling
|
||||
//public partial class Gambling
|
||||
//{
|
||||
// [Group]
|
||||
// public class MoveOrStayCommands : NadekoSubmodule
|
||||
// public class Lucky7Commands : NadekoSubmodule
|
||||
// {
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// [OwnerOnly]
|
||||
// public async Task MoveOrStayTest()
|
||||
// public async Task Lucky7Test(uint tests)
|
||||
// {
|
||||
// //test 1, just stop on second one
|
||||
// if (tests <= 0)
|
||||
// return;
|
||||
|
||||
// //test 2, stop when winning
|
||||
// var dict = new Dictionary<float, int>();
|
||||
// var totalWon = 0;
|
||||
// for (var i = 0; i < tests; i++)
|
||||
// {
|
||||
// var g = new Lucky7Game(10);
|
||||
// while (!g.Ended)
|
||||
// {
|
||||
// if (g.CurrentPosition == 0)
|
||||
// g.Stay();
|
||||
// else
|
||||
// g.Move();
|
||||
// }
|
||||
// totalWon += (int)(g.CurrentMultiplier * g.Bet);
|
||||
// if (!dict.ContainsKey(g.CurrentMultiplier))
|
||||
// dict.Add(g.CurrentMultiplier, 0);
|
||||
|
||||
// dict[g.CurrentMultiplier] ++;
|
||||
|
||||
// }
|
||||
|
||||
// await Context.Channel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
||||
// .WithTitle("Move Or Stay test")
|
||||
// .WithDescription(string.Join("\n",
|
||||
// dict.Select(x => $"x{x.Key} occured {x.Value} times {x.Value * 1.0f / tests * 100:F2}%")))
|
||||
// .WithFooter(
|
||||
// efb => efb.WithText($"Total Bet: {tests * 10} | Payout: {totalWon} | {totalWon *1.0f / tests * 10}%")));
|
||||
// }
|
||||
|
||||
// private static readonly ConcurrentDictionary<ulong, MoveOrStayGame> _games = new ConcurrentDictionary<ulong, MoveOrStayGame>();
|
||||
// private static readonly ConcurrentDictionary<ulong, Lucky7Game> _games =
|
||||
// new ConcurrentDictionary<ulong, Lucky7Game>();
|
||||
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task MoveOrStay(int bet)
|
||||
// public async Task Lucky7(int bet)
|
||||
// {
|
||||
// if (bet < 4)
|
||||
// return;
|
||||
// var game = new MoveOrStayGame(bet);
|
||||
// var game = new Lucky7Game(bet);
|
||||
// if (!_games.TryAdd(Context.User.Id, game))
|
||||
// {
|
||||
// await ReplyAsync("You're already betting on move or stay.").ConfigureAwait(false);
|
||||
@@ -44,14 +71,15 @@ namespace NadekoBot.Modules.Gambling
|
||||
|
||||
// if (!await CurrencyHandler.RemoveCurrencyAsync(Context.User, "MoveOrStay bet", bet, false))
|
||||
// {
|
||||
// await ReplyAsync("You don't have enough money");
|
||||
// _games.TryRemove(Context.User.Id, out game);
|
||||
// await ReplyConfirmLocalized("not_enough", CurrencySign).ConfigureAwait(false);
|
||||
// return;
|
||||
// }
|
||||
// await Context.Channel.EmbedAsync(GetGameState(game),
|
||||
// await Context.Channel.EmbedAsync(GetGameState(game),
|
||||
// string.Format("{0} rolled {1}.", Context.User, game.Rolled)).ConfigureAwait(false);
|
||||
// }
|
||||
|
||||
// public enum Mors
|
||||
// public enum MoveOrStay
|
||||
// {
|
||||
// Move = 1,
|
||||
// M = 1,
|
||||
@@ -61,38 +89,40 @@ namespace NadekoBot.Modules.Gambling
|
||||
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task MoveOrStay(Mors action)
|
||||
// public async Task Lucky7(MoveOrStay action)
|
||||
// {
|
||||
// MoveOrStayGame game;
|
||||
// Lucky7Game game;
|
||||
// if (!_games.TryGetValue(Context.User.Id, out game))
|
||||
// {
|
||||
// await ReplyAsync("You're not betting on move or stay.").ConfigureAwait(false);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (action == Mors.Move)
|
||||
// if (action == MoveOrStay.Move)
|
||||
// {
|
||||
// game.Move();
|
||||
// await Context.Channel.EmbedAsync(GetGameState(game), string.Format("{0} rolled {1}.", Context.User, game.Rolled)).ConfigureAwait(false); if (game.Ended)
|
||||
// await Context.Channel.EmbedAsync(GetGameState(game),
|
||||
// string.Format("{0} rolled {1}.", Context.User, game.Rolled)).ConfigureAwait(false);
|
||||
// if (game.Ended)
|
||||
// _games.TryRemove(Context.User.Id, out game);
|
||||
// }
|
||||
// else if (action == Mors.Stay)
|
||||
// else if (action == MoveOrStay.Stay)
|
||||
// {
|
||||
// var won = game.Stay();
|
||||
// await CurrencyHandler.AddCurrencyAsync(Context.User, "MoveOrStay stay", won, false)
|
||||
// .ConfigureAwait(false);
|
||||
// _games.TryRemove(Context.User.Id, out game);
|
||||
// await ReplyAsync(string.Format("You've finished with {0}",
|
||||
// won + CurrencySign))
|
||||
// await ReplyAsync(string.Format("You've finished with {0}",
|
||||
// won + CurrencySign))
|
||||
// .ConfigureAwait(false);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// }
|
||||
|
||||
// private EmbedBuilder GetGameState(MoveOrStayGame game)
|
||||
// private EmbedBuilder GetGameState(Lucky7Game game)
|
||||
// {
|
||||
// var arr = MoveOrStayGame.Winnings.ToArray();
|
||||
// var arr = Lucky7Game.Winnings.ToArray();
|
||||
// var sb = new StringBuilder();
|
||||
// for (var i = 0; i < arr.Length; i++)
|
||||
// {
|
||||
@@ -110,18 +140,18 @@ namespace NadekoBot.Modules.Gambling
|
||||
// }
|
||||
|
||||
// return new EmbedBuilder().WithOkColor()
|
||||
// .WithTitle("Move or Stay")
|
||||
// .WithTitle("Lucky7")
|
||||
// .WithDescription(sb.ToString())
|
||||
// .AddField(efb => efb.WithName("Bet")
|
||||
// .WithValue(game.Bet.ToString())
|
||||
// .WithIsInline(true))
|
||||
// .WithValue(game.Bet.ToString())
|
||||
// .WithIsInline(true))
|
||||
// .AddField(efb => efb.WithName("Current Value")
|
||||
// .WithValue((game.CurrentMultiplier * game.Bet).ToString(_cultureInfo))
|
||||
// .WithIsInline(true));
|
||||
// .WithValue((game.CurrentMultiplier * game.Bet).ToString(_cultureInfo))
|
||||
// .WithIsInline(true));
|
||||
// }
|
||||
// }
|
||||
|
||||
// public class MoveOrStayGame
|
||||
// public class Lucky7Game
|
||||
// {
|
||||
// public int Bet { get; }
|
||||
// public bool Ended { get; private set; }
|
||||
@@ -130,13 +160,13 @@ namespace NadekoBot.Modules.Gambling
|
||||
// public int Rolled { get; private set; }
|
||||
// public float CurrentMultiplier => Winnings[CurrentPosition];
|
||||
// private readonly NadekoRandom _rng = new NadekoRandom();
|
||||
|
||||
|
||||
// public static readonly ImmutableArray<float> Winnings = new[]
|
||||
// {
|
||||
// 1.5f, 0.75f, 1f, 0.5f, 0.25f, 0.25f, 2.5f, 0f, 0f
|
||||
// 1.2f, 0.8f, 0.75f, 0.90f, 0.7f, 0.5f, 1.8f, 0f, 0f
|
||||
// }.ToImmutableArray();
|
||||
|
||||
// public MoveOrStayGame(int bet)
|
||||
// public Lucky7Game(int bet)
|
||||
// {
|
||||
// Bet = bet;
|
||||
// Move();
|
||||
@@ -150,7 +180,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
// Rolled = _rng.Next(1, 4);
|
||||
// CurrentPosition += Rolled;
|
||||
|
||||
// if (CurrentPosition >= 7)
|
||||
// if (CurrentPosition >= 6)
|
||||
// Ended = true;
|
||||
// }
|
||||
|
||||
|
Reference in New Issue
Block a user