public void SaveHandsSqlCommandTest() { var hands = new List<Hand>(); Hand hand = new Hand { BigBlind = 1, ButtonPosition = 2, FlopCard1 = "As", FlopCard2 = "Js", FlopCard3 = "Th", HandId = "4545454", RiverCard = "2s", Time = new DateTime(2000, 1, 1), TurnCard = "7s", Players = new List<HandPlayer>() }; HandPlayer player = new HandPlayer { ActionFlop = "action Flop", ActionPreflop = "action Preflop", ActionRiver = "action River", ActionTurn = "action Turn", Card1Str = "2a", Card2Str = "3c", MyMoneyAddedInPot = 2, MyMoneyCollected = 1, PaidFlop = 0.5m, PaidPreflop = 0.6m, PaidRiver = 0.7m, PaidTurn = 0.8m, SeatNumber = 4, Player = "player1", Stack = 6.52m }; hand.Players.Add(player); hands.Add(hand); new Hands().SaveHandsSqlCommand(hands); using (trackDBEntities2 t = new trackDBEntities2()) { Assert.AreEqual(t.Hands.Count(), 1); Assert.AreEqual(t.Hands.First().BB, 1); Assert.AreEqual(t.Hands.First().PositionButton, 2); Assert.AreEqual(t.Hands.First().Id, "4545454"); Assert.AreEqual(t.Hands.First().Time, new DateTime(2000, 1, 1)); Assert.AreEqual(t.Hands.First().Position, 4); Assert.AreEqual(t.Hands.First().Stack, 6.52m); } }
static void Main(string[] args) { string id1 = "2863240-273-1335391174"; string id2 = "2863240-274-1335391222"; string id3 = "2946511-432-1336777177"; string idHand = id3; using (trackDBEntities2 t = new trackDBEntities2()) { var dbHand = t.Hands.Where(h => h.Id == idHand); Console.WriteLine("hand : " + dbHand.First().Id); var sortedHand = dbHand.ToList().OrderBy(x => x.Position); Console.WriteLine("Button on seat " + dbHand.First().PositionButton); foreach (var handse in sortedHand) { Console.WriteLine("Seat "+ handse.Position +":" +handse.User + " (" + handse.Stack + ")"); } var hands = dbHand.ToArray(); bool continu = ReplayStreet(hands, Enumeration.Street.Blind); if (continu) continu = ReplayStreet(hands, Enumeration.Street.Preflop); if (continu) continu = ReplayStreet(hands, Enumeration.Street.Flop); if (continu) continu = ReplayStreet(hands, Enumeration.Street.Turn); if (continu) ReplayStreet(hands, Enumeration.Street.River); Console.WriteLine("-----------"); Console.WriteLine("Summary"); Console.WriteLine("-----------"); foreach (var handse in sortedHand) { string wonloosefold = handse.Net > 0 ? " won " : (handse.Net == 0 ? " folds preflop " : " loose "); Console.WriteLine(handse.User + wonloosefold + (handse.Net != 0 ? handse.Net.ToString() : "")); } Console.WriteLine("Rake : " + sortedHand.Sum(x => x.Net)); Console.Read(); } }
private void LoadUsers() { using (trackDBEntities2 t = new trackDBEntities2()) { var users = from p in t.Hands group p by p.User into g //where g.Count() >= 1000 select new { g.Key }; _users = new ObservableCollection<string>(); foreach (var player in users) { //if (t.Hands.Where(x => x.User == player).Count() > 1000) _users.Add(player.Key); } } }
private void LoadData(string user) { Data = new ObservableCollection<Point>(); using (trackDBEntities2 t = new trackDBEntities2()) { var hands = t.Hands.Where(x => x.User == user && x.Time >= (fromDatePicker.SelectedDate ?? SqlDateTime.MinValue.Value) && x.Time <= (toDatePicker.SelectedDate ?? SqlDateTime.MaxValue.Value) ).ToList(); if (hands.Count == 0) return; decimal? coll = 0; int index = 0; int count = hands.Count(); int modulo = (int)Math.Round((float)count / 1000, 0); modulo = modulo == 0 ? 1 : modulo; int nbPoints = 0; decimal? totalBBWon = 0; foreach (var h in hands.OrderBy(x => x.Time)) { decimal? bbWon = h.Net / h.BB; totalBBWon += bbWon; index++; if (comboBox2.SelectedValue.ToString() == "BB") coll += bbWon; else coll += h.Net; if (index % modulo == 0) { nbPoints++; Data.Add(new Point(h.Time ?? DateTime.MinValue, coll, index)); } } label1.Content = count + " mains, " + nbPoints + " points"; int countRaisePF = hands.Where( x => x.User == user && (x.ActionPreflop.Contains("raises"))). Count(); int countCallPF = hands.Where( x => x.User == user && (x.ActionPreflop.Contains("calls"))). Count(); int countCheckRaise = hands.Where( x => x.User == user && (x.ActionPreflop.Contains("checks,raises"))). Count(); int countPaidPF = countRaisePF + countCallPF; textBox1.Text = "BB won /100 : " + (totalBBWon / count) * 100; textBox1.Text += Environment.NewLine; textBox1.Text += " % Vol. put money preflop : " + countPaidPF * 100 / count + "%"; textBox1.Text += Environment.NewLine; textBox1.Text += " % call pf : " + countCallPF * 100 / count + "%"; textBox1.Text += Environment.NewLine; textBox1.Text += " % raise pf : " + countRaisePF * 100 / count + "%"; textBox1.Text += Environment.NewLine; textBox1.Text += " % check raise pf : " + countCheckRaise * 100 / count + "%"; int countBetsFlop = hands.Where( x => x.User == user && (x.ActionFlop.Contains("bets"))). Count(); int countRaisesFlop = hands.Where( x => x.User == user && (x.ActionFlop.Contains("raises"))). Count(); int countCallFlop = hands.Where( x => x.User == user && (x.ActionFlop.Contains("calls"))). Count(); int countPaidFlop = countBetsFlop + countBetsFlop + countRaisesFlop; textBox1.Text += Environment.NewLine; textBox1.Text += "--- FLOP ---"; textBox1.Text += Environment.NewLine; textBox1.Text += " % Vol. put money flop : " + countPaidFlop * 100 / count + "%"; textBox1.Text += Environment.NewLine; textBox1.Text += " % call f : " + countCallFlop * 100 / count + "%"; textBox1.Text += Environment.NewLine; textBox1.Text += " % raise f : " + countRaisesFlop * 100 / count + "%"; textBox1.Text += Environment.NewLine; textBox1.Text += " % bets f : " + countBetsFlop * 100 / count + "%"; //LineChart1.InvalidateMeasure(); //LineChart1.SeriesSource = Data; } }