Search in sources :

Example 46 with GameParseException

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));
}
Also used : UnitType(games.strategy.engine.data.UnitType) GameParseException(games.strategy.engine.data.GameParseException)

Example 47 with GameParseException

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);
}
Also used : UnitType(games.strategy.engine.data.UnitType) GameParseException(games.strategy.engine.data.GameParseException)

Example 48 with GameParseException

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);
    }
}
Also used : UnitType(games.strategy.engine.data.UnitType) GameParseException(games.strategy.engine.data.GameParseException)

Example 49 with GameParseException

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;
}
Also used : Territory(games.strategy.engine.data.Territory) ArrayList(java.util.ArrayList) GameParseException(games.strategy.engine.data.GameParseException)

Example 50 with GameParseException

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));
}
Also used : UnitType(games.strategy.engine.data.UnitType) GameParseException(games.strategy.engine.data.GameParseException)

Aggregations

GameParseException (games.strategy.engine.data.GameParseException)66 UnitType (games.strategy.engine.data.UnitType)29 PlayerID (games.strategy.engine.data.PlayerID)13 Territory (games.strategy.engine.data.Territory)7 Resource (games.strategy.engine.data.Resource)6 GameChooserEntry (games.strategy.engine.framework.ui.GameChooserEntry)3 TechAdvance (games.strategy.triplea.delegate.TechAdvance)3 IntegerMap (games.strategy.util.IntegerMap)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 EngineVersionException (games.strategy.engine.data.EngineVersionException)2 IOException (java.io.IOException)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 GameMap (games.strategy.engine.data.GameMap)1 PlayerList (games.strategy.engine.data.PlayerList)1 ProductionFrontier (games.strategy.engine.data.ProductionFrontier)1 RelationshipType (games.strategy.engine.data.RelationshipType)1 ResourceCollection (games.strategy.engine.data.ResourceCollection)1 TerritoryEffect (games.strategy.engine.data.TerritoryEffect)1 InternalDoNotExport (games.strategy.engine.data.annotations.InternalDoNotExport)1