/** * Get the range of gifts available to a unit. * * @param unit The <code>Unit</code> to check. * @return A range of gifts, or null if none applicable. */ public final RandomRange getGifts(Unit unit) { if (gifts == null) return null; for (RandomRange range : gifts) { List<Scope> scopes = range.getScopes(); if (scopes.isEmpty()) return range; for (Scope scope : scopes) { if (scope.appliesTo(unit)) return range; } } return null; }
/** {@inheritDoc} */ @Override protected void writeChildren(FreeColXMLWriter xw) throws XMLStreamException { super.writeChildren(xw); if (plunder != null) { for (RandomRange range : plunder) range.toXML(xw, PLUNDER_TAG); } if (gifts != null) { for (RandomRange range : gifts) range.toXML(xw, GIFTS_TAG); } }
/** * Gets the plunder range available for the supplied unit. * * @param unit The <code>Unit</code> to check. * @return The plunder range, or null if none applicable. */ public final RandomRange getPlunderRange(Unit unit) { if (plunder == null) return null; for (RandomRange range : plunder) { List<Scope> scopes = range.getScopes(); if (scopes.isEmpty()) return range; for (Scope scope : scopes) { if (scope.appliesTo(unit)) return range; } } return null; }