Field field = mapData.getField(location);
Nation nation = game.getNation(owner);
Iterator<Unit> unitsIt = field.getUnitIterator();
if (unitsIt.hasNext()) {
Unit unit = unitsIt.next();
if (!unit.getOwner().equals(nation)) {
messages.err("ConstructUnit", "You try to build a unit " +
"on a field where another nation's unit is located.");
return;
}
}
if (field.getCityOnField() != null &&
!field.getCityOnField().getOwner().equals(nation)) {
messages.err("ConstructUnit", "You try to build a unit " +
"on a field where another nation's city is located.");
return;
}
// // for now to make it run
// UnitModel aModel = nation.getUnitModel("Musketeer");
// Unit unit = aModel.constructUnit();
Unit unit = new Musketeer(field);
Long unitID = unit.getID();
this.setUnitID(unitID);
unit.setField(field);
Game.getGame().add(unit);
Game.getMapData().setUnitOwner(unit, nation);
// mapData.addUnit(unit, mapData.getField(location), nation);
notifyAfter();