Esempio n. 1
0
 public void OnGameActionOffer(TableModel table, BaseOfferAction action)
 {
     if (OnGameActionOfferEvent != null)
     {
         OnGameActionOfferEvent(table, action);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Wysyła możliwe akcje do gracza w zaleznosci od styuacji, wykonuje sie
        /// gdy : gracz zaczyna obserwowac stol
        ///       usuwa gracza
        ///       dodaje nowego gracza
        /// </summary>
        public void SendAvailableAction(UserModel user)
        {
            //Wysyłanie oferty akcji w zależności od stanu gry i możliwości
            BaseOfferAction offerAction = new BaseOfferAction();

            //W grze normalnej
            if (this.GameTableModel.Type == Enums.TableType.Normal)
            {
                //Wolne miejsce
                if (this.GameTableModel.PlayersList.ToList().Count() < this.GameTableModel.Seats)
                {
                    offerAction = new SeatOfferAction()
                    {
                        Timestamp = DateTime.Now
                    };
                }
                else
                {
                    offerAction = new FindAnotherTableOfferAction()
                    {
                        Timestamp = DateTime.Now
                    };
                }

                if (this.GameTableModel.PlayersList.ToList().Where(p => p.User.ID == user.ID).Any())
                {
                    offerAction = new BackOfferAction()
                    {
                        Timestamp = DateTime.Now
                    };
                }
            }
            else if (this.GameTableModel.Type == Enums.TableType.Tournament)
            {
                //Możliwy jedynie powród do gry jeśli to nasz stół i uczestniczymy w turnieju
                if (this.GameTableModel.PlayersList.Where(p => p.User.ID == user.ID).Any())
                {
                    offerAction = new BackOfferAction()
                    {
                        Timestamp = DateTime.Now
                    };
                }
                else
                {
                    offerAction = new HideOfferAction()
                    {
                        Timestamp = DateTime.Now
                    };
                }
            }

            if (user.IsOnline())
            {
                user.GetClient().OnGameActionOffer(this.GameTableModel, offerAction);
            }
        }
Esempio n. 3
0
        void Instance_OnGameActionOfferEvent(TableModel table, BaseOfferAction action)
        {
            Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                if (this.gameTable.GameTable.ID == table.ID)
                {
                    if (action is BetOfferAction)
                    {
                        var actionModel = (BetOfferAction)action;

                        if (this.player != null && actionModel.Player.User.ID == this.player.User.ID)
                        {
                            ParserPlayer(actionModel.Player);
                            RunTimer(actionModel.Time);
                        }
                    }
                }
            }));
        }
        void Instance_OnGameActionOfferEvent(TableModel table, BaseOfferAction action)
        {
            Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                if (this.TableModel.ID == table.ID)
                {
                    if (action is BetOfferAction)
                    {
                        var actionModel = (BetOfferAction)action;

                        //Bet Action powinno iść tylko do gracza który je otrzymuje, jako jedyny jest rozsyłany do wszystkich
                        //musimy wiec sprawdzić czy na pewno jest to nasz bet action
                        if (actionModel.Player.User.ID == Session.Data.User.ID)
                        {
                            UserAction.Content = new Views.Game.BetOfferActionView(this, actionModel);
                        }
                    }
                    else if (action is FindAnotherTableOfferAction)
                    {
                        var actionModel    = (FindAnotherTableOfferAction)action;
                        UserAction.Content = new Views.Game.FindAnotherTableOfferActionView(this);
                    }
                    else if (action is SeatOfferAction)
                    {
                        var actionModel    = (SeatOfferAction)action;
                        UserAction.Content = new Views.Game.SeatOfferActionView(this);
                    }
                    else if (action is HideOfferAction)
                    {
                        var actionModel    = (HideOfferAction)action;
                        UserAction.Content = null;
                    }
                    else if (action is BackOfferAction)
                    {
                        var actionModel    = (BackOfferAction)action;
                        UserAction.Content = new Views.Game.BackOfferActionView(this);
                    }
                }
            }));
        }