public GameState BuildCity(Player player, Intersection intersection)
{
var r = player.Resources;
if (!(r.Count(c => c == Resource.Ore) >= 3 && r.Count(c => c == Resource.Grain) >= 2))
throw new InsufficientResourcesException("Not enough resources to buy a city");
if (player.CitiesLeft == 0)
throw new IllegalActionException("No more city pieces left of your color");
Piece piece = board.GetPiece(intersection);
if (piece == null || piece.Player != player.Id || piece.Token != Token.Settlement)
throw new IllegalBuildPositionException("The chosen position does not contain one of your settlements");
PayResource(player, Resource.Ore, 3);
PayResource(player, Resource.Grain, 2);
Log(new BuildPieceLogEvent(player.Id, Token.City, intersection));
player.CitiesLeft--;
player.SettlementsLeft++;
board = board.PlacePiece(intersection, new Piece(Token.City, player.Id));
return CurrentGamestate();
}