From 9adb5a99063c0229d6ba5554cae42d635b66b94e Mon Sep 17 00:00:00 2001 From: Toastie Date: Sun, 12 May 2024 19:29:23 +1200 Subject: [PATCH] Removed Ellie.Econ --- src/Ellie.Econ/Deck/Deck.cs | 309 ------------------ src/Ellie.Econ/Deck/NewCard.cs | 5 - src/Ellie.Econ/Deck/NewDeck.cs | 54 --- .../MultipleRegularDeck.cs | 28 -- src/Ellie.Econ/Deck/Regular/RegularCard.cs | 4 - src/Ellie.Econ/Deck/Regular/RegularDeck.cs | 15 - .../Deck/Regular/RegularDeckExtensions.cs | 56 ---- src/Ellie.Econ/Deck/Regular/RegularSuit.cs | 9 - src/Ellie.Econ/Deck/Regular/RegularValue.cs | 18 - src/Ellie.Econ/Ellie.Econ.csproj | 13 - .../Gambling/Betdraw/BetdrawColorGuess.cs | 7 - .../Gambling/Betdraw/BetdrawGame.cs | 86 ----- .../Gambling/Betdraw/BetdrawResult.cs | 9 - .../Gambling/Betdraw/BetdrawResultType.cs | 7 - .../Gambling/Betdraw/BetdrawValueGuess.cs | 7 - .../Gambling/Betflip/BetflipGame.cs | 33 -- .../Gambling/Betflip/BetflipResult.cs | 8 - .../Gambling/Betroll/BetrollGame.cs | 42 --- .../Gambling/Betroll/BetrollResult.cs | 9 - src/Ellie.Econ/Gambling/Rps/RpsGame.cs | 75 ----- src/Ellie.Econ/Gambling/Slot/SlotGame.cs | 116 ------- src/Ellie.Econ/Gambling/Slot/SlotResult.cs | 9 - src/Ellie.Econ/Gambling/Wof/LuLaResult.cs | 9 - src/Ellie.Econ/Gambling/Wof/WofGame.cs | 34 -- src/Ellie.Econ/GlobalUsings.cs | 1 - 25 files changed, 963 deletions(-) delete mode 100644 src/Ellie.Econ/Deck/Deck.cs delete mode 100644 src/Ellie.Econ/Deck/NewCard.cs delete mode 100644 src/Ellie.Econ/Deck/NewDeck.cs delete mode 100644 src/Ellie.Econ/Deck/Regular/MultipleRegularDeck/MultipleRegularDeck.cs delete mode 100644 src/Ellie.Econ/Deck/Regular/RegularCard.cs delete mode 100644 src/Ellie.Econ/Deck/Regular/RegularDeck.cs delete mode 100644 src/Ellie.Econ/Deck/Regular/RegularDeckExtensions.cs delete mode 100644 src/Ellie.Econ/Deck/Regular/RegularSuit.cs delete mode 100644 src/Ellie.Econ/Deck/Regular/RegularValue.cs delete mode 100644 src/Ellie.Econ/Ellie.Econ.csproj delete mode 100644 src/Ellie.Econ/Gambling/Betdraw/BetdrawColorGuess.cs delete mode 100644 src/Ellie.Econ/Gambling/Betdraw/BetdrawGame.cs delete mode 100644 src/Ellie.Econ/Gambling/Betdraw/BetdrawResult.cs delete mode 100644 src/Ellie.Econ/Gambling/Betdraw/BetdrawResultType.cs delete mode 100644 src/Ellie.Econ/Gambling/Betdraw/BetdrawValueGuess.cs delete mode 100644 src/Ellie.Econ/Gambling/Betflip/BetflipGame.cs delete mode 100644 src/Ellie.Econ/Gambling/Betflip/BetflipResult.cs delete mode 100644 src/Ellie.Econ/Gambling/Betroll/BetrollGame.cs delete mode 100644 src/Ellie.Econ/Gambling/Betroll/BetrollResult.cs delete mode 100644 src/Ellie.Econ/Gambling/Rps/RpsGame.cs delete mode 100644 src/Ellie.Econ/Gambling/Slot/SlotGame.cs delete mode 100644 src/Ellie.Econ/Gambling/Slot/SlotResult.cs delete mode 100644 src/Ellie.Econ/Gambling/Wof/LuLaResult.cs delete mode 100644 src/Ellie.Econ/Gambling/Wof/WofGame.cs delete mode 100644 src/Ellie.Econ/GlobalUsings.cs diff --git a/src/Ellie.Econ/Deck/Deck.cs b/src/Ellie.Econ/Deck/Deck.cs deleted file mode 100644 index 78f5dd0..0000000 --- a/src/Ellie.Econ/Deck/Deck.cs +++ /dev/null @@ -1,309 +0,0 @@ -#nullable disable -namespace Ellie.Econ; - -public class Deck -{ - public enum CardSuit - { - Spades = 1, - Hearts = 2, - Diamonds = 3, - Clubs = 4 - } - - private static readonly Dictionary _cardNames = new() - { - { 1, "Ace" }, - { 2, "Two" }, - { 3, "Three" }, - { 4, "Four" }, - { 5, "Five" }, - { 6, "Six" }, - { 7, "Seven" }, - { 8, "Eight" }, - { 9, "Nine" }, - { 10, "Ten" }, - { 11, "Jack" }, - { 12, "Queen" }, - { 13, "King" } - }; - - private static Dictionary, bool>> handValues; - - public List CardPool { get; set; } - private readonly Random _r = new EllieRandom(); - - static Deck() - => InitHandValues(); - - /// - /// Creates a new instance of the BlackJackGame, this allows you to create multiple games running at one time. - /// - public Deck() - => RefillPool(); - - /// - /// Restart the game of blackjack. It will only refill the pool for now. Probably wont be used, unless you want to have - /// only 1 bjg running at one time, - /// then you will restart the same game every time. - /// - public void Restart() - => RefillPool(); - - /// - /// Removes all cards from the pool and refills the pool with all of the possible cards. NOTE: I think this is too - /// expensive. - /// We should probably make it so it copies another premade list with all the cards, or something. - /// - protected virtual void RefillPool() - { - CardPool = new(52); - //foreach suit - for (var j = 1; j < 14; j++) - // and number - for (var i = 1; i < 5; i++) - //generate a card of that suit and number and add it to the pool - - // the pool will go from ace of spades,hears,diamonds,clubs all the way to the king of spades. hearts, ... - CardPool.Add(new((CardSuit)i, j)); - } - - /// - /// Take a card from the pool, you either take it from the top if the deck is shuffled, or from a random place if the - /// deck is in the default order. - /// - /// A card from the pool - public Card Draw() - { - if (CardPool.Count == 0) - Restart(); - //you can either do this if your deck is not shuffled - - var num = _r.Next(0, CardPool.Count); - var c = CardPool[num]; - CardPool.RemoveAt(num); - return c; - - // if you want to shuffle when you fill, then take the first one - /* - Card c = cardPool[0]; - cardPool.RemoveAt(0); - return c; - */ - } - - /// - /// Shuffles the deck. Use this if you want to take cards from the top of the deck, instead of randomly. See DrawACard - /// method. - /// - private void Shuffle() - { - if (CardPool.Count <= 1) - return; - var orderedPool = CardPool.Shuffle(); - CardPool ??= orderedPool.ToList(); - } - - public override string ToString() - => string.Concat(CardPool.Select(c => c.ToString())) + Environment.NewLine; - - private static void InitHandValues() - { - bool HasPair(List cards) - { - return cards.GroupBy(card => card.Number).Count(group => group.Count() == 2) == 1; - } - - bool IsPair(List cards) - { - return cards.GroupBy(card => card.Number).Count(group => group.Count() == 3) == 0 && HasPair(cards); - } - - bool IsTwoPair(List cards) - { - return cards.GroupBy(card => card.Number).Count(group => group.Count() == 2) == 2; - } - - bool IsStraight(List cards) - { - if (cards.GroupBy(card => card.Number).Count() != cards.Count()) - return false; - var toReturn = cards.Max(card => card.Number) - cards.Min(card => card.Number) == 4; - if (toReturn || cards.All(c => c.Number != 1)) - return toReturn; - - var newCards = cards.Select(c => c.Number == 1 ? new(c.Suit, 14) : c).ToArray(); - return newCards.Max(card => card.Number) - newCards.Min(card => card.Number) == 4; - } - - bool HasThreeOfKind(List cards) - { - return cards.GroupBy(card => card.Number).Any(group => group.Count() == 3); - } - - bool IsThreeOfKind(List cards) - { - return HasThreeOfKind(cards) && !HasPair(cards); - } - - bool IsFlush(List cards) - { - return cards.GroupBy(card => card.Suit).Count() == 1; - } - - bool IsFourOfKind(List cards) - { - return cards.GroupBy(card => card.Number).Any(group => group.Count() == 4); - } - - bool IsFullHouse(List cards) - { - return HasPair(cards) && HasThreeOfKind(cards); - } - - bool HasStraightFlush(List cards) - { - return IsFlush(cards) && IsStraight(cards); - } - - bool IsRoyalFlush(List cards) - { - return cards.Min(card => card.Number) == 1 - && cards.Max(card => card.Number) == 13 - && HasStraightFlush(cards); - } - - bool IsStraightFlush(List cards) - { - return HasStraightFlush(cards) && !IsRoyalFlush(cards); - } - - handValues = new() - { - { "Royal Flush", IsRoyalFlush }, - { "Straight Flush", IsStraightFlush }, - { "Four Of A Kind", IsFourOfKind }, - { "Full House", IsFullHouse }, - { "Flush", IsFlush }, - { "Straight", IsStraight }, - { "Three Of A Kind", IsThreeOfKind }, - { "Two Pairs", IsTwoPair }, - { "A Pair", IsPair } - }; - } - - public static string GetHandValue(List cards) - { - if (handValues is null) - InitHandValues(); - - foreach (var kvp in handValues.Where(x => x.Value(cards))) - return kvp.Key; - return "High card " + (cards.FirstOrDefault(c => c.Number == 1)?.GetValueText() ?? cards.Max().GetValueText()); - } - - public class Card : IComparable - { - private static readonly IReadOnlyDictionary _suitToSuitChar = new Dictionary - { - { CardSuit.Diamonds, "♦" }, - { CardSuit.Clubs, "♣" }, - { CardSuit.Spades, "♠" }, - { CardSuit.Hearts, "♥" } - }; - - private static readonly IReadOnlyDictionary _suitCharToSuit = new Dictionary - { - { "♦", CardSuit.Diamonds }, - { "d", CardSuit.Diamonds }, - { "♣", CardSuit.Clubs }, - { "c", CardSuit.Clubs }, - { "♠", CardSuit.Spades }, - { "s", CardSuit.Spades }, - { "♥", CardSuit.Hearts }, - { "h", CardSuit.Hearts } - }; - - private static readonly IReadOnlyDictionary _numberCharToNumber = new Dictionary - { - { 'a', 1 }, - { '2', 2 }, - { '3', 3 }, - { '4', 4 }, - { '5', 5 }, - { '6', 6 }, - { '7', 7 }, - { '8', 8 }, - { '9', 9 }, - { 't', 10 }, - { 'j', 11 }, - { 'q', 12 }, - { 'k', 13 } - }; - - public CardSuit Suit { get; } - public int Number { get; } - - public string FullName - { - get - { - var str = string.Empty; - - if (Number is <= 10 and > 1) - str += "_" + Number; - else - str += GetValueText().ToLowerInvariant(); - return str + "_of_" + Suit.ToString().ToLowerInvariant(); - } - } - - private readonly string[] _regIndicators = - { - "🇦", ":two:", ":three:", ":four:", ":five:", ":six:", ":seven:", ":eight:", ":nine:", ":keycap_ten:", - "🇯", "🇶", "🇰" - }; - - public Card(CardSuit s, int cardNum) - { - Suit = s; - Number = cardNum; - } - - public string GetValueText() - => _cardNames[Number]; - - public override string ToString() - => _cardNames[Number] + " Of " + Suit; - - public int CompareTo(object obj) - { - if (obj is not Card card) - return 0; - return Number - card.Number; - } - - public static Card Parse(string input) - { - if (string.IsNullOrWhiteSpace(input)) - throw new ArgumentNullException(nameof(input)); - - if (input.Length != 2 - || !_numberCharToNumber.TryGetValue(input[0], out var n) - || !_suitCharToSuit.TryGetValue(input[1].ToString(), out var s)) - throw new ArgumentException("Invalid input", nameof(input)); - - return new(s, n); - } - - public string GetEmojiString() - { - var str = string.Empty; - - str += _regIndicators[Number - 1]; - str += _suitToSuitChar[Suit]; - - return str; - } - } -} \ No newline at end of file diff --git a/src/Ellie.Econ/Deck/NewCard.cs b/src/Ellie.Econ/Deck/NewCard.cs deleted file mode 100644 index 4a091a4..0000000 --- a/src/Ellie.Econ/Deck/NewCard.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace Ellie.Econ; - -public abstract record class NewCard(TSuit Suit, TValue Value) - where TSuit : struct, Enum - where TValue : struct, Enum; \ No newline at end of file diff --git a/src/Ellie.Econ/Deck/NewDeck.cs b/src/Ellie.Econ/Deck/NewDeck.cs deleted file mode 100644 index a71406c..0000000 --- a/src/Ellie.Econ/Deck/NewDeck.cs +++ /dev/null @@ -1,54 +0,0 @@ -namespace Ellie.Econ; - -public abstract class NewDeck - where TCard: NewCard - where TSuit : struct, Enum - where TValue : struct, Enum -{ - protected static readonly TSuit[] _suits = Enum.GetValues(); - protected static readonly TValue[] _values = Enum.GetValues(); - - public virtual int CurrentCount - => _cards.Count; - - public virtual int TotalCount { get; } - - protected readonly LinkedList _cards = new(); - public NewDeck() - { - TotalCount = _suits.Length * _values.Length; - } - - public virtual TCard? Draw() - { - var first = _cards.First; - if (first is not null) - { - _cards.RemoveFirst(); - return first.Value; - } - - return null; - } - - public virtual TCard? Peek(int x = 0) - { - var card = _cards.First; - for (var i = 0; i < x; i++) - { - card = card?.Next; - } - - return card?.Value; - } - - public virtual void Shuffle() - { - var cards = _cards.ToList(); - var newCards = cards.Shuffle(); - - _cards.Clear(); - foreach (var card in newCards) - _cards.AddFirst(card); - } -} \ No newline at end of file diff --git a/src/Ellie.Econ/Deck/Regular/MultipleRegularDeck/MultipleRegularDeck.cs b/src/Ellie.Econ/Deck/Regular/MultipleRegularDeck/MultipleRegularDeck.cs deleted file mode 100644 index 2a7e7df..0000000 --- a/src/Ellie.Econ/Deck/Regular/MultipleRegularDeck/MultipleRegularDeck.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Ellie.Econ; - -public class MultipleRegularDeck : NewDeck -{ - private int Decks { get; } - - public override int TotalCount { get; } - - public MultipleRegularDeck(int decks = 1) - { - if (decks < 1) - throw new ArgumentOutOfRangeException(nameof(decks), "Has to be more than 0"); - - Decks = decks; - TotalCount = base.TotalCount * decks; - - for (var i = 0; i < Decks; i++) - { - foreach (var suit in _suits) - { - foreach (var val in _values) - { - _cards.AddLast((RegularCard)Activator.CreateInstance(typeof(RegularCard), suit, val)!); - } - } - } - } -} \ No newline at end of file diff --git a/src/Ellie.Econ/Deck/Regular/RegularCard.cs b/src/Ellie.Econ/Deck/Regular/RegularCard.cs deleted file mode 100644 index 337a1ff..0000000 --- a/src/Ellie.Econ/Deck/Regular/RegularCard.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace Ellie.Econ; - -public sealed record class RegularCard(RegularSuit Suit, RegularValue Value) - : NewCard(Suit, Value); \ No newline at end of file diff --git a/src/Ellie.Econ/Deck/Regular/RegularDeck.cs b/src/Ellie.Econ/Deck/Regular/RegularDeck.cs deleted file mode 100644 index 6997623..0000000 --- a/src/Ellie.Econ/Deck/Regular/RegularDeck.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace Ellie.Econ; - -public sealed class RegularDeck : NewDeck -{ - public RegularDeck() - { - foreach (var suit in _suits) - { - foreach (var val in _values) - { - _cards.AddLast((RegularCard)Activator.CreateInstance(typeof(RegularCard), suit, val)!); - } - } - } -} \ No newline at end of file diff --git a/src/Ellie.Econ/Deck/Regular/RegularDeckExtensions.cs b/src/Ellie.Econ/Deck/Regular/RegularDeckExtensions.cs deleted file mode 100644 index 98c880c..0000000 --- a/src/Ellie.Econ/Deck/Regular/RegularDeckExtensions.cs +++ /dev/null @@ -1,56 +0,0 @@ -namespace Ellie.Econ; - -public static class RegularDeckExtensions -{ - public static string GetEmoji(this RegularSuit suit) - => suit switch - { - RegularSuit.Hearts => "♥️", - RegularSuit.Spades => "♠️", - RegularSuit.Diamonds => "♦️", - _ => "♣️", - }; - - public static string GetEmoji(this RegularValue value) - => value switch - { - RegularValue.Ace => "🇦", - RegularValue.Two => "2️⃣", - RegularValue.Three => "3️⃣", - RegularValue.Four => "4️⃣", - RegularValue.Five => "5️⃣", - RegularValue.Six => "6️⃣", - RegularValue.Seven => "7️⃣", - RegularValue.Eight => "8️⃣", - RegularValue.Nine => "9️⃣", - RegularValue.Ten => "🔟", - RegularValue.Jack => "🇯", - RegularValue.Queen => "🇶", - _ => "🇰", - }; - - public static string GetEmoji(this RegularCard card) - => $"{card.Value.GetEmoji()} {card.Suit.GetEmoji()}"; - - public static string GetName(this RegularValue value) - => value.ToString(); - - public static string GetName(this RegularSuit suit) - => suit.ToString(); - - public static string GetName(this RegularCard card) - => $"{card.Value.ToString()} of {card.Suit.GetName()}"; -} - - - - - - - - - - - - - diff --git a/src/Ellie.Econ/Deck/Regular/RegularSuit.cs b/src/Ellie.Econ/Deck/Regular/RegularSuit.cs deleted file mode 100644 index dc4167b..0000000 --- a/src/Ellie.Econ/Deck/Regular/RegularSuit.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Ellie.Econ; - -public enum RegularSuit -{ - Hearts, - Diamonds, - Clubs, - Spades -} \ No newline at end of file diff --git a/src/Ellie.Econ/Deck/Regular/RegularValue.cs b/src/Ellie.Econ/Deck/Regular/RegularValue.cs deleted file mode 100644 index 8aa9171..0000000 --- a/src/Ellie.Econ/Deck/Regular/RegularValue.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace Ellie.Econ; - -public enum RegularValue -{ - Ace = 1, - Two = 2, - Three = 3, - Four = 4, - Five = 5, - Six = 6, - Seven = 7, - Eight = 8, - Nine = 9, - Ten = 10, - Jack = 12, - Queen = 13, - King = 14, -} \ No newline at end of file diff --git a/src/Ellie.Econ/Ellie.Econ.csproj b/src/Ellie.Econ/Ellie.Econ.csproj deleted file mode 100644 index 038763e..0000000 --- a/src/Ellie.Econ/Ellie.Econ.csproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - net6.0 - enable - enable - - - - - - - diff --git a/src/Ellie.Econ/Gambling/Betdraw/BetdrawColorGuess.cs b/src/Ellie.Econ/Gambling/Betdraw/BetdrawColorGuess.cs deleted file mode 100644 index 7ecd3bd..0000000 --- a/src/Ellie.Econ/Gambling/Betdraw/BetdrawColorGuess.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Ellie.Econ.Gambling.Betdraw; - -public enum BetdrawColorGuess -{ - Red, - Black -} \ No newline at end of file diff --git a/src/Ellie.Econ/Gambling/Betdraw/BetdrawGame.cs b/src/Ellie.Econ/Gambling/Betdraw/BetdrawGame.cs deleted file mode 100644 index d52ae43..0000000 --- a/src/Ellie.Econ/Gambling/Betdraw/BetdrawGame.cs +++ /dev/null @@ -1,86 +0,0 @@ -using Serilog; - -namespace Ellie.Econ.Gambling.Betdraw; - -public sealed class BetdrawGame -{ - private static readonly EllieRandom _rng = new(); - private readonly RegularDeck _deck; - - private const decimal SINGLE_GUESS_MULTI = 2.075M; - private const decimal DOUBLE_GUESS_MULTI = 4.15M; - - public BetdrawGame() - { - _deck = new RegularDeck(); - } - - public BetdrawResult Draw(BetdrawValueGuess? val, BetdrawColorGuess? col, decimal amount) - { - if (val is null && col is null) - throw new ArgumentNullException(nameof(val)); - - var card = _deck.Peek(_rng.Next(0, 52))!; - - var realVal = (int)card.Value < 7 - ? BetdrawValueGuess.Low - : BetdrawValueGuess.High; - - var realCol = card.Suit is RegularSuit.Diamonds or RegularSuit.Hearts - ? BetdrawColorGuess.Red - : BetdrawColorGuess.Black; - - // if card is 7, autoloss - if (card.Value == RegularValue.Seven) - { - return new() - { - Won = 0M, - Multiplier = 0M, - ResultType = BetdrawResultType.Lose, - Card = card, - }; - } - - byte win = 0; - if (val is BetdrawValueGuess valGuess) - { - if (realVal != valGuess) - return new() - { - Won = 0M, - Multiplier = 0M, - ResultType = BetdrawResultType.Lose, - Card = card - }; - - ++win; - } - - if (col is BetdrawColorGuess colGuess) - { - if (realCol != colGuess) - return new() - { - Won = 0M, - Multiplier = 0M, - ResultType = BetdrawResultType.Lose, - Card = card - }; - - ++win; - } - - var multi = win == 1 - ? SINGLE_GUESS_MULTI - : DOUBLE_GUESS_MULTI; - - return new() - { - Won = amount * multi, - Multiplier = multi, - ResultType = BetdrawResultType.Win, - Card = card - }; - } -} \ No newline at end of file diff --git a/src/Ellie.Econ/Gambling/Betdraw/BetdrawResult.cs b/src/Ellie.Econ/Gambling/Betdraw/BetdrawResult.cs deleted file mode 100644 index 82661ac..0000000 --- a/src/Ellie.Econ/Gambling/Betdraw/BetdrawResult.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Ellie.Econ.Gambling.Betdraw; - -public readonly struct BetdrawResult -{ - public decimal Won { get; init; } - public decimal Multiplier { get; init; } - public BetdrawResultType ResultType { get; init; } - public RegularCard Card { get; init; } -} \ No newline at end of file diff --git a/src/Ellie.Econ/Gambling/Betdraw/BetdrawResultType.cs b/src/Ellie.Econ/Gambling/Betdraw/BetdrawResultType.cs deleted file mode 100644 index 371b8fa..0000000 --- a/src/Ellie.Econ/Gambling/Betdraw/BetdrawResultType.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Ellie.Econ.Gambling.Betdraw; - -public enum BetdrawResultType -{ - Win, - Lose -} \ No newline at end of file diff --git a/src/Ellie.Econ/Gambling/Betdraw/BetdrawValueGuess.cs b/src/Ellie.Econ/Gambling/Betdraw/BetdrawValueGuess.cs deleted file mode 100644 index caf2a14..0000000 --- a/src/Ellie.Econ/Gambling/Betdraw/BetdrawValueGuess.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Ellie.Econ.Gambling.Betdraw; - -public enum BetdrawValueGuess -{ - High, - Low, -} \ No newline at end of file diff --git a/src/Ellie.Econ/Gambling/Betflip/BetflipGame.cs b/src/Ellie.Econ/Gambling/Betflip/BetflipGame.cs deleted file mode 100644 index d6d26aa..0000000 --- a/src/Ellie.Econ/Gambling/Betflip/BetflipGame.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace Ellie.Econ.Gambling; - -public sealed class BetflipGame -{ - private readonly decimal _winMulti; - private static readonly EllieRandom _rng = new EllieRandom(); - - public BetflipGame(decimal winMulti) - { - _winMulti = winMulti; - } - - public BetflipResult Flip(byte guess, decimal amount) - { - var side = (byte)_rng.Next(0, 2); - if (side == guess) - { - return new BetflipResult() - { - Side = side, - Won = amount * _winMulti, - Multiplier = _winMulti - }; - } - - return new BetflipResult() - { - Side = side, - Won = 0, - Multiplier = 0, - }; - } -} \ No newline at end of file diff --git a/src/Ellie.Econ/Gambling/Betflip/BetflipResult.cs b/src/Ellie.Econ/Gambling/Betflip/BetflipResult.cs deleted file mode 100644 index 8763f50..0000000 --- a/src/Ellie.Econ/Gambling/Betflip/BetflipResult.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Ellie.Econ.Gambling; - -public readonly struct BetflipResult -{ - public decimal Won { get; init; } - public byte Side { get; init; } - public decimal Multiplier { get; init; } -} \ No newline at end of file diff --git a/src/Ellie.Econ/Gambling/Betroll/BetrollGame.cs b/src/Ellie.Econ/Gambling/Betroll/BetrollGame.cs deleted file mode 100644 index 5938957..0000000 --- a/src/Ellie.Econ/Gambling/Betroll/BetrollGame.cs +++ /dev/null @@ -1,42 +0,0 @@ -namespace Ellie.Econ.Gambling; - -public sealed class BetrollGame -{ - private readonly (int WhenAbove, decimal MultiplyBy)[] _thresholdPairs; - private readonly EllieRandom _rng; - - public BetrollGame(IReadOnlyList<(int WhenAbove, decimal MultiplyBy)> pairs) - { - _thresholdPairs = pairs.OrderByDescending(x => x.WhenAbove).ToArray(); - _rng = new(); - } - - public BetrollResult Roll(decimal amount = 0) - { - var roll = _rng.Next(1, 101); - - for (var i = 0; i < _thresholdPairs.Length; i++) - { - ref var pair = ref _thresholdPairs[i]; - - if (pair.WhenAbove < roll) - { - return new() - { - Multiplier = pair.MultiplyBy, - Roll = roll, - Threshold = pair.WhenAbove, - Won = amount * pair.MultiplyBy - }; - } - } - - return new() - { - Multiplier = 0, - Roll = roll, - Threshold = -1, - Won = 0, - }; - } -} \ No newline at end of file diff --git a/src/Ellie.Econ/Gambling/Betroll/BetrollResult.cs b/src/Ellie.Econ/Gambling/Betroll/BetrollResult.cs deleted file mode 100644 index ddafa5c..0000000 --- a/src/Ellie.Econ/Gambling/Betroll/BetrollResult.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Ellie.Econ.Gambling; - -public readonly struct BetrollResult -{ - public int Roll { get; init; } - public decimal Multiplier { get; init; } - public decimal Threshold { get; init; } - public decimal Won { get; init; } -} \ No newline at end of file diff --git a/src/Ellie.Econ/Gambling/Rps/RpsGame.cs b/src/Ellie.Econ/Gambling/Rps/RpsGame.cs deleted file mode 100644 index 8d3c623..0000000 --- a/src/Ellie.Econ/Gambling/Rps/RpsGame.cs +++ /dev/null @@ -1,75 +0,0 @@ -namespace Ellie.Econ.Gambling.Rps; - -public sealed class RpsGame -{ - private static readonly EllieRandom _rng = new EllieRandom(); - - const decimal WIN_MULTI = 1.95m; - const decimal DRAW_MULTI = 1m; - const decimal LOSE_MULTI = 0m; - - public RpsGame() - { - - } - - public RpsResult Play(RpsPick pick, decimal amount) - { - var compPick = (RpsPick)_rng.Next(0, 3); - if (compPick == pick) - { - return new() - { - Won = amount * DRAW_MULTI, - Multiplier = DRAW_MULTI, - ComputerPick = compPick, - Result = RpsResultType.Draw, - }; - } - - if ((compPick == RpsPick.Paper && pick == RpsPick.Rock) - || (compPick == RpsPick.Rock && pick == RpsPick.Scissors) - || (compPick == RpsPick.Scissors && pick == RpsPick.Paper)) - { - return new() - { - Won = amount * LOSE_MULTI, - Multiplier = LOSE_MULTI, - Result = RpsResultType.Lose, - ComputerPick = compPick, - }; - } - - return new() - { - Won = amount * WIN_MULTI, - Multiplier = WIN_MULTI, - Result = RpsResultType.Win, - ComputerPick = compPick, - }; - } -} - -public enum RpsPick : byte -{ - Rock = 0, - Paper = 1, - Scissors = 2, -} - -public enum RpsResultType : byte -{ - Win, - Draw, - Lose -} - - - -public readonly struct RpsResult -{ - public decimal Won { get; init; } - public decimal Multiplier { get; init; } - public RpsResultType Result { get; init; } - public RpsPick ComputerPick { get; init; } -} \ No newline at end of file diff --git a/src/Ellie.Econ/Gambling/Slot/SlotGame.cs b/src/Ellie.Econ/Gambling/Slot/SlotGame.cs deleted file mode 100644 index f6cddb9..0000000 --- a/src/Ellie.Econ/Gambling/Slot/SlotGame.cs +++ /dev/null @@ -1,116 +0,0 @@ -namespace Ellie.Econ.Gambling; - -//here is a payout chart -//https://lh6.googleusercontent.com/-i1hjAJy_kN4/UswKxmhrbPI/AAAAAAAAB1U/82wq_4ZZc-Y/DE6B0895-6FC1-48BE-AC4F-14D1B91AB75B.jpg -//thanks to judge for helping me with this -public class SlotGame -{ - private static readonly EllieRandom _rng = new EllieRandom(); - - public SlotResult Spin(decimal bet) - { - var rolls = new[] - { - (byte)_rng.Next(0, 6), - (byte)_rng.Next(0, 6), - (byte)_rng.Next(0, 6) - }; - - ref var a = ref rolls[0]; - ref var b = ref rolls[1]; - ref var c = ref rolls[2]; - - var multi = 0; - var winType = SlotWinType.None; - if (a == b && b == c) - { - if (a == 5) - { - winType = SlotWinType.TrippleJoker; - multi = 30; - } - else - { - winType = SlotWinType.TrippleNormal; - multi = 10; - } - } - else if (a == 5 && (b == 5 || c == 5) - || (b == 5 && c == 5)) - { - winType = SlotWinType.DoubleJoker; - multi = 4; - } - else if (a == 5 || b == 5 || c == 5) - { - winType = SlotWinType.SingleJoker; - multi = 1; - } - - return new() - { - Won = bet * multi, - WinType = winType, - Multiplier = multi, - Rolls = rolls, - }; - } -} - -public enum SlotWinType : byte -{ - None, - SingleJoker, - DoubleJoker, - TrippleNormal, - TrippleJoker, -} - -/* -var rolls = new[] - { - _rng.Next(default(byte), 6), - _rng.Next(default(byte), 6), - _rng.Next(default(byte), 6) - }; - - var multi = 0; - var winType = SlotWinType.None; - - ref var a = ref rolls[0]; - ref var b = ref rolls[1]; - ref var c = ref rolls[2]; - if (a == b && b == c) - { - if (a == 5) - { - winType = SlotWinType.TrippleJoker; - multi = 30; - } - else - { - winType = SlotWinType.TrippleNormal; - multi = 10; - } - } - else if (a == 5 && (b == 5 || c == 5) - || (b == 5 && c == 5)) - { - winType = SlotWinType.DoubleJoker; - multi = 4; - } - else if (rolls.Any(x => x == 5)) - { - winType = SlotWinType.SingleJoker; - multi = 1; - } - - return new() - { - Won = bet * multi, - WinType = winType, - Multiplier = multi, - Rolls = rolls, - }; - } -*/ \ No newline at end of file diff --git a/src/Ellie.Econ/Gambling/Slot/SlotResult.cs b/src/Ellie.Econ/Gambling/Slot/SlotResult.cs deleted file mode 100644 index 42d3630..0000000 --- a/src/Ellie.Econ/Gambling/Slot/SlotResult.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Ellie.Econ.Gambling; - -public readonly struct SlotResult -{ - public decimal Multiplier { get; init; } - public byte[] Rolls { get; init; } - public decimal Won { get; init; } - public SlotWinType WinType { get; init; } -} \ No newline at end of file diff --git a/src/Ellie.Econ/Gambling/Wof/LuLaResult.cs b/src/Ellie.Econ/Gambling/Wof/LuLaResult.cs deleted file mode 100644 index 0f98e1a..0000000 --- a/src/Ellie.Econ/Gambling/Wof/LuLaResult.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Ellie.Econ.Gambling; - -public readonly struct LuLaResult -{ - public int Index { get; init; } - public decimal Multiplier { get; init; } - public decimal Won { get; init; } - public IReadOnlyList Multipliers { get; init; } -} \ No newline at end of file diff --git a/src/Ellie.Econ/Gambling/Wof/WofGame.cs b/src/Ellie.Econ/Gambling/Wof/WofGame.cs deleted file mode 100644 index d76a215..0000000 --- a/src/Ellie.Econ/Gambling/Wof/WofGame.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace Ellie.Econ.Gambling; - -public sealed class LulaGame -{ - private static readonly IReadOnlyList DEFAULT_MULTIPLIERS = new[] { 1.7M, 1.5M, 0.2M, 0.1M, 0.3M, 0.5M, 1.2M, 2.4M }; - - private readonly IReadOnlyList _multipliers; - private static readonly EllieRandom _rng = new(); - - public LulaGame(IReadOnlyList multipliers) - { - _multipliers = multipliers; - } - - public LulaGame() : this(DEFAULT_MULTIPLIERS) - { - } - - public LuLaResult Spin(long bet) - { - var result = _rng.Next(0, _multipliers.Count); - - var multi = _multipliers[result]; - var amount = bet * multi; - - return new() - { - Index = result, - Multiplier = multi, - Won = amount, - Multipliers = _multipliers.ToArray(), - }; - } -} \ No newline at end of file diff --git a/src/Ellie.Econ/GlobalUsings.cs b/src/Ellie.Econ/GlobalUsings.cs deleted file mode 100644 index a197f0b..0000000 --- a/src/Ellie.Econ/GlobalUsings.cs +++ /dev/null @@ -1 +0,0 @@ -global using Ellie.Common; \ No newline at end of file