Exemple #1
0
 public void deleteCommandCard(CommandCard pCard)
 {
     if (gameCommandCards.Contains(pCard))
         gameCommandCards.Remove(pCard);
 }
Exemple #2
0
        //Apply a command card to the game state
        internal void applyCommandCard(CommandCard commandCard)
        {
            #region Fixed Move

            //Initially we check whether it's a fixed move or not
            if (!commandCard.fixedMove.Equals("NULL"))
            {
                //Specify where we're gonna move the player
                int moveTo = Int32.Parse(commandCard.fixedMove);

                //If the command card specifies him to collect money
                if (commandCard.collect > 0)
                {
                    //Then if he passes through "GO" collect some money
                    //Otherwise do nothing
                    if(moveTo-currentPosition<=0)
                        gamePlayers[currentPlayer].money += commandCard.moneyTransaction;
                }

                //Change current position
                gamePlayers[currentPlayer].position = moveTo;
                currentPosition = moveTo;
                moved = true;
            }

            #endregion Fixed Move

            #region Relative Move

            //Relative move
            else if (!commandCard.relativeMove.Equals("NULL"))
            {
                //Find the specific position to move
                //We'll move towards the nearest group
                if (Int32.Parse(commandCard.relativeMove) > 0)
                {
                    int moveTo = findNearestFromGroup(Int32.Parse(commandCard.relativeMove));

                    //If the player is to collect money then add the specific amount to his balance
                    if (commandCard.collect > 0)
                    {
                        if (moveTo - currentPosition <= 0)
                            gamePlayers[currentPlayer].money += commandCard.moneyTransaction;
                    }

                    //Change current position
                    gamePlayers[currentPlayer].position = moveTo;
                    currentPosition = moveTo;
                    moved = true;
                }
            }

            #endregion Relative Move

            #region Money Transaction

            else
            {
                //If the player is to collect money
                if (commandCard.collect > 0)
                {
                    //Check whether it is from the other players or from the bank
                    if (commandCard.playerInteraction > 0)
                    {
                        getMoneyFromPlayers(commandCard.moneyTransaction);
                    }
                    else
                        gamePlayers[currentPlayer].money += commandCard.moneyTransaction;
                }

                //Otherwise check whether he is to pay money
                if (commandCard.collect == 0)
                {
                    //Calculate the total amount that his has to pay
                   int moneyToPay = commandCard.moneyTransaction + commandCard.houseMultFactor * gamePlayers[currentPlayer].getTotalHouses() + commandCard.hotelMultFactor * gamePlayers[currentPlayer].getTotalHotels();

                    //Check wheter the player has the money to pay for his fine
                   //If not then he has to declare bankruptchy and exit the game
                   if (methods.mActions.payMoney(currentPlayer, -1, moneyToPay) < 0)
                   {
                       //Remove him for the game
                       removePlayer(currentPlayer);
                       for (int i = 0; i < gameCards.Count; i++)
                       {
                           if (gamePlayers[currentPlayer].propertiesPurchased[i].Equals(1))
                           {
                               biddingWar(gameCards[i].getPosition());
                           }
                       }
                   }
                }
            }

            #endregion Money Transaction

             //   MessageBox.Show(commandCard.text);
        }
Exemple #3
0
 //Methods to add and delete a CommandCard
 public void addCommandCard(CommandCard pCard)
 {
     if (!gameCommandCards.Contains(pCard))
         gameCommandCards.Add(pCard);
 }