use of games.strategy.engine.data.GameParseException in project triplea by triplea-game.
the class UnitAttachment method setWhenHitPointsDamagedChangesInto.
private void setWhenHitPointsDamagedChangesInto(final String value) throws GameParseException {
final String[] s = value.split(":");
if (s.length != 3) {
throw new GameParseException("setWhenHitPointsDamagedChangesInto must have damage:translateAttributes:unitType " + thisErrorMsg());
}
final UnitType unitType = getData().getUnitTypeList().getUnitType(s[2]);
if (unitType == null) {
throw new GameParseException("setWhenHitPointsDamagedChangesInto: No unit type: " + s[2] + thisErrorMsg());
}
m_whenHitPointsDamagedChangesInto.put(getInt(s[0]), Tuple.of(getBool(s[1]), unitType));
}
use of games.strategy.engine.data.GameParseException in project triplea by triplea-game.
the class UnitAttachment method setConsumesUnits.
private void setConsumesUnits(final String value) throws GameParseException {
final String[] s = value.split(":");
if (s.length != 2) {
throw new GameParseException("consumesUnits must have two fields" + thisErrorMsg());
}
final String unitTypeToProduce = s[1];
// validate that this unit exists in the xml
final UnitType ut = getData().getUnitTypeList().getUnitType(unitTypeToProduce);
if (ut == null) {
throw new GameParseException("No unit called:" + unitTypeToProduce + thisErrorMsg());
}
final int n = getInt(s[0]);
if (n < 1) {
throw new GameParseException("consumesUnits must have positive values" + thisErrorMsg());
}
m_consumesUnits.put(ut, n);
}
use of games.strategy.engine.data.GameParseException in project triplea by triplea-game.
the class UnitAttachment method setWillNotFireIfPresent.
private void setWillNotFireIfPresent(final String value) throws GameParseException {
final String[] s = value.split(":");
for (final String u : s) {
final UnitType ut = getData().getUnitTypeList().getUnitType(u);
if (ut == null) {
throw new GameParseException("willNotFireIfPresent: no such unit type: " + u + thisErrorMsg());
}
m_willNotFireIfPresent.add(ut);
}
}
use of games.strategy.engine.data.GameParseException in project triplea by triplea-game.
the class UnitAttachment method getListedTerritories.
private Collection<Territory> getListedTerritories(final String[] list) throws GameParseException {
final List<Territory> territories = new ArrayList<>();
for (final String name : list) {
// Validate all territories exist
final Territory territory = getData().getMap().getTerritory(name);
if (territory == null) {
throw new GameParseException("No territory called: " + name + thisErrorMsg());
}
territories.add(territory);
}
return territories;
}
use of games.strategy.engine.data.GameParseException in project triplea by triplea-game.
the class UnitAttachment method setWhenHitPointsRepairedChangesInto.
private void setWhenHitPointsRepairedChangesInto(final String value) throws GameParseException {
final String[] s = value.split(":");
if (s.length != 3) {
throw new GameParseException("setWhenHitPointsRepairedChangesInto must have damage:translateAttributes:unitType " + thisErrorMsg());
}
final UnitType unitType = getData().getUnitTypeList().getUnitType(s[2]);
if (unitType == null) {
throw new GameParseException("setWhenHitPointsRepairedChangesInto: No unit type: " + s[2] + thisErrorMsg());
}
m_whenHitPointsRepairedChangesInto.put(getInt(s[0]), Tuple.of(getBool(s[1]), unitType));
}
Aggregations