Пример #1
0
        private void CardExitToJail_OnClickGetCard(object sender, EventArgs e)
        {
            CardExitToJail card = (CardExitToJail)_CardHandler.CurrentCard;

            card.Action = CardExitToJail.ActionOption.KEEPCARD;
            _CardHandler.ExecuteCardAction(card);
            this.Content = null;
        }
Пример #2
0
        public void ExecuteCardAction(Card c)
        {
            if (c is CardUpdateMoney)
            {
                CardUpdateMoney card = (CardUpdateMoney)c;
                if (card.Amount < 0)
                {
                    _PlayerHandler.PayeAmount(PlayerHandler.Instance.currentPlayer, Math.Abs(card.Amount));
                }
                else
                {
                    _PlayerHandler.CardGiveMoney(PlayerHandler.Instance.currentPlayer, card.Amount);
                }
            }
            else if (c is CardUpdateMoneyAccordingBuilds)
            {
                CardUpdateMoneyAccordingBuilds  card       = (CardUpdateMoneyAccordingBuilds)c;
                ObservableCollection <Property> properties = _PlayerHandler.Properties();

                int Amount = 0;
                foreach (Property p in properties)
                {
                    if (p is Land)
                    {
                        Land l = (Land)p;
                        Amount += l.NbHotel * card.CostHotel;
                        Amount += l.NbHouse * card.CostHouse;
                    }
                }
                _PlayerHandler.PayeAmount(PlayerHandler.Instance.currentPlayer, Math.Abs(Amount));
            }
            else if (c is CardAnniversary)
            {
                CardAnniversary    card    = (CardAnniversary)c;
                Player             current = _PlayerHandler.currentPlayer;
                Predicate <Player> findAllPlayerWithoutDrawer = (Player p) => { return(p.Id != current.Id); };
                List <Player>      players = _PlayerHandler.ListOfPlayers.FindAll(findAllPlayerWithoutDrawer);
                foreach (Player p in players)
                {
                    _PlayerHandler.PayeTo(p, current, card.Amount);
                }
            }
            else if (c is CardMove)
            {
                CardMove card    = (CardMove)c;
                Player   current = _PlayerHandler.currentPlayer;
                _PlayerHandler.MoveTo(current, (current.Position + card.NbMove));
            }
            else if (c is CardMoveToCell)
            {
                CardMoveToCell card    = (CardMoveToCell)c;
                Player         current = _PlayerHandler.currentPlayer;
                _PlayerHandler.MoveTo(current, _BoardHandler.Board.GetCell(card.CellPosition));
            }
            else if (c is CardMoveToJail)
            {
                CardMoveToJail card    = (CardMoveToJail)c;
                Player         current = _PlayerHandler.currentPlayer;
                current.InJail = true;
                DicesHandler.Instance.PlayerCanBeRaise = false;
                _PlayerHandler.MoveTo(current, _BoardHandler.Board.GetCell(card.CellPosition));
            }
            else if (c is CardExitToJail)
            {
                CardExitToJail card    = (CardExitToJail)c;
                Player         current = _PlayerHandler.currentPlayer;
                switch (card.Action)
                {
                case CardExitToJail.ActionOption.EXITTOJAIL:
                    _PlayerHandler.ExitToJail(current);
                    break;

                case CardExitToJail.ActionOption.KEEPCARD:
                    _PlayerHandler.AddCardTo(current, c);
                    break;
                }
            }
            else if (c is CardChoice)
            {
                CardChoice card    = (CardChoice)c;
                Player     current = _PlayerHandler.currentPlayer;

                switch (card.Action)
                {
                case CardChoice.ActionOption.DRAWCARD:
                    switch (card.CardTypeToDraw)
                    {
                    case (int)CardType.CHANCE:
                        this.GetNextChanceCard();
                        break;

                    case (int)CardType.COMMUNITY:
                        this.GetNextCommunityCard();
                        break;
                    }
                    break;

                case CardChoice.ActionOption.PAY:
                    _PlayerHandler.PayeAmount(current, card.Amount);
                    break;
                }
            }
        }
Пример #3
0
 /// <summary>
 /// Check if player own card : exit to jail
 /// </summary>
 /// <param name="card">card</param>
 /// <returns></returns>
 public bool PlayerOwnExitToJailCard(out CardExitToJail card)
 {
     card = (CardExitToJail)currentPlayer.ListOfCards.FirstOrDefault(x => x is CardExitToJail);
     return(card != default(CardExitToJail));
 }