Beispiel #1
0
        /**
         * The action when the player stepped onto a Card field.
         */
        private void DefaultCardAction(Card card, int diceRoll)
        {
            Player cardOwner = propertyManager.WhoOwns(card);

            if (cardOwner == null)
            {
                if (currentPlayer.Money < card.Cost)
                {
                    window.ShowMessage("You have not got enough money to buy this property");
                    ShowCard(card);
                    GameState = GameStage.NO_FUNDS_BUY;
                    return;
                }
                window.PurchaseButtons(card.Name);
                ShowCard(card);
                GameState = GameStage.AWAITING_PURCHASE;
                return;
            }
            else if (cardOwner == currentPlayer)
            {
                if (card is PropertyCard)
                {
                    if (propertyManager.OwnsWholeGroup(card.Group, currentPlayer))
                    {
                        if (((PropertyCard)card).ApartmentCost > currentPlayer.Money)
                        {
                            window.ShowMessage("You have not got enough money to upgrade this property");
                            GameState = GameStage.NO_FUNDS_BUY;
                        }
                        else
                        {
                            window.ShowUpgradeOptions(card.Name, ((PropertyCard)card).ApartmentCost);
                            ShowCard(card);
                            GameState = GameStage.AWAITING_UPGRADE;
                        }
                    }
                }
                else
                {
                    ShowWhatNext(currentPlayer);
                }
                return;
            }
            else
            {
                if (cardOwner.Prison)
                {
                    window.ShowMessage("The owner of this property is in prison. Lucky you!");
                    GameState = GameStage.NO_FUNDS_BUY;
                    return;
                }
                else if (card.Mortgaged)
                {
                    window.ShowMessage("This property is mortgaged and you don't have to pay!");
                    GameState = GameStage.NO_FUNDS_BUY;
                    return;
                }
                else
                {
                    float money;
                    int   propsOwned;
                    if (diceRoll > 0)
                    {
                        propsOwned = PropsOwned(cardOwner, "agency");
                        money      = ((AgencyCard)card).GetPayment(diceRoll, propsOwned);
                    }
                    else if (diceRoll < 0)
                    {
                        money = card.GetPayment();
                    }
                    else
                    {
                        propsOwned = PropsOwned(cardOwner, "bonus");
                        money      = ((BonusCard)card).GetPayment(propsOwned);
                    }
                    if (money > currentPlayer.Money)
                    {
                        window.ShowNoMoneyPay();
                        GameState = GameStage.NO_FUNDS_PAY;
                        return;
                    }
                    currentPlayer.Money -= money;
                    cardOwner.Money     += money;
                    window.ShowPayment(cardOwner.name, money);
                    ShowCard(card);
                    GameState = GameStage.AWAITING_RENT;
                }
                return;
            }
        }