//--------------------------------------------------------------------- //SURRENDER------------------------------------------------------------ //--------------------------------------------------------------------- public TurnResults freePlayerProperties(int player, TurnResults turnResults) { int squareIndex28 = 0; int housesOnSet = 0; int totalHousesCost = 0; Boolean ownsProperty = false; for (int index22 = 0; index22 < 22; index22++) { squareIndex28 = indexConversions.get28IndexFrom22Index(index22); ownsProperty = propertyOwners.getOwnsProperty(squareIndex28, player); housesOnSet = propertyOwners.getHousesOnSet(index22); if (ownsProperty && housesOnSet > 0) { totalHousesCost = propertyInfo.getHousePropertyHouseCost(index22); totalHousesCost = totalHousesCost * housesOnSet; turnResults.freeParkingMoney += totalHousesCost; propertyOwners.removeAllHousesInSet(player, index22); } //END IF } //END FOR propertyOwners.freePlayerProperties(player); return(turnResults); }
//--------------------------------------------------------------------- //SELL HOUSES---------------------------------------------------------- //--------------------------------------------------------------------- public TurnResults sellHouses(int player, int[] houses, TurnResults turnResults) { //SQUARE IS FROM PROPERTIES THAT BUY HOUSES 22 //ADD HOUSES TO TOTAL //ONLY NEGITIVE NUMBERS AND ZEROS IN HOUSES return(boardProperties.addHouses(player, houses, turnResults)); }
public TurnResults mortgageUnmortgage(Boolean[] mortgageProperties, TurnResults turnResults, int player) { int mortgageValue = 0; //FLIP ALL PROPERTIES THAT ARE TRUE for (int index28 = 0; index28 < mortgageProperties.Length; index28++) { if (mortgageProperties[index28]) { if (propertyOwners.propertyMortgaged(index28)) { mortgageValue = getMortgagePropertyValue(index28) * -1; turnResults.addPlayerCash(player, mortgageValue); } else if (!propertyOwners.propertyMortgaged(index28)) { mortgageValue = getMortgagePropertyValue(index28); turnResults.addPlayerCash(player, mortgageValue); } //END IF } //END IF } //END FOR propertyOwners.mortgageUnmortgage(mortgageProperties); return(turnResults); }
//COMMUNITY CHEST------------------------------------------------------ public TurnResults processCommunityChestCard(int player, TurnResults turnResults) { return(chanceAndCommunityChest.processCommunityChestCard( player, propertyOwners.getPlayerOwnedHouses(player), propertyOwners.getPlayerOwnedHotels(player), turnResults)); }
//--------------------------------------------------------------------- //--------------------------------------------------------------------- //SURRENDER------------------------------------------------------------ //--------------------------------------------------------------------- //--------------------------------------------------------------------- public TurnResults SurrenderFreePlayer(int player, TurnResults turnResults) { boardPlayerLocations[playerBoardLocations[player]][player] = false; playerBoardLocations[player] = -1; return(boardProperties.freePlayerProperties(player, turnResults)); }
//--------------------------------------------------------------------- //--------------------------------------------------------------------- //MAKE TRADE----------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- public TurnResults makeTrade( int currentPlayer, int tradePlayer, Boolean[] propertiesToPlayer, Boolean[] propertiesToTradePlayer, TurnResults turnResults) { return(boardProperties.makeTrade( currentPlayer, tradePlayer, propertiesToPlayer, propertiesToTradePlayer, turnResults)); }
public TurnResults addHouses(int player, int[] houses, TurnResults turnResults) { int costOfHouses = 0; //SQUARE IS FROM PROPERTIES THAT BUY HOUSES 22 //ADD HOUSES TO TOTAL //ONLY NEGITIVE NUMBERS AND ZEROS IN HOUSES propertyOwners.addHouses(player, houses); for (int index22 = 0; index22 < houses.Length; index22++) { costOfHouses = propertyInfo.getHousePropertyHouseCost(index22); costOfHouses = costOfHouses * -1 * houses[index22]; turnResults.addPlayerCash(player, costOfHouses); }//END FOR return(turnResults); }
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; }
//--------------------------------------------------------------------- //--------------------------------------------------------------------- //MOVE----------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- //MOVE----------------------------------------------------------------- //--------------------------------------------------------------------- public TurnResults move(int player, int spaces, TurnResults turnResults, int playerCash, Jail jail) { int currentLocation40 = playerBoardLocations[player]; boardPlayerLocations[currentLocation40][player] = false; currentLocation40 = (currentLocation40 + spaces) % 40; //CHECK IF PASSED GO if (turnResults.location > currentLocation40) { System.Windows.Forms.MessageBox.Show("Passed Go!"); turnResults.addPlayerCash(player, 200); }//END IF turnResults.location = currentLocation40; return(processMove(player, spaces, turnResults, playerCash, jail)); }
public TurnResults battle( int[] players, int propertyValue, TurnResults turnResults, DisplayResources displayResources) { int[] order = new int[players.Length]; int cash = 0; int player = 0; int place = 0; Array.Copy(setOrder(order), order, order.Length); for (int index = 0; index < order.Length; index++) { cash = propertyValue * arrayPropertyMultipliers[players.Length - 2][index]; player = players[order[index]]; place = index + 1; turnResults.addPlayerCash(player, cash); System.Windows.Forms.MessageBox.Show( "Battle " + Convert.ToString(index) + " place " + displayResources.getPlayerName(player) + " cash " + Convert.ToString(cash) + " drinks " + arrayDrinkMultipliers[players.Length - 2][index]); }//END FOR return(turnResults); }
public TurnDirector(DisplayResources displayResources) { boardDirector = new BoardDirector(displayResources); players = new Player[displayResources.getNumberOfPlayers()]; for (int index = 0; index < displayResources.getNumberOfPlayers(); index++) { players[index] = new Player(); }//END FOR jail = new Jail(displayResources.getNumberOfPlayers()); turnResults = new TurnResults(displayResources.getNumberOfPlayers()); this.displayResources = new DisplayResources( displayResources.getPlayerNames(), displayResources.getPlayerAbvs()); intializeValues(); }
//--------------------------------------------------------------------- //MAKE TRADE----------------------------------------------------------- //--------------------------------------------------------------------- public TurnResults makeTrade( int currentPlayer, int tradePlayer, Boolean[] propertiesToPlayer, Boolean[] propertiesToTradePlayer, TurnResults turnResults) { int squareIndex22 = 0; int housesOnSet = 0; int totalHousesCost = 0; for (int index28 = 0; index28 < propertiesToPlayer.Length; index28++) { if (index28 == 0 || index28 == 1 || index28 == 3 || index28 == 4 || index28 == 5 || index28 == 6 || index28 == 8 || index28 == 9 || index28 == 11 || index28 == 12 || index28 == 13 || index28 == 14 || index28 == 15 || index28 == 16 || index28 == 18 || index28 == 19 || index28 == 21 || index28 == 22 || index28 == 23 || index28 == 24 || index28 == 26 || index28 == 27) { // 0 0 Mediterranean Avenue // 1 1 Baltic Avenue // 3 2 Oriental Avenue // 4 3 Vermont Avenue // 5 4 Connecticut Avenue // 6 5 St. Charles Place // 8 6 States Avenue // 9 7 Virginia Avenue // 11 8 St. James Place // 12 9 Tennessee Avenue // 13 10 New York Avenue // 14 11 Kentucky Avenue // 15 12 Indiana Avenue // 16 13 Illinois Avenue // 18 14 Atlantic Avenue // 19 15 Ventnor Avenue // 21 16 Marvin Gardens // 22 17 Pacific Avenue // 23 18 North Carolina Avenue // 24 19 Pennsylvania Avenue // 26 20 Park Place // 27 21 Boardwalk squareIndex22 = indexConversions.get22IndexFrom28Index(index28); housesOnSet = propertyOwners.getHousesOnSet(squareIndex22); if (propertiesToPlayer[index28] && housesOnSet > 0) { totalHousesCost = propertyInfo.getHousePropertyHouseCost(squareIndex22); totalHousesCost = totalHousesCost * housesOnSet; turnResults.addPlayerCash(tradePlayer, totalHousesCost); propertyOwners.removeAllHousesInSet(tradePlayer, squareIndex22); }//END IF if (propertiesToTradePlayer[index28] && housesOnSet > 0) { totalHousesCost = propertyInfo.getHousePropertyHouseCost(squareIndex22); totalHousesCost = totalHousesCost * housesOnSet; turnResults.addPlayerCash(currentPlayer, totalHousesCost); propertyOwners.removeAllHousesInSet(currentPlayer, squareIndex22); } //END IF } //END IF } //END FOR propertyOwners.makeTrade( currentPlayer, tradePlayer, propertiesToPlayer, propertiesToTradePlayer); return(turnResults); }
//--------------------------------------------------------------------- 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); }
//--------------------------------------------------------------------- //BUY HOUSES----------------------------------------------------------- //--------------------------------------------------------------------- public TurnResults buyHouses(int player, int[] houses, TurnResults turnResults) { //SQUARE IS FROM PROPERTIES THAT BUY HOUSES 22 //ADD HOUSES TO TOTAL return(boardProperties.addHouses(player, houses, turnResults)); }
//--------------------------------------------------------------------- public TurnResults mortgageUnmortgage(Boolean[] mortgageProperties, TurnResults turnResults, int player) { //FLIP ALL PROPERTIES THAT ARE TRUE return(boardProperties.mortgageUnmortgage(mortgageProperties, turnResults, player)); }
//--------------------------------------------------------------------- private TurnResults processBattle(TurnResults turnResults, int squareIndex40, Jail jail) { int[] battlePlayers; int numberOfBattlePlayers; int propertyValue = 0; int squareIndex28 = 0; numberOfBattlePlayers = getNumberOfBattlePlayersOnSquare(squareIndex40, jail); if (numberOfBattlePlayers >= 2) { battlePlayers = new int[numberOfBattlePlayers]; Array.Copy(getBattlePlayersOnSquare(squareIndex40, jail), battlePlayers, battlePlayers.Length); if (squareIndex40 == 0) { // 0 GO propertyValue = 400; } else if (squareIndex40 == 10) { // 10 Jail propertyValue = 200; } else if (squareIndex40 == 20) { // 20 Free Parking propertyValue = 500; } else if (squareIndex40 == 4) { // 4 Income Tax propertyValue = 200; } else if (squareIndex40 == 38) { // 38 Luxury Tax propertyValue = 75; } else if (squareIndex40 == 7 || squareIndex40 == 22 || squareIndex40 == 36) { // 7 Chance 1 // 22 Chance 2 // 36 Chance 3 propertyValue = 200; } else if (squareIndex40 == 2 || squareIndex40 == 17 || squareIndex40 == 33) { // 2 Community Chest 1 // 17 Community Chest 2 // 33 Community Chest 3 propertyValue = 200; } else if (squareIndex40 == 12 || squareIndex40 == 28) { // 12 Electric Company // 28 Water Works squareIndex28 = indexConversions.get28IndexFrom40Index(squareIndex40); propertyValue = boardProperties.getPropertyPrice(squareIndex28); } else if (squareIndex40 == 5 || squareIndex40 == 15 || squareIndex40 == 25 || squareIndex40 == 35) { // 5 Reading Railroad // 15 Pennsylvania Railroad // 25 B&O Railroad // 35 Short Line squareIndex28 = indexConversions.get28IndexFrom40Index(squareIndex40); propertyValue = boardProperties.getPropertyPrice(squareIndex28); } else if (squareIndex40 == 1 || squareIndex40 == 3 || squareIndex40 == 6 || squareIndex40 == 8 || squareIndex40 == 9 || squareIndex40 == 11 || squareIndex40 == 13 || squareIndex40 == 14 || squareIndex40 == 16 || squareIndex40 == 18 || squareIndex40 == 19 || squareIndex40 == 21 || squareIndex40 == 23 || squareIndex40 == 24 || squareIndex40 == 26 || squareIndex40 == 27 || squareIndex40 == 29 || squareIndex40 == 31 || squareIndex40 == 32 || squareIndex40 == 34 || squareIndex40 == 37 || squareIndex40 == 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 squareIndex28 = indexConversions.get28IndexFrom40Index(squareIndex40); propertyValue = boardProperties.getPropertyPrice(squareIndex28); }//END IF turnResults.setValues(battle.battle(battlePlayers, propertyValue, turnResults, displayResources)); }//END IF return(turnResults); }