}
public void execute() {
notifyBefore();
Messages messages = Messages.getMessages();
MapData mapData = Game.getMapData();
Field field = mapData.getField(location);
Nation nation = Game.getGame().getNation(ownerNation);
Iterator<Unit> unitsIt = field.getUnitIterator();
if (unitsIt.hasNext()) {
Unit unit = unitsIt.next();
if (!unit.getOwner().equals(nation)) {
messages.err("ConstructCity", "You try to build a city " +
"on a field where another nation's unit is located.");
return;
}
}
if (field.getCityOnField() != null &&
!field.getCityOnField().getOwner().equals(nation)) {
messages.err("ConstructCity", "You try to build a city " +
"on a field where another nation's city is located.");
return;
}
City city = new City(field, "New City");
Game.getGame().add(city);
mapData.setCityOwner(city, nation);
// mapData.addCity(city, field, nation);
setCityID(city.getID());
notifyAfter();