Пример #1
0
        //---------------------------------------------------------------------
        //---------------------------------------------------------------------
        //TURN RESULTS---------------------------------------------------------
        //---------------------------------------------------------------------
        //---------------------------------------------------------------------

        private void applyTurnResults()
        {
            Boolean[] stillPlaying = new Boolean[players.Length];

            players[currentPlayer].location = turnResults.location;

            for (int index = 0; index < players.Length; index++)
            {
                if (players[index].stillPlaying)
                {
                    players[index].cash += turnResults.getPlayerCash(index);
                    stillPlaying[index]  = true;
                }
                else
                {
                    stillPlaying[index] = false;
                } //END IF
            }     //END FOR

            if (turnResults.inJail)
            {
                jail.setIsInJail(currentPlayer, true);
            }//END IF

            players[currentPlayer].addGetOutOfJailFreeCards(turnResults.getOutOfJailFreeCards);

            freeParking.cash = turnResults.freeParkingMoney;

            turnResults.intializeValues(freeParking.cash, stillPlaying);
        }
Пример #2
0
        public void setValues(TurnResults turnResults)
        {
            this.location = turnResults.location;

            //SET
            for (int index = 0; index < playerCash.Length; index++)
            {
                this.playerCash[index]   = turnResults.getPlayerCash(index);
                this.stillPlaying[index] = turnResults.getPlayerStillPlaying(index);
            }//END FOR

            this.inJail = turnResults.inJail;

            this.getOutOfJailFreeCards = turnResults.getOutOfJailFreeCards;

            this.freeParkingMoney = turnResults.freeParkingMoney;

            this.rentMultiplier = turnResults.rentMultiplier;
        }
Пример #3
0
        //---------------------------------------------------------------------

        private TurnResults processMove(int player, int spaces, TurnResults turnResults, int playerCash, Jail jail)
        {
            int currentLocation40 = turnResults.location;

            int squareIndex28 = 0;

            int squareIndex22 = 0;

            int cashAssets = 0;

            int rent = 0;

            int propertyOwner = 0;

            int railRoads = 0;

            boardPlayerLocations[currentLocation40][player] = true;

            playerBoardLocations[player] = currentLocation40;

            if (currentLocation40 == 0)
            {
                // 0 GO

                processBattle(turnResults, currentLocation40, jail);

                turnResults.addPlayerCash(player, 200);
            }
            else if (currentLocation40 == 10)
            {
                // 10 Jail

                processBattle(turnResults, currentLocation40, jail);

                System.Windows.Forms.MessageBox.Show("Just Visiting");
            }
            else if (currentLocation40 == 20)
            {
                // 20 Free Parking

                processBattle(turnResults, currentLocation40, jail);

                System.Windows.Forms.MessageBox.Show("Free Parking!");

                turnResults.addPlayerCash(player, turnResults.freeParkingMoney);

                turnResults.freeParkingMoney = 500;
            }
            else if (currentLocation40 == 30)
            {
                // 30 Go To Jail
                System.Windows.Forms.MessageBox.Show("Go to Jail. Go directly to Jail. Do not pass GO, do not collect $200.");

                turnResults.location = 10;

                boardPlayerLocations[currentLocation40][player] = false;

                boardPlayerLocations[turnResults.location][player] = true;

                playerBoardLocations[player] = turnResults.location;

                turnResults.inJail = true;
            }
            else if (currentLocation40 == 4)
            {
                // 4 Income Tax

                processBattle(turnResults, currentLocation40, jail);

                cashAssets = playerCash + turnResults.getPlayerCash(player);

                if (canShowMortgageButton(player) == false && cashAssets < 2000)
                {
                    cashAssets = cashAssets / 10;

                    System.Windows.Forms.MessageBox.Show("Income Tax: " + cashAssets);

                    cashAssets = cashAssets * -1;

                    turnResults.addPlayerCash(player, cashAssets);
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("Income Tax: 200");

                    turnResults.addPlayerCash(player, -200);
                }//END IF
            }
            else if (currentLocation40 == 38)
            {
                // 38 Luxury Tax

                processBattle(turnResults, currentLocation40, jail);

                System.Windows.Forms.MessageBox.Show("Luxury Tax: 75");

                turnResults.addPlayerCash(player, -75);
            }
            else if (currentLocation40 == 7 ||
                     currentLocation40 == 22 ||
                     currentLocation40 == 36)
            {
                // 7 Chance 1
                // 22 Chance 2
                // 36 Chance 3

                processBattle(turnResults, currentLocation40, jail);

                turnResults.setValues(boardProperties.processChanceCard(player, turnResults));

                if (currentLocation40 != turnResults.location)
                {
                    boardPlayerLocations[currentLocation40][player] = false;

                    turnResults.setValues(processMove(player, spaces, turnResults, playerCash, jail));
                }//END IF
            }
            else if (currentLocation40 == 2 ||
                     currentLocation40 == 17 ||
                     currentLocation40 == 33)
            {
                // 2 Community Chest 1
                // 17 Community Chest 2
                // 33 Community Chest 3

                processBattle(turnResults, currentLocation40, jail);

                turnResults.setValues(boardProperties.processCommunityChestCard(player, turnResults));

                if (currentLocation40 != turnResults.location)
                {
                    boardPlayerLocations[currentLocation40][player] = false;

                    turnResults.setValues(processMove(player, spaces, turnResults, playerCash, jail));
                }//END IF
            }
            else if (currentLocation40 == 12 ||
                     currentLocation40 == 28)
            {
                // 12 Electric Company
                // 28 Water Works

                processBattle(turnResults, currentLocation40, jail);

                squareIndex28 = indexConversions.get28IndexFrom40Index(currentLocation40);

                propertyOwner = boardProperties.getOwnerOfProperty(squareIndex28);

                if ((turnResults.rentMultiplier == 10 ||
                     boardProperties.getOwnerOfProperty(7) == boardProperties.getOwnerOfProperty(20)) &&
                    propertyOwner >= 0 &&
                    !boardProperties.propertyMortgaged(squareIndex28))
                {
                    rent = spaces * 10;

                    turnResults.addPlayerCash(propertyOwner, rent);

                    rent = rent * -1;

                    turnResults.addPlayerCash(player, rent);
                }
                else if (propertyOwner >= 0 &&
                         !boardProperties.propertyMortgaged(squareIndex28))
                {
                    rent = spaces * 4;

                    turnResults.addPlayerCash(propertyOwner, rent);

                    rent = rent * -1;

                    turnResults.addPlayerCash(player, rent);
                }//END IF

                turnResults.rentMultiplier = 1;
            }
            else if (currentLocation40 == 5 ||
                     currentLocation40 == 15 ||
                     currentLocation40 == 25 ||
                     currentLocation40 == 35)
            {
                // 5 Reading Railroad
                // 15 Pennsylvania Railroad
                // 25 B&O Railroad
                // 35 Short Line

                processBattle(turnResults, currentLocation40, jail);

                squareIndex28 = indexConversions.get28IndexFrom40Index(currentLocation40);

                propertyOwner = boardProperties.getOwnerOfProperty(squareIndex28);

                railRoads = 0;

                if (propertyOwner >= 0 &&
                    !boardProperties.propertyMortgaged(squareIndex28))
                {
                    if (propertyOwner == boardProperties.getOwnerOfProperty(2))
                    {
                        railRoads++;
                    }//END IF

                    if (propertyOwner == boardProperties.getOwnerOfProperty(10))
                    {
                        railRoads++;
                    }//END IF

                    if (propertyOwner == boardProperties.getOwnerOfProperty(17))
                    {
                        railRoads++;
                    }//END IF

                    if (propertyOwner == boardProperties.getOwnerOfProperty(25))
                    {
                        railRoads++;
                    }//END IF

                    if (railRoads == 1)
                    {
                        rent = 25 * turnResults.rentMultiplier;
                    }
                    else if (railRoads == 2)
                    {
                        rent = 50 * turnResults.rentMultiplier;
                    }
                    else if (railRoads == 3)
                    {
                        rent = 100 * turnResults.rentMultiplier;
                    }
                    else if (railRoads == 4)
                    {
                        rent = 200 * turnResults.rentMultiplier;
                    }//END IF

                    turnResults.addPlayerCash(propertyOwner, rent);

                    rent = rent * -1;

                    turnResults.addPlayerCash(player, rent);
                }//END IF

                turnResults.rentMultiplier = 1;
            }
            else if (currentLocation40 == 1 || currentLocation40 == 3 ||
                     currentLocation40 == 6 || currentLocation40 == 8 ||
                     currentLocation40 == 9 || currentLocation40 == 11 ||
                     currentLocation40 == 13 || currentLocation40 == 14 ||
                     currentLocation40 == 16 || currentLocation40 == 18 ||
                     currentLocation40 == 19 || currentLocation40 == 21 ||
                     currentLocation40 == 23 || currentLocation40 == 24 ||
                     currentLocation40 == 26 || currentLocation40 == 27 ||
                     currentLocation40 == 29 || currentLocation40 == 31 ||
                     currentLocation40 == 32 || currentLocation40 == 34 ||
                     currentLocation40 == 37 || currentLocation40 == 39)
            {
                // 1 Mediterranean Avenue
                // 3 Baltic Avenue
                // 6 Oriental Avenue
                // 8 Vermont Avenue
                // 9 Connecticut Avenue
                // 11 St. Charles Place
                // 13 States Avenue
                // 14 Virginia Avenue
                // 16 St. James Place
                // 18 Tennessee Avenue
                // 19 New York Avenue
                // 21 Kentucky Avenue
                // 23 Indiana Avenue
                // 24 Illinois Avenue
                // 26 Atlantic Avenue
                // 27 Ventnor Avenue
                // 29 Marvin Gardens
                // 31 Pacific Avenue
                // 32 North Carolina Avenue
                // 34 Pennsylvania Avenue
                // 37 Park Place
                // 39 Boardwalk

                processBattle(turnResults, currentLocation40, jail);

                squareIndex28 = indexConversions.get28IndexFrom40Index(currentLocation40);

                squareIndex22 = indexConversions.get22IndexFrom40Index(currentLocation40);

                propertyOwner = boardProperties.getOwnerOfProperty(squareIndex28);

                if (propertyOwner >= 0 &&
                    !boardProperties.propertyMortgaged(squareIndex28))
                {
                    rent = boardProperties.getHousePropertyRent(
                        propertyOwner,
                        squareIndex22,
                        boardProperties.getHousesOnProperty(squareIndex22));

                    turnResults.addPlayerCash(propertyOwner, rent);

                    rent = rent * -1;

                    turnResults.addPlayerCash(player, rent);
                } //END IF
            }     //END IF

            return(turnResults);
        }