using System.Collections.Generic;
using Newtonsoft.Json.Converters;
using System.Globalization;
public static void Main()
var oldGame = new GGPoker();
oldGame.Args = new GGPokerArgs()
Dealer = new GGPokerDealerArgs()
Cards = new List<GGPokerCards>() {
{ new GGPokerCards() { Value = "AC" } },
{ new GGPokerCards() { Value = "AH" } }
Seats = new Dictionary<string, GGPokerPlayerArgs>()
{ "4", new GGPokerPlayerArgs()
Data = new GGPokerPlayer()
Cards = new List<GGPokerCards>() {
{ new GGPokerCards() { Value = "2C" } },
{ new GGPokerCards() { Value = "Hello" } }
{ "3", new GGPokerPlayerArgs()
Data = new GGPokerPlayer()
Cards = new List<GGPokerCards>() {
{ new GGPokerCards() { Value = "8C" } },
{ new GGPokerCards() { Value = "4H" } },
{ new GGPokerCards() { Value = "5H" } }
var game = new GGPoker();
game.Args = new GGPokerArgs()
Dealer = new GGPokerDealerArgs()
Cards = new List<GGPokerCards>() {
{ new GGPokerCards() { Value = "AC" } },
{ new GGPokerCards() { Value = "AH" } },
{ new GGPokerCards() { Value = "8H" } },
Seats = new Dictionary<string, GGPokerPlayerArgs>()
{ "4", new GGPokerPlayerArgs()
Data = new GGPokerPlayer()
Cards = new List<GGPokerCards>() {
{ new GGPokerCards() { Value = "2C" } },
{ new GGPokerCards() { Value = "8C" } },
{ "3", new GGPokerPlayerArgs()
Data = new GGPokerPlayer()
Cards = new List<GGPokerCards>() {
{ new GGPokerCards() { Value = "8C" } },
{ new GGPokerCards() { Value = "4H" } },
{ new GGPokerCards() { Value = "5H" } },
Compare compare = new(game, oldGame);
if (compare.IsEqual() == false)
var lst = compare.GetCardsDifference().ToList();
lst.ForEach(l => Console.WriteLine(l));
private GGPoker? _storedGame;
public Compare(GGPoker game, GGPoker? storedGame)
_storedGame = StoredGame(storedGame);
private GGPoker? StoredGame(GGPoker? storedGame)
Cards cards = new(_game);
var newCards = cards.GetCards();
if (_storedGame == null) return false;
Cards storedCards = new(_storedGame);
var oldCards = storedCards.GetCards();
return Enumerable.SequenceEqual(oldCards, newCards);
public IEnumerable<string>? GetCardsDifference()
if (_storedGame == null) return null;
var lstDealer = GetDifference(_game.Args.Dealer.Cards, _storedGame.Args.Dealer.Cards);
List<string> lstPlayers = new();
for (int i = 0; i < _game.Args.Seats.Count; i++)
var lstTmpPlayers = GetDifference(_game.Args.Seats.ToList()[i].Value.Data.Cards, _storedGame.Args.Seats.ToList()[i].Value.Data.Cards);
lstPlayers = lstPlayers.Concat(lstTmpPlayers).ToList();
return lstDealer.Concat(lstPlayers);
public List<string> GetDifference(List<GGPokerCards> cards, List<GGPokerCards> oldCards)
List<string> lst = new();
for (int i = 0; i < cards.Count; i++)
if (cards[i].Value != oldCards[i].Value)
public Cards(GGPoker game) => Game = game;
public IEnumerable<string> GetCards()
List<string> cards = new();
Game.Args.Dealer.Cards.ForEach(c => cards.Add(c.Value));
Game.Args.Seats.ToList().ForEach(s => s.Value.Data.Cards.ForEach((c) => cards.Add(c.Value)));
public int CardsByDeck = 52;
public int CardsBySuit = 4;
private double numberOfDecks { get; set; }
public double NumberOfDecks(int numberOfCardsExposed)
int total = CardsByDeck * Deck;
int remainingCards = total - numberOfCardsExposed;
double numberOfDecks = (remainingCards * Deck) / total;
return this.numberOfDecks = Math.Round(numberOfDecks, 2);
public int? RunningCount(GGPoker ggPoker)
var cardValue = new CardValue();
ggPoker.Args.Dealer.Cards.ForEach(p => total += cardValue.SetHiLo(cardValue.SanitizeCard(p.Value)));
if (ggPoker.Args.Seats is not null)
ggPoker.Args.Seats.ToList().ForEach(p =>
if (p.Value.Data.Cards is not null)
p.Value.Data.Cards.ForEach(c => total += cardValue.SetHiLo(cardValue.SanitizeCard(c.Value)));
public int? RunningCount(List<string> ggPoker)
var card = new CardValue();
ggPoker.ForEach(g => total += card.SetHiLo(card.SanitizeCard(g)));
public double TrueCount(int runningCount)
double trueCount = runningCount / numberOfDecks;
return Math.Round(trueCount, 2);
protected readonly Dictionary<int, string[]> _cards = new()
{ 1, new string[] { "2", "3", "4", "5", "6" } },
{ 0, new string[] { "7", "8", "9" } },
{ -1, new string[] { "T", "J", "Q", "K", "A" } },
public string? SanitizeCard(string card)
char[] chars = card.ToCharArray();
return chars[0].ToString();
public int? SetHiLo(string? card)
if (card is null) return 0;
int? hiLoValue = this._cards.Where(p => p.Value.Contains(card)).ToList().FirstOrDefault().Key;
public partial class GGPoker
public string Id { get; set; }
public string Type { get; set; }
public GGPokerArgs Args { get; set; }
public long Time { get; set; }
public string GameId { get; set; }
public GGPokerDealerArgs Dealer { get; set; }
public Dictionary<string, GGPokerPlayerArgs> Seats { get; set; }
[JsonProperty("dealingOrder")]
public object[] DealingOrder { get; set; }
[JsonProperty("dealingSequence")]
public object[] DealingSequence { get; set; }
public class GGPokerDealerArgs
public List<GGPokerCards> Cards { get; set; }
public int Score { get; set; }
[JsonProperty("dealNoOfCards")]
public int DealNoOfCards { get; set; }
public class GGPokerPlayerArgs
public GGPokerPlayer Data { get; set; }
public class GGPokerPlayer
public List<GGPokerCards> Cards { get; set; }
public int Score { get; set; }
public string State { get; set; }
[JsonProperty("confirmedDecisions", NullValueHandling = NullValueHandling.Ignore)]
public List<GGPokerPlayerDecisions> ConfirmedDecisions { get; set; }
[JsonProperty("result", NullValueHandling = NullValueHandling.Ignore)]
public string Result { get; set; }
public class GGPokerPlayerDecisions
[JsonProperty("decision")]
public string Decision { get; set; }
public long T { get; set; }
[JsonProperty("preDecision")]
public bool PreDecision { get; set; }
[JsonProperty("validation")]
public bool Validation { get; set; }
[JsonProperty("decisionId", NullValueHandling = NullValueHandling.Ignore)]
public string DecisionId { get; set; }
public class GGPokerCards
public string Value { get; set; }
public int Deck { get; set; }
public long T { get; set; }
public partial class GGPoker
public static GGPoker FromJson(string json) => JsonConvert.DeserializeObject<GGPoker>(json, Converter.Settings);
public static class Serialize
public static string ToJson(this GGPoker self) => JsonConvert.SerializeObject(self, Converter.Settings);
internal static class Converter
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
DateParseHandling = DateParseHandling.None,
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }