public GameState BuildRoad(Player player, Edge edge)
{
var r = player.Resources;
if (!(r.Contains(Resource.Brick) && r.Contains(Resource.Lumber)))
throw new InsufficientResourcesException("Not enough resources to buy a road");
if (player.RoadsLeft == 0)
throw new IllegalActionException("No more road pieces left of your color");
if (board.GetRoad(edge) != -1)
throw new IllegalBuildPositionException("The chosen position is occupied by another road");
if (!RoadConnected(board, edge, player.Id))
throw new IllegalBuildPositionException("The chosen position is not connected to any of your pieces");
if (!board.CanBuildRoad(edge))
throw new IllegalBuildPositionException("The chosen position is not valid");
PayResource(player, Resource.Brick);
PayResource(player, Resource.Lumber);
Log(new BuildRoadLogEvent(player.Id, edge));
player.RoadsLeft--;
board = board.PlaceRoad(edge, player.Id);
UpdateLongestRoad();
return CurrentGamestate();
}