Search in sources :

Example 41 with PlayerID

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

the class GameDataExporter method playerRepair.

private void playerRepair(final GameData data) {
    for (final PlayerID player : data.getPlayerList()) {
        try {
            final String playerRepair = player.getRepairFrontier().getName();
            final String playername = player.getName();
            xmlfile.append("        <playerRepair player=\"").append(playername).append("\" frontier=\"").append(playerRepair).append("\"/>\n");
        } catch (final NullPointerException npe) {
        // neutral?
        }
    }
}
Also used : PlayerID(games.strategy.engine.data.PlayerID)

Example 42 with PlayerID

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

the class GameDataExporter method playertechs.

private static String playertechs(final GameData data) {
    final StringBuilder returnValue = new StringBuilder();
    for (final PlayerID player : data.getPlayerList()) {
        if (player.getTechnologyFrontierList().getFrontiers().size() > 0) {
            returnValue.append("        <playerTech player=\"").append(player.getName()).append("\">\n");
            for (final TechnologyFrontier frontier : player.getTechnologyFrontierList().getFrontiers()) {
                returnValue.append("            <category name=\"").append(frontier.getName()).append("\">\n");
                for (final TechAdvance tech : frontier.getTechs()) {
                    String name = tech.getName();
                    final String cat = tech.getProperty();
                    for (final String definedName : TechAdvance.ALL_PREDEFINED_TECHNOLOGY_NAMES) {
                        if (definedName.equals(name)) {
                            name = cat;
                        }
                    }
                    returnValue.append("                <tech name=\"").append(name).append("\"/>\n");
                }
                returnValue.append("            </category>\n");
            }
            returnValue.append("        </playerTech>\n");
        }
    }
    return returnValue.toString();
}
Also used : PlayerID(games.strategy.engine.data.PlayerID) TechAdvance(games.strategy.triplea.delegate.TechAdvance) TechnologyFrontier(games.strategy.engine.data.TechnologyFrontier)

Example 43 with PlayerID

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

the class ProUtils method getEnemyPlayers.

private static List<PlayerID> getEnemyPlayers(final PlayerID player) {
    final GameData data = ProData.getData();
    final List<PlayerID> enemyPlayers = new ArrayList<>();
    for (final PlayerID players : data.getPlayerList().getPlayers()) {
        if (!data.getRelationshipTracker().isAllied(player, players)) {
            enemyPlayers.add(players);
        }
    }
    return enemyPlayers;
}
Also used : PlayerID(games.strategy.engine.data.PlayerID) GameData(games.strategy.engine.data.GameData) ArrayList(java.util.ArrayList)

Example 44 with PlayerID

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

the class ProUtils method getLiveAlliedCapitals.

public static List<Territory> getLiveAlliedCapitals(final GameData data, final PlayerID player) {
    final List<Territory> capitals = new ArrayList<>();
    final List<PlayerID> players = getAlliedPlayers(player);
    for (final PlayerID alliedPlayer : players) {
        capitals.addAll(TerritoryAttachment.getAllCurrentlyOwnedCapitals(alliedPlayer, data));
    }
    capitals.retainAll(CollectionUtils.getMatches(capitals, Matches.territoryIsNotImpassableToLandUnits(player, data)));
    capitals.retainAll(CollectionUtils.getMatches(capitals, Matches.isTerritoryAllied(player, data)));
    return capitals;
}
Also used : PlayerID(games.strategy.engine.data.PlayerID) Territory(games.strategy.engine.data.Territory) ArrayList(java.util.ArrayList)

Example 45 with PlayerID

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

the class ProUtils method getAlliedPlayers.

private static List<PlayerID> getAlliedPlayers(final PlayerID player) {
    final GameData data = ProData.getData();
    final List<PlayerID> alliedPlayers = new ArrayList<>();
    for (final PlayerID players : data.getPlayerList().getPlayers()) {
        if (data.getRelationshipTracker().isAllied(player, players)) {
            alliedPlayers.add(players);
        }
    }
    return alliedPlayers;
}
Also used : PlayerID(games.strategy.engine.data.PlayerID) GameData(games.strategy.engine.data.GameData) ArrayList(java.util.ArrayList)

Aggregations

PlayerID (games.strategy.engine.data.PlayerID)323 Territory (games.strategy.engine.data.Territory)163 Unit (games.strategy.engine.data.Unit)133 Test (org.junit.jupiter.api.Test)122 TripleAUnit (games.strategy.triplea.TripleAUnit)104 ITestDelegateBridge (games.strategy.engine.data.ITestDelegateBridge)94 GameData (games.strategy.engine.data.GameData)90 ArrayList (java.util.ArrayList)79 UnitType (games.strategy.engine.data.UnitType)74 Route (games.strategy.engine.data.Route)67 ScriptedRandomSource (games.strategy.engine.random.ScriptedRandomSource)46 HashSet (java.util.HashSet)44 Change (games.strategy.engine.data.Change)29 CompositeChange (games.strategy.engine.data.CompositeChange)29 IntegerMap (games.strategy.util.IntegerMap)29 List (java.util.List)29 HashMap (java.util.HashMap)28 Collection (java.util.Collection)27 Resource (games.strategy.engine.data.Resource)25 UnitAttachment (games.strategy.triplea.attachments.UnitAttachment)23