public WindowTimer(Table table)
        {
            Table = table;
            InitializeComponent();

            // drag by right mouse click
            System.Windows.Point startPosition = new System.Windows.Point();
            PreviewMouseRightButtonDown += (sender, e) =>
            {
                startPosition = e.GetPosition(this);
            };
            PreviewMouseMove += (sender, e) =>
            {
                if (!Config.HudTimerLocationLocked && e.RightButton == MouseButtonState.Pressed)
                {
                    System.Windows.Point endPosition = e.GetPosition(this);
                    Vector vector = endPosition - startPosition;
                    Left += vector.X;
                    Top += vector.Y;

                    Rectangle cr = WinApi.GetClientRectangle(Table.Handle);
                    double x = (Left - cr.Left) / cr.Width;
                    double y = (Top - cr.Top) / cr.Height;
                    Config.HudTimerLocationsX[(int)Table.TableHud.TableSize] = (float)x;
                    Config.HudTimerLocationsY[(int)Table.TableHud.TableSize] = (float)y;
                }
            };
        }
Example #2
0
 public override void Exec(Table table)
 {
     base.Exec(table);
     Amount = Player.PutChipsInTotal(AmountInTotal);
 }
Example #3
0
 public override void Undo(Table table)
 {
     base.Undo(table);
     Player.UnFold();
 }
Example #4
0
 public override void Exec(Table table)
 {
     base.Exec(table);
     Player.Fold();
 }
Example #5
0
 public virtual void Exec(Table table)
 {
     table.Log("[Do] " + CommandText);
 }
Example #6
0
 public override void Undo(Table table)
 {
     base.Undo(table);
     Player.PutChips(Amount);
 }
Example #7
0
 public override void Undo(Table table)
 {
     base.Undo(table);
     table.CommunityCards[3] = null;
 }
Example #8
0
 public override void Undo(Table table)
 {
     base.Undo(table);
     Player.ArePocketCardsOpenfaced = false;
 }
Example #9
0
            public override void Exec(Table table)
            {
                while (table.Players.Any(o => o.Bet != 0))
                {
                    decimal amount = 0;
                    decimal bet = table.Players.Where(p => p.Bet > 0).Min(p => p.Bet);
                    var players = new List<Player>();
                    foreach (var player in table.Players)
                    {
                        if (player.Bet >= bet)
                        {
                            player.Bet -= bet;
                            amount += bet;
                            players.Add(player);
                        }
                    }
                    var pot = new Pot(players, amount, Street);
                    Pots.Add(pot);
                }

                table.Pots.AddRange(Pots);
            }
Example #10
0
 public override void Undo(Table table)
 {
     base.Undo(table);
     Player.CollectChipsFromPot(-Amount);
 }
Example #11
0
 public override void Exec(Table table)
 {
     base.Exec(table);
     Player.CollectChipsFromPot(Amount);
 }
Example #12
0
 public override void Undo(Table table)
 {
     base.Undo(table);
 }
Example #13
0
 public override void Exec(Table table)
 {
     base.Exec(table);
 }
Example #14
0
 public virtual void Undo(Table table)
 {
     table.Log("[Undo] " + CommandText);
 }
Example #15
0
 public override void Exec(Table table)
 {
     base.Exec(table);
     table.CommunityCards[4] = RiverCard;
 }
Example #16
0
 public override void Exec(Table table)
 {
     base.Exec(table);
     Player.ArePocketCardsOpenfaced = true;
 }
Example #17
0
            public override void Undo(Table table)
            {
                foreach (var pot in Pots)
                {
                    decimal amountPerPlayer = pot.Amount / pot.Players.Count;
                    foreach (var player in pot.Players)
                    {
                        player.Bet += amountPerPlayer;
                    }
                }

                foreach (var pot in Pots)
                {
                    table.Pots.Remove(pot);
                }
                Pots.Clear();
            }
Example #18
0
 public override void Exec(Table table)
 {
     base.Exec(table);
     table.CommunityCards[3] = TurnCard;
 }
Example #19
0
            public override void Exec(Table table)
            {
                var finalizedPots = new List<Pot>();
                var finalizedPotsSbs = new List<Pot>();
                foreach (var pot in table.Pots)
                {
                    var findPot = finalizedPots.FirstOrDefault(o => pot.Players.Where(player => player.IsInPlay).All(player => o.Players.Contains(player)) && o.Players.Count == pot.Players.Count(player => player.IsInPlay));
                    var findPotSbs = finalizedPotsSbs.FirstOrDefault(o => pot.Players.Where(player => player.IsInPlay).All(player => o.Players.Contains(player)) && o.Players.Count == pot.Players.Count(player => player.IsInPlay) && o.Street == pot.Street);
                    if (findPot == null)
                    {
                        findPot = new Pot(pot.Players.Where(player => player.IsInPlay).ToList(), 0, Street.Unknown);
                        finalizedPots.Add(findPot);
                    }
                    if (findPotSbs == null)
                    {
                        findPotSbs = new Pot(pot.Players.Where(player => player.IsInPlay).ToList(), 0, pot.Street);
                        finalizedPotsSbs.Add(findPotSbs);
                    }
                    findPot.Amount += pot.Amount;
                    findPotSbs.Amount += pot.Amount;
                }

                Pots = table.Pots;
                PotsStreetByStreet = table.PotsStreetByStreet;
                table.Pots = finalizedPots;
                table.PotsStreetByStreet = finalizedPotsSbs;
                table.TotalPotBeforeCollection = Pots.Sum(o => o.Amount);
            }
Example #20
0
 public override void Exec(Table table)
 {
     base.Exec(table);
     Player.PutChips(-Amount);
 }
Example #21
0
 public override void Undo(Table table)
 {
     table.Pots = Pots;
     table.PotsStreetByStreet = PotsStreetByStreet;
     table.TotalPotBeforeCollection = 0;
 }
Example #22
0
 public override void Exec(Table table)
 {
     base.Exec(table);
     table.CommunityCards[0] = FlopCards[0];
     table.CommunityCards[1] = FlopCards[1];
     table.CommunityCards[2] = FlopCards[2];
 }
Example #23
0
        public TableHud(Table table)
        {
            #region Init Windows

            Methods.UiInvoke(() =>
            {
                Table = table;
                WindowTimer = new WindowTimer(Table);
                WindowTimer.Opacity = 0;
                WindowTimer.Show();
                for (int i = 0; i < 10; i++)
                {
                    WindowsBigBlind[i] = new WindowBigBlind(Table, i);
                    WindowsBigBlind[i].Opacity = 0;
                    WindowsBigBlind[i].Show();
                }
            });

            #endregion

            _thread = new Thread(() =>
            {
                try
                {
                    while (true)
                    {
                        #region Calculate Timer / BigBlinds

                        string title = Table.Title, className = Table.ClassName;
                        long tournamentNumber;
                        decimal sb, bb, ante;

                        string timerValue = null;
                        bool timerVisibility = false;
                        decimal[] bbValue = new decimal[10];
                        bool[] bbVisibility = new bool[10];
                        bool[] bbIsHero = new bool[10];
                        string[] bbTooltip = new string[10];

                        var success = GetInfo(title, out sb, out bb, out ante, out tournamentNumber);
                        if (success)
                        {
                            var tournament = App.HandHistoryManager.GetTournament(tournamentNumber);
                            if (tournament != null)
                            {
                                TableSize = tournament.GetLastHandTableSize();
                                GetContentTimer(title, className, tournament, sb, bb, out timerValue, out timerVisibility);
                                GetContentBigBlind(tournament, sb, bb, ante, out bbValue, out bbVisibility, out bbIsHero, out bbTooltip);
                            }
                        }

                        #endregion

                        #region Update Timer / BigBlinds

                        Methods.UiInvoke(() =>
                        {
                            try // to eliminate that stupid UpdateView null reference problem..
                            {
                                // Update View
                                WindowTimer.UpdateView(timerValue, PokerType != null ? PokerType.Name : "Unknown");
                                for (int i = 0; i < 10; i++)
                                {
                                    WindowsBigBlind[i].UpdateView(i, bbValue[i], bbTooltip[i], bbIsHero[i]);
                                }

                                // Ensure visibility
                                WindowTimer.EnsureVisibility(timerVisibility);
                                for (int i = 0; i < 10; i++)
                                {
                                    WindowsBigBlind[i].EnsureVisibility(bbVisibility[i] && ((!bbIsHero[i] && Config.HudBigBlindShowForOpponents) || (bbIsHero[i] && Config.HudBigBlindShowForHero)));
                                }
                            }
                            catch
                            {
                            }
                        });

                        #endregion

                        Thread.Sleep(500);
                    }
                }
            #if (DEBUG)
                catch (ThreadInterruptedException)
                {
                }
            #else
                catch (Exception e)
                {
                    if (!(e is ThreadInterruptedException))
                    {
                        Methods.DisplayException(e, App.WindowMain, WindowStartupLocation.CenterOwner);
                    }
                }
            #endif
                finally
                {
                    #region Dispose Windows

                    Methods.UiInvoke(() =>
                    {
                        WindowTimer.Close();
                        for (int i = 0; i < 10; i++)
                        {
                            WindowsBigBlind[i].Close();
                        }
                    });

                    #endregion
                }
            });
            _thread.Start();
        }