mirror of https://github.com/FreeCol/freecol.git
Add priority to UnitType.
This commit is contained in:
parent
244a3fc80d
commit
dc026ed9b9
|
@ -1408,7 +1408,8 @@
|
|||
<!-- ATTENTION: skill-taught can NOT be inherited because it
|
||||
defaults to the unit type itself! -->
|
||||
<unit-type id="colonist" abstract="true"
|
||||
offence="0" defence="1" movement="3" line-of-sight="1">
|
||||
offence="0" defence="1" movement="3" line-of-sight="1"
|
||||
priority="1000">
|
||||
<ability id="model.ability.person"
|
||||
value="true"/>
|
||||
<ability id="model.ability.foundColony"
|
||||
|
|
|
@ -409,6 +409,9 @@
|
|||
<xs:attribute name="maximum-experience" type="xs:nonNegativeInteger"/>
|
||||
<xs:attribute name="maximum-attrition" type="xs:nonNegativeInteger"/>
|
||||
<xs:attribute name="increasing-price" type="xs:nonNegativeInteger"/>
|
||||
<!-- @compat 0.11.3: drop optional in due course -->
|
||||
<xs:attribute name="priority" use="optional" type="xs:nonNegativeInteger"/>
|
||||
<!-- end @compat 0.11.3 -->
|
||||
<!-- @compat 0.11.3 -->
|
||||
<xs:attribute name="defaultUnit" use="optional" type="xs:boolean"/>
|
||||
<xs:attribute name="lineOfSight" use="optional" type="xs:nonNegativeInteger"/>
|
||||
|
|
|
@ -82,6 +82,7 @@
|
|||
0.103: incrementType -> increment-type
|
||||
0.104: Fix capitalization in Scope.
|
||||
0.105: Fix capitalization in Operand.
|
||||
0.106: Add priority to unit-type.
|
||||
-->
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
|
||||
<xs:annotation>
|
||||
|
@ -535,6 +536,10 @@
|
|||
<xs:attribute name="space" type="xs:nonNegativeInteger"/>
|
||||
<xs:attribute name="space-taken" type="xs:nonNegativeInteger"/>
|
||||
|
||||
<!-- @compat 0.11.3: drop optional in due course -->
|
||||
<xs:attribute name="priority" use="optional" type="xs:nonNegativeInteger"/>
|
||||
<!-- end @compat 0.11.3 -->
|
||||
|
||||
<!-- @compat 0.11.3 -->
|
||||
<xs:attribute name="defaultUnit" use="optional" type="xs:boolean"/>
|
||||
<xs:attribute name="hitPoints" type="xs:nonNegativeInteger"/>
|
||||
|
|
|
@ -171,17 +171,15 @@ public class BuildQueue<T extends BuildableType> implements Consumer {
|
|||
.getBoolean(GameOptions.SAVE_PRODUCTION_OVERFLOW);
|
||||
List<AbstractGoods> consumption = new ArrayList<>();
|
||||
for (AbstractGoods ag : current.getRequiredGoods()) {
|
||||
boolean satisfied = false;
|
||||
AbstractGoods available = AbstractGoods.findByType(ag.getType(), input);
|
||||
AbstractGoods available
|
||||
= AbstractGoods.findByType(ag.getType(), input);
|
||||
if (available != null
|
||||
&& ag.getAmount() <= available.getAmount()) {
|
||||
int amount = (overflow || ag.getType().isStorable())
|
||||
? ag.getAmount()
|
||||
: available.getAmount();
|
||||
consumption.add(new AbstractGoods(ag.getType(), amount));
|
||||
satisfied = true;
|
||||
}
|
||||
if (!satisfied) { // don't build anything
|
||||
} else { // don't build anything
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1909,7 +1909,7 @@ public class Colony extends Settlement implements Nameable, TradeLocation {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all {@link Consumer}s in the colony sorted by
|
||||
* Get a list of all {@link Consumer}s in the colony sorted by
|
||||
* priority. Consumers include all object that consume goods,
|
||||
* e.g. Units, Buildings and BuildQueues.
|
||||
*
|
||||
|
|
|
@ -97,6 +97,9 @@ public final class UnitType extends BuildableType implements Consumer {
|
|||
*/
|
||||
private int maximumAttrition = INFINITY;
|
||||
|
||||
/** Consumption order. */
|
||||
private int priority = Consumer.UNIT_PRIORITY;
|
||||
|
||||
/** The skill this UnitType teaches, mostly its own. */
|
||||
private UnitType skillTaught = null;
|
||||
|
||||
|
@ -680,8 +683,7 @@ public final class UnitType extends BuildableType implements Consumer {
|
|||
*/
|
||||
@Override
|
||||
public int getPriority() {
|
||||
// FIXME: make this configurable
|
||||
return UNIT_PRIORITY;
|
||||
return priority;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -711,6 +713,7 @@ public final class UnitType extends BuildableType implements Consumer {
|
|||
private static final String MAXIMUM_ATTRITION_TAG = "maximum-attrition";
|
||||
private static final String OFFENCE_TAG = "offence";
|
||||
private static final String PRICE_TAG = "price";
|
||||
private static final String PRIORITY_TAG = "priority";
|
||||
private static final String RECRUIT_PROBABILITY_TAG = "recruit-probability";
|
||||
private static final String SCORE_VALUE_TAG = "score-value";
|
||||
private static final String SKILL_TAG = "skill";
|
||||
|
@ -778,6 +781,8 @@ public final class UnitType extends BuildableType implements Consumer {
|
|||
if (expertProduction != null) {
|
||||
xw.writeAttribute(EXPERT_PRODUCTION_TAG, expertProduction);
|
||||
}
|
||||
|
||||
xw.writeAttribute(PRIORITY_TAG, priority);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -900,6 +905,9 @@ public final class UnitType extends BuildableType implements Consumer {
|
|||
recruitProbability = xr.getAttribute(RECRUIT_PROBABILITY_TAG,
|
||||
parent.recruitProbability);
|
||||
|
||||
// New in 0.11.4, but default is backward compatible.
|
||||
priority = xr.getAttribute(PRIORITY_TAG, Consumer.UNIT_PRIORITY);
|
||||
|
||||
skill = xr.getAttribute(SKILL_TAG, parent.skill);
|
||||
|
||||
price = xr.getAttribute(PRICE_TAG, parent.price);
|
||||
|
|
Loading…
Reference in New Issue