Beispiel #1
0
        private void SteppedOnUtilitySpace(Player[] players, IList <Space> listOfSpaces, int currentPlayerCounter, Player player, Space currentSpace)
        {
            UtilitySpace currentUtilitySpace = (UtilitySpace)currentSpace;

            if (currentUtilitySpace.Owned == false)
            {
                FreeSpace(players, listOfSpaces, currentPlayerCounter, player, currentUtilitySpace);
                player.OwnedUtilities = currentUtilitySpace.Owned == true ?
                                        player.OwnedUtilities + 1 :
                                        player.OwnedUtilities;
            }
            else if (currentUtilitySpace.Owned == true &&
                     !player.ListOfProperties.Contains(listOfSpaces[player.Position]))
            {
                OtherPlayerOwnUtility(players, listOfSpaces, player, currentUtilitySpace);
            }
        }
Beispiel #2
0
 private void OtherPlayerOwnUtility(Player[] players, IList <Space> listOfSpaces, Player player, UtilitySpace currentUtilitySpace)
 {
     for (int i = 0; i < players.Length; i++)
     {
         var otherPlayer = players[i];
         if (otherPlayer.ListOfProperties.Contains(listOfSpaces[player.Position]))
         {
             PayingMoney(player, (int)currentUtilitySpace.Rent * otherPlayer.OwnedUtilities, otherPlayer);
         }
     }
 }
Beispiel #3
0
        // Switch case method for after chance cards are drawn. This method carries the actions of the chance cards.
        public void CardEffect(Player player, GameBoard board, ChanceCards card, List <Player> players)
        {
            switch (ChanceEffect)
            {
            case 1:
                player.MovePlayerToSpace(board.GetStartingSpace());
                player.AddMoney(200);
                break;

            case 2:
                //Need to be able to purchase space or activate space effect
                player.MovePlayerToSpace(board.GetSpaceByName("Fleet Street"));
                break;

            case 3:
                //Need to be able to purchase space or activate space effect
                player.MovePlayerToSpace(board.GetSpaceByName("Pall Mall"));
                break;

            case 4:
                //Need to be able to purchase space or activate space effect
                UtilitySpace utilitySpace = (UtilitySpace)board.GetClosestUtility(player.GetSpaceOccupied().GetSpaceId());
                player.MovePlayerToSpace(utilitySpace);
                player.RemoveMoney(utilitySpace.GetUtility().GetCost());
                break;

            case 5:
                //Need to be able to purchase space or activate space effect
                RailroadSpace railroadSpace = (RailroadSpace)board.GetClosestRailroad(player.GetSpaceOccupied().GetSpaceId());
                player.MovePlayerToSpace(railroadSpace);

                if (railroadSpace.GetOwner() != null)
                {
                    int payment = player.RemoveMoneyWithReturn(railroadSpace.GetRailroad().GetCost() * 2);
                    railroadSpace.GetOwner().AddMoney(payment);
                }
                break;

            case 6:
                player.AddMoney(50);
                break;

            case 7:
                player.SetGetOutOfJailFreeCard(true);
                break;

            case 8:
                //Need to be able to purchase space or activate space effect
                int spacePosition = player.GetSpaceOccupied().GetSpaceId();
                spacePosition -= 3;

                if (spacePosition < 0)
                {
                    spacePosition += 40;
                }

                player.MovePlayerToSpace(board.GetSpaceById(spacePosition));
                player.Action(board.GetSpaceById(spacePosition), board, players);
                break;

            case 9:
                player.MovePlayerToSpace(board.GetJailSpace());

                JailSpace jailSpace = (JailSpace)board.GetJailSpace();
                jailSpace.AddPlayerToJail(player);

                break;

            case 10:
                int amount = 25 * board.GetTotalNumOfHouse();
                player.RemoveMoney(amount);
                break;

            case 11:
                player.RemoveMoney(15);
                break;

            case 12:
                player.MovePlayerToSpace(board.GetSpaceByName("White Chapel Road"));
                break;

            case 13:
                player.MovePlayerToSpace(board.GetSpaceByName("Mayfair"));
                break;

            case 14:
                for (int i = 0; i < players.Count; i++)
                {
                    if (player.IsPlayerBankrupt())
                    {
                        break;
                    }

                    if (player != players[i])
                    {
                        players[i].AddMoney(player.RemoveMoneyWithReturn(50));
                    }
                }
                break;

            case 15:
                player.AddMoney(150);
                break;

            case 16:
                player.AddMoney(100);
                break;
            }
        }