示例#1
0
        // Event for CardMoveToCell
        private void CardMoveToCell_OnClickValidate(object sender, EventArgs e)
        {
            CardMoveToCell card = (CardMoveToCell)_CardHandler.CurrentCard;

            EventMovePlayerToCell(PlayerHandler.Instance.currentPlayer, BoardHandler.Instance.Board.GetCell(card.CellPosition), card.withStartAmount);
            _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;
                }
            }
        }