Example #1
0
 /**
  * The art of placing a settlement on the vertex.
  *
  * @pre the Can do is true
  * @param vertexLocation
  * @throws Exception
  * @post a settlement is placed on a vertex
  */
 public void placeSettlementOnVertex(int UserId, VertexLocation vertexLocation) throws Exception {
   if (canDoPlaceSettlementOnVertex(UserId, vertexLocation) == false) {
     throw new Exception(
         "Cannot build Settlement on this vertex, this should not have been allowed to get this far.");
   }
   // If we are in the first two rounds of the game
   if (turnNumber < 2) {
     board.placeInitialSettlementOnVertex(currentPlayer, vertexLocation);
     versionNumber++;
     // Here we collect the resources for the second placed settlement in setup round
     if (turnNumber == 1) {
       Hex[] adjacentHexes = board.getVertex(vertexLocation).getAdjacentHexes();
       for (Hex hex : adjacentHexes) {
         if (hex != null) {
           ResourceType hexResourceType = hex.getHexResourceType();
           ResourceCard card = bank.playerTakeResource(hexResourceType);
           currentPlayer.getResourceCardHand().addCard(card);
         }
       }
     }
   } else {
     board.placeSettlementOnVertex(currentPlayer, vertexLocation);
     versionNumber++;
   }
 }