Exemplo n.º 1
0
        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;
                }
            };
        }
Exemplo n.º 2
0
 public override void Exec(Table table)
 {
     base.Exec(table);
     Amount = Player.PutChipsInTotal(AmountInTotal);
 }
Exemplo n.º 3
0
 public override void Undo(Table table)
 {
     base.Undo(table);
     Player.UnFold();
 }
Exemplo n.º 4
0
 public override void Exec(Table table)
 {
     base.Exec(table);
     Player.Fold();
 }
Exemplo n.º 5
0
 public virtual void Exec(Table table)
 {
     table.Log("[Do] " + CommandText);
 }
Exemplo n.º 6
0
 public override void Undo(Table table)
 {
     base.Undo(table);
     Player.PutChips(Amount);
 }
Exemplo n.º 7
0
 public override void Undo(Table table)
 {
     base.Undo(table);
     table.CommunityCards[3] = null;
 }
Exemplo n.º 8
0
 public override void Undo(Table table)
 {
     base.Undo(table);
     Player.ArePocketCardsOpenfaced = false;
 }
Exemplo n.º 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);
            }
Exemplo n.º 10
0
 public override void Undo(Table table)
 {
     base.Undo(table);
     Player.CollectChipsFromPot(-Amount);
 }
Exemplo n.º 11
0
 public override void Exec(Table table)
 {
     base.Exec(table);
     Player.CollectChipsFromPot(Amount);
 }
Exemplo n.º 12
0
 public override void Undo(Table table)
 {
     base.Undo(table);
 }
Exemplo n.º 13
0
 public override void Exec(Table table)
 {
     base.Exec(table);
 }
Exemplo n.º 14
0
 public virtual void Undo(Table table)
 {
     table.Log("[Undo] " + CommandText);
 }
Exemplo n.º 15
0
 public override void Exec(Table table)
 {
     base.Exec(table);
     table.CommunityCards[4] = RiverCard;
 }
Exemplo n.º 16
0
 public override void Exec(Table table)
 {
     base.Exec(table);
     Player.ArePocketCardsOpenfaced = true;
 }
Exemplo n.º 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();
            }
Exemplo n.º 18
0
 public override void Exec(Table table)
 {
     base.Exec(table);
     table.CommunityCards[3] = TurnCard;
 }
Exemplo n.º 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);
            }
Exemplo n.º 20
0
 public override void Exec(Table table)
 {
     base.Exec(table);
     Player.PutChips(-Amount);
 }
Exemplo n.º 21
0
 public override void Undo(Table table)
 {
     table.Pots = Pots;
     table.PotsStreetByStreet = PotsStreetByStreet;
     table.TotalPotBeforeCollection = 0;
 }
Exemplo n.º 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];
 }
Exemplo n.º 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();
        }