BuildFirstRoad() public method

Let a player build a road without a requirement for connectivity and free of charge The road may not be placed on top of another road Connectivity with previously placed settlement should be controlled elsewhere (in StartActions.cs)
public BuildFirstRoad ( Player player, Edge edge ) : GameState
player Player The player placing the road
edge Edge The edge to build the road on
return GameState
Ejemplo n.º 1
0
 /// <summary>
 /// Build a road on the board
 /// If you try to build at a position not connected to the newly placed settlement an IllegalBuildPositionException is thrown
 /// If you try to build more than one road an IllegalActionException is thrown
 /// </summary>
 /// <param name="firstTile">The first tile that the road will be along</param>
 /// <param name="secondTile">The second tile that the road will be along</param>
 public void BuildRoad(Edge edge)
 {
     if (roadBuilt)
     {
         throw new IllegalActionException("Only one road may be built in a turn during the startup");
     }
     if (!settlementBuilt)
     {
         throw new IllegalActionException("The settlement must be placed before the road");
     }
     int[] array = new int[] { settlementPosition.FirstTile, settlementPosition.SecondTile, settlementPosition.ThirdTile };
     if (!(array.Contains(edge.FirstTile) && array.Contains(edge.SecondTile)))
     {
         throw new IllegalBuildPositionException("The road must be placed next to the settlement");
     }
     roadPosition = edge;
     controller.BuildFirstRoad(player, edge);
     roadBuilt = true;
 }