mirror of https://github.com/FreeCol/freecol.git
Update Casas, use new UnitChangeTypes.
This commit is contained in:
parent
de5c318df5
commit
f1a752fe1e
|
@ -188,6 +188,11 @@
|
|||
<unit-type-change from="model.unit.freeColonist"
|
||||
to="model.unit.masterTobaccoPlanter" probability="4"/>
|
||||
</unit-change-type>
|
||||
<unit-change-type id="model.unitChange.foundingFather">
|
||||
<scope ability-id="model.ability.upgradeConvert" ability-value="true"/>
|
||||
<unit-type-change from="model.unit.indianConvert"
|
||||
to="model.unit.freeColonist" probability="100"/>
|
||||
</unit-change-type>
|
||||
<unit-change-type id="model.unitChange.independence">
|
||||
<unit-type-change from="model.unit.veteranSoldier"
|
||||
to="model.unit.colonialRegular" probability="100"/>
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<freecol-specification id="convertUpgrade">
|
||||
<unit-change-types>
|
||||
<unit-change-type id="model.unitChange.enterColony">
|
||||
<scope method-name="canUpgradeOnEnterColony" method-value="true"/>
|
||||
<scope ability-id="model.ability.upgradeConvert" ability-value="true"/>
|
||||
<unit-type-change from="model.unit.indianConvert"
|
||||
to="model.unit.freeColonist" probability="100"/>
|
||||
</unit-change-type>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
In case of incompatible changes, please update version number and
|
||||
XSD schema for validation.
|
||||
-->
|
||||
<freecol-specification id="classic" version="0.113">
|
||||
<freecol-specification id="classic" version="0.114">
|
||||
|
||||
<!-- Modifiers that are not attached to other game object
|
||||
types. They may be modified, but MUST NOT be removed. -->
|
||||
|
@ -1575,6 +1575,11 @@
|
|||
<unit-type-change from="model.unit.freeColonist"
|
||||
to="model.unit.masterTobaccoPlanter" probability="4"/>
|
||||
</unit-change-type>
|
||||
<unit-change-type id="model.unitChange.foundingFather">
|
||||
<scope ability-id="model.ability.upgradeConvert" ability-value="true"/>
|
||||
<unit-type-change from="model.unit.indianConvert"
|
||||
to="model.unit.freeColonist" probability="100"/>
|
||||
</unit-change-type>
|
||||
<unit-change-type id="model.unitChange.independence">
|
||||
<unit-type-change from="model.unit.veteranSoldier"
|
||||
to="model.unit.colonialRegular" probability="100"/>
|
||||
|
@ -2864,8 +2869,8 @@
|
|||
<founding-father id="model.foundingFather.bartolomeDeLasCasas"
|
||||
type="religious"
|
||||
weight1="0" weight2="5" weight3="10">
|
||||
<upgrade from-id="model.unit.indianConvert"
|
||||
to-id="model.unit.freeColonist"/>
|
||||
<ability id="model.ability.upgradeConvert"
|
||||
value="true"/>
|
||||
</founding-father>
|
||||
</founding-fathers>
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
In case of incompatible changes, please update version number and
|
||||
XSD schema for validation.
|
||||
-->
|
||||
<freecol-specification id="freecol" version="0.113" extends="classic">
|
||||
<freecol-specification id="freecol" version="0.114" extends="classic">
|
||||
|
||||
<goods-types>
|
||||
<goods-type id="model.goods.horses" is-farmed="false"
|
||||
|
|
|
@ -56,12 +56,6 @@
|
|||
<xs:attribute name="id" use="required" type="UnitTypeId"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="upgrade">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="from-id" use="required" type="UnitTypeId"/>
|
||||
<xs:attribute name="to-id" use="required" type="UnitTypeId"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:choice>
|
||||
|
||||
<xs:attribute name="id" use="required" type="xs:ID"/>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
You should have received a copy of the GNU General Public License
|
||||
along with FreeCol. If not, see http://www.gnu.org/licenses
|
||||
|
||||
XSD for specification version 0.113
|
||||
XSD for specification version 0.114
|
||||
CHANGELOG:
|
||||
0.26: add capture-equipment
|
||||
0.27: add limits
|
||||
|
@ -111,6 +111,7 @@
|
|||
0.111: Add unit-change-types etc.
|
||||
0.112: Added rebel-factor attribute to building-type.
|
||||
0.113: Added competence-factor attribute to building-type.
|
||||
0.114: Drop upgrade element from founding-father.
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
|
||||
|
|
|
@ -407,6 +407,10 @@ public final class Ability extends Feature {
|
|||
public static final String UNDEAD
|
||||
= "model.ability.undead";
|
||||
|
||||
/** Upgrade converts to free colonist with Casas. */
|
||||
public static final String UPGRADE_CONVERT
|
||||
= "model.ability.upgradeConvert";
|
||||
|
||||
|
||||
/** The ability value. */
|
||||
private boolean value = true;
|
||||
|
|
|
@ -71,9 +71,6 @@ public class FoundingFather extends FreeColSpecObjectType {
|
|||
/** The events triggered by this Founding Father. */
|
||||
private List<Event> events = null;
|
||||
|
||||
/** Holds the upgrades of Units caused by this FoundingFather. */
|
||||
private Map<UnitType, UnitType> upgrades = null;
|
||||
|
||||
/** A list of AbstractUnits generated by this FoundingFather. */
|
||||
private List<AbstractUnit> units = null;
|
||||
|
||||
|
@ -170,38 +167,6 @@ public class FoundingFather extends FreeColSpecObjectType {
|
|||
events.add(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the upgrades triggered by this Founding Father.
|
||||
*
|
||||
* @return A map of old to new {@code UnitType}s.
|
||||
*/
|
||||
public final Map<UnitType, UnitType> getUpgrades() {
|
||||
return (upgrades == null) ? Collections.<UnitType, UnitType>emptyMap()
|
||||
: upgrades;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the upgrades triggered by this Founding Father.
|
||||
*
|
||||
* Public for the test suite.
|
||||
*
|
||||
* @param newUpgrades The new upgrades map.
|
||||
*/
|
||||
public final void setUpgrades(final Map<UnitType, UnitType> newUpgrades) {
|
||||
this.upgrades = newUpgrades;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an upgrade.
|
||||
*
|
||||
* @param fromType The initial {@code UnitType}.
|
||||
* @param toType The upgraded {@code UnitType}.
|
||||
*/
|
||||
private void addUpgrade(UnitType fromType, UnitType toType) {
|
||||
if (upgrades == null) upgrades = new HashMap<>();
|
||||
upgrades.put(fromType, toType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the units this father supplies.
|
||||
*
|
||||
|
@ -253,8 +218,10 @@ public class FoundingFather extends FreeColSpecObjectType {
|
|||
private static final String TO_ID_TAG = "to-id";
|
||||
private static final String TYPE_TAG = "type";
|
||||
private static final String UNIT_TAG = "unit";
|
||||
private static final String UPGRADE_TAG = "upgrade";
|
||||
private static final String WEIGHT_TAG = "weight";
|
||||
// @compat 0.11.6
|
||||
private static final String UPGRADE_TAG = "upgrade";
|
||||
// end @compat 0.11.6
|
||||
|
||||
|
||||
/**
|
||||
|
@ -287,18 +254,6 @@ public class FoundingFather extends FreeColSpecObjectType {
|
|||
|
||||
xw.writeEndElement();
|
||||
}
|
||||
|
||||
if (upgrades != null) {
|
||||
for (Map.Entry<UnitType, UnitType> entry : upgrades.entrySet()) {
|
||||
xw.writeStartElement(UPGRADE_TAG);
|
||||
|
||||
xw.writeAttribute(FROM_ID_TAG, entry.getKey().getId());
|
||||
|
||||
xw.writeAttribute(TO_ID_TAG, entry.getValue().getId());
|
||||
|
||||
xw.writeEndElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -324,7 +279,6 @@ public class FoundingFather extends FreeColSpecObjectType {
|
|||
if (xr.shouldClearContainers()) {
|
||||
events = null;
|
||||
units = null;
|
||||
upgrades = null;
|
||||
}
|
||||
|
||||
super.readChildren(xr);
|
||||
|
@ -338,20 +292,17 @@ public class FoundingFather extends FreeColSpecObjectType {
|
|||
final Specification spec = getSpecification();
|
||||
final String tag = xr.getLocalName();
|
||||
|
||||
if (UPGRADE_TAG.equals(tag)) {
|
||||
UnitType fromType = xr.getType(spec, FROM_ID_TAG, UnitType.class,
|
||||
(UnitType)null);
|
||||
UnitType toType = xr.getType(spec, TO_ID_TAG, UnitType.class,
|
||||
(UnitType)null);
|
||||
addUpgrade(fromType, toType);
|
||||
xr.closeTag(UPGRADE_TAG);
|
||||
|
||||
} else if (UNIT_TAG.equals(tag)) {
|
||||
if (UNIT_TAG.equals(tag)) {
|
||||
addUnit(new AbstractUnit(xr));
|
||||
|
||||
} else if (Event.TAG.equals(tag)) {
|
||||
addEvent(new Event(xr, spec));
|
||||
|
||||
// @compat 0.11.6
|
||||
} else if (UPGRADE_TAG.equals(tag)) {
|
||||
xr.closeTag(UPGRADE_TAG);
|
||||
// end @compat 0.11.6
|
||||
|
||||
} else {
|
||||
super.readChild(xr);
|
||||
}
|
||||
|
|
|
@ -2379,6 +2379,16 @@ public final class Specification {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// <upgrade> element dropped from FoundingFather, replaced by an
|
||||
// ability. Only impacts Casas.
|
||||
FoundingFather casas
|
||||
= getFoundingFather("model.foundingFather.bartolomeDeLasCasas");
|
||||
if (casas != null && !casas.hasAbility(Ability.UPGRADE_CONVERT)) {
|
||||
Ability uc = new Ability(Ability.UPGRADE_CONVERT, casas, true);
|
||||
addAbility(uc);
|
||||
casas.addAbility(uc);
|
||||
}
|
||||
// end @compat 0.11.6
|
||||
}
|
||||
|
||||
|
|
|
@ -1440,15 +1440,6 @@ public class Unit extends GoodsLocation
|
|||
&& getTeachingType(teacher) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Support for the convertUpgrade mod.
|
||||
*
|
||||
* @return True if the convert upgrade mod is enabled and Casas elected.
|
||||
*/
|
||||
public boolean canUpgradeOnEnterColony() {
|
||||
return getOwner().hasAbility("model.ability.upgradeConvertsAtColony");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the nationality of this Unit.
|
||||
*
|
||||
|
|
|
@ -74,6 +74,10 @@ public class UnitChangeType extends FreeColSpecObjectType {
|
|||
public static final String EXPERIENCE
|
||||
= "model.unitChange.experience";
|
||||
|
||||
/** Change when a founding father is elected. */
|
||||
public static final String FOUNDING_FATHER
|
||||
= "model.unitChange.foundingFather";
|
||||
|
||||
/** Changes at declaration of independence. */
|
||||
public static final String INDEPENDENCE
|
||||
= "model.unitChange.independence";
|
||||
|
|
|
@ -1943,14 +1943,15 @@ outer: for (Effect effect : effects) {
|
|||
europeDirty = true;
|
||||
}
|
||||
|
||||
java.util.Map<UnitType, UnitType> upgrades = father.getUpgrades();
|
||||
if (upgrades != null) {
|
||||
UnitChangeType uct
|
||||
= spec.getUnitChangeType(UnitChangeType.FOUNDING_FATHER);
|
||||
if (uct != null && uct.appliesTo(this)) {
|
||||
for (Unit u : getUnitList()) {
|
||||
UnitType newType = upgrades.get(u.getType());
|
||||
if (newType != null) {
|
||||
u.changeType(newType);//-vis(this)
|
||||
for (UnitChange uc : uct.getUnitChanges(u.getType())) {
|
||||
u.changeType(uc.to);//-vis(this)
|
||||
visibilityChange = true;
|
||||
cs.add(See.perhaps(), u);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,6 +85,8 @@ public class IndividualFatherTest extends FreeColTestCase {
|
|||
= spec().getUnitType("model.unit.freeColonist");
|
||||
private static final UnitType statesmanType
|
||||
= spec().getUnitType("model.unit.elderStatesman");
|
||||
private static final UnitType nativeConvertType
|
||||
= spec().getUnitType("model.unit.indianConvert");
|
||||
|
||||
|
||||
public void testBolivar() {
|
||||
|
@ -202,27 +204,13 @@ public class IndividualFatherTest extends FreeColTestCase {
|
|||
Game game = getGame();
|
||||
game.setMap(getTestMap(true));
|
||||
|
||||
java.util.Map<UnitType, UnitType> upgrades
|
||||
= bartolomeDeLasCasas.getUpgrades();
|
||||
|
||||
assertFalse(upgrades.isEmpty());
|
||||
forEachMapEntry(upgrades, e -> {
|
||||
assertEquals(e.getKey(),
|
||||
spec().getUnitType(e.getKey().getId()));
|
||||
assertEquals(e.getValue(),
|
||||
spec().getUnitType(e.getValue().getId()));
|
||||
});
|
||||
|
||||
Colony colony = getStandardColony(4);
|
||||
ServerPlayer player = (ServerPlayer)colony.getOwner();
|
||||
Unit unit = colony.getUnitList().get(0);
|
||||
|
||||
java.util.Map.Entry<UnitType, UnitType> entry
|
||||
= first(upgrades.entrySet());
|
||||
unit.setType(entry.getKey());
|
||||
|
||||
unit.setType(nativeConvertType);
|
||||
|
||||
player.csAddFoundingFather(bartolomeDeLasCasas, null, new ChangeSet());
|
||||
assertEquals(unit.getType(), entry.getValue());
|
||||
assertEquals(unit.getType(), colonistType);
|
||||
}
|
||||
|
||||
public void testDeWitt() {
|
||||
|
|
|
@ -1844,30 +1844,6 @@ public class InGameControllerTest extends FreeColTestCase {
|
|||
|| (colonistType == types[1] && statesmanType == types[0]));
|
||||
}
|
||||
|
||||
public void testAddFatherUpgrades() {
|
||||
final Game game = ServerTestHelper.startServerGame(getTestMap());
|
||||
final InGameController igc = ServerTestHelper.getInGameController();
|
||||
|
||||
Colony colony = getStandardColony(4);
|
||||
colony.getUnitList().get(0).setType(colonistType);
|
||||
colony.getUnitList().get(1).setType(colonistType);
|
||||
colony.getUnitList().get(2).setType(colonistType);
|
||||
colony.getUnitList().get(3).setType(indenturedServantType);
|
||||
|
||||
FoundingFather father = new FoundingFather("father", spec());
|
||||
father.setType(FoundingFatherType.TRADE);
|
||||
java.util.Map<UnitType, UnitType> upgrades = new HashMap<>();
|
||||
upgrades.put(indenturedServantType, colonistType);
|
||||
upgrades.put(colonistType, statesmanType);
|
||||
father.setUpgrades(upgrades);
|
||||
igc.addFoundingFather((ServerPlayer)colony.getOwner(), father);
|
||||
|
||||
assertEquals(statesmanType, colony.getUnitList().get(0).getType());
|
||||
assertEquals(statesmanType, colony.getUnitList().get(1).getType());
|
||||
assertEquals(statesmanType, colony.getUnitList().get(2).getType());
|
||||
assertEquals(colonistType, colony.getUnitList().get(3).getType());
|
||||
}
|
||||
|
||||
public void testAddFatherBuildingEvent() {
|
||||
final Game game = ServerTestHelper.startServerGame(getTestMap());
|
||||
final InGameController igc = ServerTestHelper.getInGameController();
|
||||
|
|
Loading…
Reference in New Issue