Search in sources :

Example 86 with GameData

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

the class UndoablePlacement method undoSpecific.

@Override
protected final void undoSpecific(final IDelegateBridge bridge) {
    final GameData data = bridge.getData();
    final AbstractPlaceDelegate currentDelegate = (AbstractPlaceDelegate) data.getSequence().getStep().getDelegate();
    final Map<Territory, Collection<Unit>> produced = currentDelegate.getProduced();
    final Collection<Unit> units = produced.get(m_producerTerritory);
    units.removeAll(getUnits());
    if (units.isEmpty()) {
        produced.remove(m_producerTerritory);
    }
    currentDelegate.setProduced(new HashMap<>(produced));
}
Also used : Territory(games.strategy.engine.data.Territory) GameData(games.strategy.engine.data.GameData) Collection(java.util.Collection) Unit(games.strategy.engine.data.Unit)

Example 87 with GameData

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

the class HelpMenu method addUnitHelpMenu.

private void addUnitHelpMenu() {
    final String unitHelpTitle = "Unit Help";
    final JMenuItem unitMenuItem = add(SwingAction.of(unitHelpTitle, e -> {
        final JEditorPane editorPane = new JEditorPane();
        editorPane.setEditable(false);
        editorPane.setContentType("text/html");
        editorPane.setText(getUnitStatsTable(gameData, uiContext));
        editorPane.setCaretPosition(0);
        final JScrollPane scroll = new JScrollPane(editorPane);
        scroll.setBorder(BorderFactory.createEmptyBorder());
        final Dimension screenResolution = Toolkit.getDefaultToolkit().getScreenSize();
        // not only do we have a start bar, but we also have the message dialog to account for just the scroll bars plus
        // the window sides
        final int availHeight = screenResolution.height - 120;
        final int availWidth = screenResolution.width - 40;
        scroll.setPreferredSize(new Dimension((scroll.getPreferredSize().width > availWidth ? availWidth : (scroll.getPreferredSize().height > availHeight ? Math.min(availWidth, scroll.getPreferredSize().width + 22) : scroll.getPreferredSize().width)), (scroll.getPreferredSize().height > availHeight ? availHeight : (scroll.getPreferredSize().width > availWidth ? Math.min(availHeight, scroll.getPreferredSize().height + 22) : scroll.getPreferredSize().height))));
        final JDialog dialog = new JDialog((JFrame) null, unitHelpTitle);
        dialog.add(scroll, BorderLayout.CENTER);
        final JPanel buttons = new JPanel();
        final JButton button = new JButton(SwingAction.of("OK", event -> {
            dialog.setVisible(false);
            dialog.removeAll();
            dialog.dispose();
        }));
        buttons.add(button);
        dialog.getRootPane().setDefaultButton(button);
        dialog.add(buttons, BorderLayout.SOUTH);
        dialog.pack();
        dialog.addWindowListener(new WindowAdapter() {

            @Override
            public void windowOpened(final WindowEvent e) {
                scroll.getVerticalScrollBar().getModel().setValue(0);
                scroll.getHorizontalScrollBar().getModel().setValue(0);
                button.requestFocus();
            }
        });
        dialog.setVisible(true);
    }));
    unitMenuItem.setMnemonic(KeyEvent.VK_U);
    unitMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
}
Also used : Color(java.awt.Color) Rectangle(java.awt.Rectangle) SystemProperties(games.strategy.engine.framework.system.SystemProperties) SwingComponents(games.strategy.ui.SwingComponents) JDialog(javax.swing.JDialog) URL(java.net.URL) TuvUtils(games.strategy.triplea.util.TuvUtils) SwingUtilities(javax.swing.SwingUtilities) JMenuItem(javax.swing.JMenuItem) Map(java.util.Map) Application(com.apple.eawt.Application) UiContext(games.strategy.triplea.ui.UiContext) JEditorPane(javax.swing.JEditorPane) UnitType(games.strategy.engine.data.UnitType) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) ClientContext(games.strategy.engine.ClientContext) KeyStroke(javax.swing.KeyStroke) JButton(javax.swing.JButton) JLabelBuilder(swinglib.JLabelBuilder) UnitImageFactory(games.strategy.triplea.image.UnitImageFactory) JMenu(javax.swing.JMenu) BorderFactory(javax.swing.BorderFactory) KeyEvent(java.awt.event.KeyEvent) WindowAdapter(java.awt.event.WindowAdapter) JOptionPane(javax.swing.JOptionPane) WindowEvent(java.awt.event.WindowEvent) JScrollPane(javax.swing.JScrollPane) GameData(games.strategy.engine.data.GameData) Dimension(java.awt.Dimension) List(java.util.List) PlayerID(games.strategy.engine.data.PlayerID) ResourceCollection(games.strategy.engine.data.ResourceCollection) JLabel(javax.swing.JLabel) UrlConstants(games.strategy.triplea.UrlConstants) Optional(java.util.Optional) LocalizeHtml(games.strategy.util.LocalizeHtml) JPanel(javax.swing.JPanel) Toolkit(java.awt.Toolkit) SwingAction(games.strategy.ui.SwingAction) JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) JFrame(javax.swing.JFrame) WindowEvent(java.awt.event.WindowEvent) JEditorPane(javax.swing.JEditorPane) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) JMenuItem(javax.swing.JMenuItem) JDialog(javax.swing.JDialog)

Example 88 with GameData

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

the class ExportMenu method addExportUnitStats.

private void addExportUnitStats() {
    final JMenuItem menuFileExport = new JMenuItem(SwingAction.of("Export Unit Charts", e -> {
        final JFileChooser chooser = new JFileChooser();
        chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
        final File rootDir = new File(SystemProperties.getUserDir());
        String defaultFileName = gameData.getGameName() + "_unit_stats";
        defaultFileName = FileNameUtils.removeIllegalCharacters(defaultFileName);
        defaultFileName = defaultFileName + ".html";
        chooser.setSelectedFile(new File(rootDir, defaultFileName));
        if (chooser.showSaveDialog(frame) != JOptionPane.OK_OPTION) {
            return;
        }
        try (Writer writer = Files.newBufferedWriter(chooser.getSelectedFile().toPath(), StandardCharsets.UTF_8)) {
            writer.write(HelpMenu.getUnitStatsTable(gameData, uiContext).replaceAll("<p>", "<p>\r\n").replaceAll("</p>", "</p>\r\n").replaceAll("</tr>", "</tr>\r\n").replaceAll(LocalizeHtml.PATTERN_HTML_IMG_TAG, ""));
        } catch (final IOException e1) {
            ClientLogger.logQuietly("Failed to write unit stats: " + chooser.getSelectedFile().getAbsolutePath(), e1);
        }
    }));
    menuFileExport.setMnemonic(KeyEvent.VK_U);
    add(menuFileExport);
}
Also used : ExtendedStats(games.strategy.triplea.ui.ExtendedStats) Arrays(java.util.Arrays) Enumeration(java.util.Enumeration) GameDataUtils(games.strategy.engine.framework.GameDataUtils) HistoryNode(games.strategy.engine.history.HistoryNode) UnitAttachment(games.strategy.triplea.attachments.UnitAttachment) TripleAFrame(games.strategy.triplea.ui.TripleAFrame) GameDataExporter(games.strategy.engine.data.export.GameDataExporter) JFileChooser(javax.swing.JFileChooser) JFrame(javax.swing.JFrame) Round(games.strategy.engine.history.Round) ClientContext(games.strategy.engine.ClientContext) Collection(java.util.Collection) Set(java.util.Set) JMenu(javax.swing.JMenu) PlayerOrderComparator(games.strategy.triplea.util.PlayerOrderComparator) KeyEvent(java.awt.event.KeyEvent) StandardCharsets(java.nio.charset.StandardCharsets) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) HistoryPanel(games.strategy.triplea.ui.history.HistoryPanel) GameData(games.strategy.engine.data.GameData) List(java.util.List) PlayerID(games.strategy.engine.data.PlayerID) Writer(java.io.Writer) LocalizeHtml(games.strategy.util.LocalizeHtml) WindowConstants(javax.swing.WindowConstants) SwingAction(games.strategy.ui.SwingAction) SystemProperties(games.strategy.engine.framework.system.SystemProperties) SetupFrame(games.strategy.triplea.printgenerator.SetupFrame) TreeNode(javax.swing.tree.TreeNode) LocalDateTime(java.time.LocalDateTime) Action(javax.swing.Action) Resource(games.strategy.engine.data.Resource) ArrayList(java.util.ArrayList) JMenuItem(javax.swing.JMenuItem) UiContext(games.strategy.triplea.ui.UiContext) UnitType(games.strategy.engine.data.UnitType) LinkedHashSet(java.util.LinkedHashSet) JComponent(javax.swing.JComponent) Files(java.nio.file.Files) IOException(java.io.IOException) IStat(games.strategy.engine.stats.IStat) JOptionPane(javax.swing.JOptionPane) ScreenshotExporter(games.strategy.triplea.ui.export.ScreenshotExporter) File(java.io.File) ClientLogger(games.strategy.debug.ClientLogger) FileNameUtils(games.strategy.util.FileNameUtils) Step(games.strategy.engine.history.Step) DateTimeFormatter(java.time.format.DateTimeFormatter) EndRoundDelegate(games.strategy.triplea.delegate.EndRoundDelegate) ProductionRule(games.strategy.engine.data.ProductionRule) JFileChooser(javax.swing.JFileChooser) IOException(java.io.IOException) JMenuItem(javax.swing.JMenuItem) File(java.io.File) Writer(java.io.Writer)

Example 89 with GameData

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

the class ExportMenu method createAndSaveStats.

private void createAndSaveStats(final boolean showPhaseStats) {
    final ExtendedStats statPanel = new ExtendedStats(gameData, uiContext);
    final JFileChooser chooser = new JFileChooser();
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    final File rootDir = new File(SystemProperties.getUserDir());
    final int currentRound = gameData.getCurrentRound();
    String defaultFileName = "stats_" + dateTimeFormatter.format(LocalDateTime.now()) + "_" + gameData.getGameName() + "_round_" + currentRound + (showPhaseStats ? "_full" : "_short");
    defaultFileName = FileNameUtils.removeIllegalCharacters(defaultFileName);
    defaultFileName = defaultFileName + ".csv";
    chooser.setSelectedFile(new File(rootDir, defaultFileName));
    if (chooser.showSaveDialog(frame) != JOptionPane.OK_OPTION) {
        return;
    }
    final StringBuilder text = new StringBuilder(1000);
    try {
        gameData.acquireReadLock();
        final GameData clone = GameDataUtils.cloneGameData(gameData);
        final IStat[] stats = statPanel.getStats();
        // extended stats covers stuff that doesn't show up in the game stats menu bar, like custom resources or tech
        // tokens or # techs, etc.
        final IStat[] statsExtended = statPanel.getStatsExtended(gameData);
        final String[] alliances = statPanel.getAlliances().toArray(new String[0]);
        final PlayerID[] players = statPanel.getPlayers().toArray(new PlayerID[0]);
        // its important here to translate the player objects into our game data
        // the players for the stat panel are only relevant with respect to
        // the game data they belong to
        Arrays.setAll(players, i -> clone.getPlayerList().getPlayerId(players[i].getName()));
        text.append(defaultFileName).append(",");
        text.append("\n");
        text.append("TripleA Engine Version: ,");
        text.append(ClientContext.engineVersion()).append(",");
        text.append("\n");
        text.append("Game Name: ,");
        text.append(gameData.getGameName()).append(",");
        text.append("\n");
        text.append("Game Version: ,");
        text.append(gameData.getGameVersion()).append(",");
        text.append("\n");
        text.append("\n");
        text.append("Current Round: ,");
        text.append(currentRound).append(",");
        text.append("\n");
        text.append("Number of Players: ,");
        text.append(statPanel.getPlayers().size()).append(",");
        text.append("\n");
        text.append("Number of Alliances: ,");
        text.append(statPanel.getAlliances().size()).append(",");
        text.append("\n");
        text.append("\n");
        text.append("Turn Order: ,");
        text.append("\n");
        final List<PlayerID> playerOrderList = new ArrayList<>(gameData.getPlayerList().getPlayers());
        playerOrderList.sort(new PlayerOrderComparator(gameData));
        final Set<PlayerID> playerOrderSetNoDuplicates = new LinkedHashSet<>(playerOrderList);
        for (final PlayerID currentPlayerId : playerOrderSetNoDuplicates) {
            text.append(currentPlayerId.getName()).append(",");
            final Collection<String> allianceNames = gameData.getAllianceTracker().getAlliancesPlayerIsIn(currentPlayerId);
            for (final String allianceName : allianceNames) {
                text.append(allianceName).append(",");
            }
            text.append("\n");
        }
        text.append("\n");
        text.append("Winners: ,");
        final EndRoundDelegate delegateEndRound = (EndRoundDelegate) gameData.getDelegateList().getDelegate("endRound");
        if (delegateEndRound != null && delegateEndRound.getWinners() != null) {
            for (final PlayerID p : delegateEndRound.getWinners()) {
                text.append(p.getName()).append(",");
            }
        } else {
            text.append("none yet; game not over,");
        }
        text.append("\n");
        text.append("\n");
        text.append("Resource Chart: ,");
        text.append("\n");
        for (final Resource resource : gameData.getResourceList().getResources()) {
            text.append(resource.getName()).append(",");
            text.append("\n");
        }
        // if short, we won't both showing production and unit info
        if (showPhaseStats) {
            text.append("\n");
            text.append("Production Rules: ,");
            text.append("\n");
            text.append("Name,Result,Quantity,Cost,Resource,\n");
            final Collection<ProductionRule> purchaseOptions = gameData.getProductionRuleList().getProductionRules();
            for (final ProductionRule pr : purchaseOptions) {
                String costString = pr.toStringCosts().replaceAll("; ", ",");
                costString = costString.replaceAll(" ", ",");
                text.append(pr.getName()).append(",").append(pr.getResults().keySet().iterator().next().getName()).append(",").append(pr.getResults().getInt(pr.getResults().keySet().iterator().next())).append(",").append(costString).append(",");
                text.append("\n");
            }
            text.append("\n");
            text.append("Unit Types: ,");
            text.append("\n");
            text.append("Name,Listed Abilities\n");
            for (final UnitType unitType : gameData.getUnitTypeList()) {
                final UnitAttachment ua = UnitAttachment.get(unitType);
                if (ua == null) {
                    continue;
                }
                String toModify = ua.allUnitStatsForExporter();
                toModify = toModify.replaceFirst("UnitType called ", "").replaceFirst(" with:", "").replaceAll("games.strategy.engine.data.", "").replaceAll("\n", ";").replaceAll(",", ";");
                toModify = toModify.replaceAll("  ", ",");
                toModify = toModify.replaceAll(", ", ",").replaceAll(" ,", ",");
                text.append(toModify);
                text.append("\n");
            }
        }
        text.append("\n");
        text.append((showPhaseStats ? "Full Stats (includes each phase that had activity)," : "Short Stats (only shows first phase with activity per player per round),"));
        text.append("\n");
        text.append("Turn Stats: ,");
        text.append("\n");
        text.append("Round,Player Turn,Phase Name,");
        for (final IStat stat : stats) {
            for (final PlayerID player : players) {
                text.append(stat.getName()).append(" ");
                text.append(player.getName());
                text.append(",");
            }
            for (final String alliance : alliances) {
                text.append(stat.getName()).append(" ");
                text.append(alliance);
                text.append(",");
            }
        }
        for (final IStat element : statsExtended) {
            for (final PlayerID player : players) {
                text.append(element.getName()).append(" ");
                text.append(player.getName());
                text.append(",");
            }
            for (final String alliance : alliances) {
                text.append(element.getName()).append(" ");
                text.append(alliance);
                text.append(",");
            }
        }
        text.append("\n");
        clone.getHistory().gotoNode(clone.getHistory().getLastNode());
        @SuppressWarnings("unchecked") final Enumeration<TreeNode> nodes = ((DefaultMutableTreeNode) clone.getHistory().getRoot()).preorderEnumeration();
        PlayerID currentPlayer = null;
        int round = 0;
        while (nodes.hasMoreElements()) {
            // we want to export on change of turn
            final HistoryNode element = (HistoryNode) nodes.nextElement();
            if (element instanceof Round) {
                round++;
            }
            if (!(element instanceof Step)) {
                continue;
            }
            final Step step = (Step) element;
            if (step.getPlayerId() == null || step.getPlayerId().isNull()) {
                continue;
            }
            // this is to stop from having multiple entries for each players turn.
            if (!showPhaseStats) {
                if (step.getPlayerId() == currentPlayer) {
                    continue;
                }
            }
            currentPlayer = step.getPlayerId();
            clone.getHistory().gotoNode(element);
            final String playerName = step.getPlayerId() == null ? "" : step.getPlayerId().getName() + ": ";
            String stepName = step.getStepName();
            // copied directly from TripleAPlayer, will probably have to be updated in the future if more delegates are made
            if (stepName.endsWith("Bid")) {
                stepName = "Bid";
            } else if (stepName.endsWith("Tech")) {
                stepName = "Tech";
            } else if (stepName.endsWith("TechActivation")) {
                stepName = "TechActivation";
            } else if (stepName.endsWith("Purchase")) {
                stepName = "Purchase";
            } else if (stepName.endsWith("NonCombatMove")) {
                stepName = "NonCombatMove";
            } else if (stepName.endsWith("Move")) {
                stepName = "Move";
            } else if (stepName.endsWith("Battle")) {
                stepName = "Battle";
            } else if (stepName.endsWith("BidPlace")) {
                stepName = "BidPlace";
            } else if (stepName.endsWith("Place")) {
                stepName = "Place";
            } else if (stepName.endsWith("Politics")) {
                stepName = "Politics";
            } else if (stepName.endsWith("EndTurn")) {
                stepName = "EndTurn";
            } else {
                stepName = "";
            }
            text.append(round).append(",").append(playerName).append(",").append(stepName).append(",");
            for (final IStat stat : stats) {
                for (final PlayerID player : players) {
                    text.append(stat.getFormatter().format(stat.getValue(player, clone)));
                    text.append(",");
                }
                for (final String alliance : alliances) {
                    text.append(stat.getFormatter().format(stat.getValue(alliance, clone)));
                    text.append(",");
                }
            }
            for (final IStat element2 : statsExtended) {
                for (final PlayerID player : players) {
                    text.append(element2.getFormatter().format(element2.getValue(player, clone)));
                    text.append(",");
                }
                for (final String alliance : alliances) {
                    text.append(element2.getFormatter().format(element2.getValue(alliance, clone)));
                    text.append(",");
                }
            }
            text.append("\n");
        }
    } finally {
        gameData.releaseReadLock();
    }
    try (Writer writer = Files.newBufferedWriter(chooser.getSelectedFile().toPath(), StandardCharsets.UTF_8)) {
        writer.write(text.toString());
    } catch (final IOException e1) {
        ClientLogger.logQuietly("Failed to write stats: " + chooser.getSelectedFile().getAbsolutePath(), e1);
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) PlayerID(games.strategy.engine.data.PlayerID) EndRoundDelegate(games.strategy.triplea.delegate.EndRoundDelegate) GameData(games.strategy.engine.data.GameData) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) ArrayList(java.util.ArrayList) ExtendedStats(games.strategy.triplea.ui.ExtendedStats) Step(games.strategy.engine.history.Step) UnitAttachment(games.strategy.triplea.attachments.UnitAttachment) IStat(games.strategy.engine.stats.IStat) ProductionRule(games.strategy.engine.data.ProductionRule) UnitType(games.strategy.engine.data.UnitType) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreeNode(javax.swing.tree.TreeNode) Round(games.strategy.engine.history.Round) PlayerOrderComparator(games.strategy.triplea.util.PlayerOrderComparator) Resource(games.strategy.engine.data.Resource) IOException(java.io.IOException) JFileChooser(javax.swing.JFileChooser) HistoryNode(games.strategy.engine.history.HistoryNode) File(java.io.File) Writer(java.io.Writer)

Example 90 with GameData

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

the class TuvUtils method getResourceCostsForTuvForAllPlayersMergedAndAveraged.

/**
 * Return a map where key are unit types and values are the AVERAGED for all players.
 * Any production rule that produces multiple units
 * (like artillery in NWO, costs 7 but makes 2 artillery, meaning effective price is 3.5 each)
 * will have their costs rounded up on a per unit basis.
 * Therefore, this map should NOT be used for Purchasing information!
 */
private static Map<UnitType, ResourceCollection> getResourceCostsForTuvForAllPlayersMergedAndAveraged(final GameData data) {
    final Map<UnitType, ResourceCollection> average = new HashMap<>();
    final Resource pus;
    data.acquireReadLock();
    try {
        pus = data.getResourceList().getResource(Constants.PUS);
    } finally {
        data.releaseReadLock();
    }
    final IntegerMap<Resource> defaultMap = new IntegerMap<>();
    defaultMap.put(pus, 1);
    final ResourceCollection defaultResources = new ResourceCollection(data, defaultMap);
    final Map<UnitType, List<ResourceCollection>> backups = new HashMap<>();
    final Map<UnitType, ResourceCollection> backupAveraged = new HashMap<>();
    for (final ProductionRule rule : data.getProductionRuleList().getProductionRules()) {
        if (rule == null || rule.getResults() == null || rule.getResults().isEmpty() || rule.getCosts() == null || rule.getCosts().isEmpty()) {
            continue;
        }
        final IntegerMap<NamedAttachable> unitMap = rule.getResults();
        final ResourceCollection costPerGroup = new ResourceCollection(data, rule.getCosts());
        final Set<UnitType> units = new HashSet<>();
        for (final NamedAttachable resourceOrUnit : unitMap.keySet()) {
            if (!(resourceOrUnit instanceof UnitType)) {
                continue;
            }
            units.add((UnitType) resourceOrUnit);
        }
        if (units.isEmpty()) {
            continue;
        }
        final int totalProduced = unitMap.totalValues();
        if (totalProduced == 1) {
            final UnitType ut = units.iterator().next();
            final List<ResourceCollection> current = backups.computeIfAbsent(ut, k -> new ArrayList<>());
            current.add(costPerGroup);
        } else if (totalProduced > 1) {
            costPerGroup.discount((double) 1 / (double) totalProduced);
            for (final UnitType ut : units) {
                final List<ResourceCollection> current = backups.computeIfAbsent(ut, k -> new ArrayList<>());
                current.add(costPerGroup);
            }
        }
    }
    for (final Entry<UnitType, List<ResourceCollection>> entry : backups.entrySet()) {
        final ResourceCollection avgCost = new ResourceCollection(entry.getValue().toArray(new ResourceCollection[0]), data);
        if (entry.getValue().size() > 1) {
            avgCost.discount((double) 1 / (double) entry.getValue().size());
        }
        backupAveraged.put(entry.getKey(), avgCost);
    }
    final Map<PlayerID, Map<UnitType, ResourceCollection>> allPlayersCurrent = getResourceCostsForTuv(data, false);
    allPlayersCurrent.remove(null);
    for (final UnitType ut : data.getUnitTypeList().getAllUnitTypes()) {
        final List<ResourceCollection> costs = new ArrayList<>();
        for (final Map<UnitType, ResourceCollection> entry : allPlayersCurrent.values()) {
            if (entry.get(ut) != null) {
                costs.add(entry.get(ut));
            }
        }
        if (costs.isEmpty()) {
            final ResourceCollection backup = backupAveraged.get(ut);
            if (backup != null) {
                costs.add(backup);
            } else {
                costs.add(defaultResources);
            }
        }
        final ResourceCollection avgCost = new ResourceCollection(costs.toArray(new ResourceCollection[0]), data);
        if (costs.size() > 1) {
            avgCost.discount((double) 1 / (double) costs.size());
        }
        average.put(ut, avgCost);
    }
    return average;
}
Also used : IntegerMap(games.strategy.util.IntegerMap) Unit(games.strategy.engine.data.Unit) Collection(java.util.Collection) Constants(games.strategy.triplea.Constants) Set(java.util.Set) UnitAttachment(games.strategy.triplea.attachments.UnitAttachment) HashMap(java.util.HashMap) NamedAttachable(games.strategy.engine.data.NamedAttachable) Resource(games.strategy.engine.data.Resource) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) GameData(games.strategy.engine.data.GameData) List(java.util.List) PlayerID(games.strategy.engine.data.PlayerID) ResourceCollection(games.strategy.engine.data.ResourceCollection) ProductionFrontier(games.strategy.engine.data.ProductionFrontier) Matches(games.strategy.triplea.delegate.Matches) Map(java.util.Map) Entry(java.util.Map.Entry) UnitType(games.strategy.engine.data.UnitType) ProductionRule(games.strategy.engine.data.ProductionRule) CollectionUtils(games.strategy.util.CollectionUtils) IntegerMap(games.strategy.util.IntegerMap) PlayerID(games.strategy.engine.data.PlayerID) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) NamedAttachable(games.strategy.engine.data.NamedAttachable) Resource(games.strategy.engine.data.Resource) ArrayList(java.util.ArrayList) ProductionRule(games.strategy.engine.data.ProductionRule) UnitType(games.strategy.engine.data.UnitType) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) IntegerMap(games.strategy.util.IntegerMap) ResourceCollection(games.strategy.engine.data.ResourceCollection) HashSet(java.util.HashSet)

Aggregations

GameData (games.strategy.engine.data.GameData)204 Unit (games.strategy.engine.data.Unit)100 PlayerID (games.strategy.engine.data.PlayerID)92 Territory (games.strategy.engine.data.Territory)92 ArrayList (java.util.ArrayList)83 TripleAUnit (games.strategy.triplea.TripleAUnit)64 HashSet (java.util.HashSet)50 CompositeChange (games.strategy.engine.data.CompositeChange)40 List (java.util.List)36 HashMap (java.util.HashMap)32 Set (java.util.Set)32 Route (games.strategy.engine.data.Route)31 UnitAttachment (games.strategy.triplea.attachments.UnitAttachment)30 Collection (java.util.Collection)29 UnitType (games.strategy.engine.data.UnitType)26 Change (games.strategy.engine.data.Change)24 Test (org.junit.jupiter.api.Test)23 Resource (games.strategy.engine.data.Resource)22 TestMapGameData (games.strategy.triplea.xml.TestMapGameData)22 Map (java.util.Map)21