Search in sources :

Example 36 with GameParseException

use of games.strategy.engine.data.GameParseException in project triplea by triplea-game.

the class TriggerAttachment method setTech.

private void setTech(final String techs) throws GameParseException {
    for (final String subString : techs.split(":")) {
        TechAdvance ta = getData().getTechnologyFrontier().getAdvanceByProperty(subString);
        if (ta == null) {
            ta = getData().getTechnologyFrontier().getAdvanceByName(subString);
        }
        if (ta == null) {
            throw new GameParseException("Technology not found :" + subString + thisErrorMsg());
        }
        m_tech.add(ta);
    }
}
Also used : TechAdvance(games.strategy.triplea.delegate.TechAdvance) GameParseException(games.strategy.engine.data.GameParseException)

Example 37 with GameParseException

use of games.strategy.engine.data.GameParseException in project triplea by triplea-game.

the class TriggerAttachment method setResource.

private void setResource(final String s) throws GameParseException {
    if (s == null) {
        m_resource = null;
        return;
    }
    final Resource r = getData().getResourceList().getResource(s);
    if (r == null) {
        throw new GameParseException("Invalid resource: " + s + thisErrorMsg());
    }
    m_resource = s;
}
Also used : Resource(games.strategy.engine.data.Resource) GameParseException(games.strategy.engine.data.GameParseException)

Example 38 with GameParseException

use of games.strategy.engine.data.GameParseException in project triplea by triplea-game.

the class TriggerAttachment method setPlayers.

private void setPlayers(final String names) throws GameParseException {
    final String[] s = names.split(":");
    for (final String element : s) {
        final PlayerID player = getData().getPlayerList().getPlayerId(element);
        if (player == null) {
            throw new GameParseException("Could not find player. name:" + element + thisErrorMsg());
        }
        m_players.add(player);
    }
}
Also used : PlayerID(games.strategy.engine.data.PlayerID) GameParseException(games.strategy.engine.data.GameParseException)

Example 39 with GameParseException

use of games.strategy.engine.data.GameParseException in project triplea by triplea-game.

the class TriggerAttachment method setChangeOwnership.

private void setChangeOwnership(final String value) throws GameParseException {
    // territory:oldOwner:newOwner:booleanConquered
    // can have "all" for territory and "any" for oldOwner
    final String[] s = value.split(":");
    if (s.length < 4) {
        throw new GameParseException("changeOwnership must have 4 fields: territory:oldOwner:newOwner:booleanConquered" + thisErrorMsg());
    }
    if (!s[0].equalsIgnoreCase("all")) {
        final Territory t = getData().getMap().getTerritory(s[0]);
        if (t == null) {
            throw new GameParseException("No such territory: " + s[0] + thisErrorMsg());
        }
    }
    if (!s[1].equalsIgnoreCase("any")) {
        final PlayerID oldOwner = getData().getPlayerList().getPlayerId(s[1]);
        if (oldOwner == null) {
            throw new GameParseException("No such player: " + s[1] + thisErrorMsg());
        }
    }
    final PlayerID newOwner = getData().getPlayerList().getPlayerId(s[2]);
    if (newOwner == null) {
        throw new GameParseException("No such player: " + s[2] + thisErrorMsg());
    }
    getBool(s[3]);
    m_changeOwnership.add(value);
}
Also used : PlayerID(games.strategy.engine.data.PlayerID) Territory(games.strategy.engine.data.Territory) GameParseException(games.strategy.engine.data.GameParseException)

Example 40 with GameParseException

use of games.strategy.engine.data.GameParseException in project triplea by triplea-game.

the class TriggerAttachment method setUnitType.

private void setUnitType(final String names) throws GameParseException {
    final String[] s = names.split(":");
    for (final String element : s) {
        final UnitType type = getData().getUnitTypeList().getUnitType(element);
        if (type == null) {
            throw new GameParseException("Could not find unitType. name:" + element + thisErrorMsg());
        }
        m_unitType.add(type);
    }
}
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