/* * Conditions must apply: * no other player's settlement must be present at this location or, within 1 road's distance. * if a settlement exists player must have required resources: * must have required resources: Brick, Wood, Wheat, Sheep * */ public void buildSettlement(Player currentPlayer, bool takeResources, bool connectionCheck) { if (owningPlayer == null) { if (takeResources && !Bank.hasPayment(currentPlayer, Bank.SETTLEMENT_COST)) { throw new BuildError(BuildError.NOT_ENOUGH_RESOURCES); } if (!checkForOtherSettlement()) { throw new BuildError(BuildError.SETTLEMENT_TOO_CLOSE); } if (connectionCheck && !checkForConnection(currentPlayer)) { throw new BuildError(BuildError.NO_CONNECTION_SETTLEMENT); } setOwningPlayer(currentPlayer); currentPlayer.addSettlement(this); } else if (owningPlayer == currentPlayer) { if (!Bank.hasPayment(currentPlayer, Bank.CITY_COST)) { throw new BuildError(BuildError.NOT_ENOUGH_RESOURCES); } if (isCity) { throw new BuildError(BuildError.IS_CITY); } this.isCity = true; this.image = new Bitmap("Resources/city.png"); } else { throw new BuildError(BuildError.LocationOwnedBy(owningPlayer)); } this.Refresh(); }
/** * Add condition: * Must have either a road or a settlement with matching player. */ public void buildRoad(Player currentPlayer, bool takeResources) { if (owningPlayer != null) { throw new BuildError(BuildError.LocationOwnedBy(owningPlayer)); } if (takeResources && !Bank.hasPayment(currentPlayer, Bank.ROAD_COST)) { throw new BuildError(BuildError.NOT_ENOUGH_RESOURCES); } if (!checkForConnection(currentPlayer)) { throw new BuildError(BuildError.NO_CONNECTED_ROAD); } this.owningPlayer = currentPlayer; //this.BackColor = currentPlayer.getPlayerColor(); currentPlayer.addRoad(this); this.Refresh(); }