/** * All build options require that appropriate units are built in appropriate places (e.g., armies * can't go in the water, fleets can't go in landlocked provinces, fleets must have coasts * specified if required, etc.). This method takes care of that. * * <p>returns false if we cannot build here. */ private boolean checkBuildUnit( StateInfo stateInfo, Province province, Location loc, StringBuffer sb) { if (srcUnitType == null) { sb.append(Utils.getLocalString(NOBUILD_NO_UNIT_SELECTED)); return false; } if (srcUnitType.equals(Unit.Type.ARMY)) { if (province.isSea()) { sb.append(Utils.getLocalString(NOBUILD_NO_ARMY_IN_SEA)); return false; } else { // check borders if (!GUIOrderUtils.checkBorder(this, loc, srcUnitType, stateInfo.getPhase(), sb)) { return false; } sb.append(Utils.getLocalString(BUILD_ARMY_OK)); return true; } } else if (srcUnitType.equals(Unit.Type.FLEET)) { if (province.isLandLocked()) { sb.append(Utils.getLocalString(NOBUILD_FLEET_LANDLOCKED)); return false; } else { // check borders if (!GUIOrderUtils.checkBorder(this, loc, srcUnitType, stateInfo.getPhase(), sb)) { return false; } sb.append(Utils.getLocalString(BUILD_FLEET_OK)); return true; } } else if (srcUnitType.equals(Unit.Type.WING)) { // check borders if (!GUIOrderUtils.checkBorder(this, loc, srcUnitType, stateInfo.getPhase(), sb)) { return false; } sb.append(Utils.getLocalString(BUILD_WING_OK)); return true; } // this should not occur. sb.append("** Unknown unit type! **"); return false; } // checkBuildUnit()