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);
}
}
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;
}
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);
}
}
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);
}
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);
}
}
Aggregations