Search in sources :

Example 1 with ProductionFrontier

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

the class ProductionFrontierChange method perform.

@Override
protected void perform(final GameData data) {
    final PlayerID player = data.getPlayerList().getPlayerId(m_player);
    final ProductionFrontier frontier = data.getProductionFrontierList().getProductionFrontier(m_endFrontier);
    player.setProductionFrontier(frontier);
}
Also used : PlayerID(games.strategy.engine.data.PlayerID) ProductionFrontier(games.strategy.engine.data.ProductionFrontier)

Example 2 with ProductionFrontier

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

the class TriggerAttachment method setFrontier.

private void setFrontier(final String s) throws GameParseException {
    if (s == null) {
        m_frontier = null;
        return;
    }
    final ProductionFrontier front = getData().getProductionFrontierList().getProductionFrontier(s);
    if (front == null) {
        throw new GameParseException("Could not find frontier. name:" + s + thisErrorMsg());
    }
    m_frontier = front;
}
Also used : GameParseException(games.strategy.engine.data.GameParseException) ProductionFrontier(games.strategy.engine.data.ProductionFrontier)

Example 3 with ProductionFrontier

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

the class ImprovedShipyardsAdvance method perform.

@Override
public void perform(final PlayerID id, final IDelegateBridge bridge) {
    final GameData data = bridge.getData();
    if (!Properties.getUseShipyards(data)) {
        return;
    }
    final ProductionFrontier current = id.getProductionFrontier();
    // they already have it
    if (current.getName().endsWith("Shipyards")) {
        return;
    }
    final String industrialTechName = current.getName() + "Shipyards";
    final ProductionFrontier advancedTech = data.getProductionFrontierList().getProductionFrontier(industrialTechName);
    // it doesnt exist, dont crash
    if (advancedTech == null) {
        Logger.getLogger(TechAdvance.class.getName()).log(Level.WARNING, "No tech named:" + industrialTechName + " not adding tech");
        return;
    }
    final Change prodChange = ChangeFactory.changeProductionFrontier(id, advancedTech);
    bridge.addChange(prodChange);
}
Also used : GameData(games.strategy.engine.data.GameData) Change(games.strategy.engine.data.Change) ProductionFrontier(games.strategy.engine.data.ProductionFrontier)

Example 4 with ProductionFrontier

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

the class InitializationDelegate method initDestroyerArtillery.

private static void initDestroyerArtillery(final IDelegateBridge bridge) {
    final GameData data = bridge.getData();
    final boolean addArtilleryAndDestroyers = Properties.getUseDestroyersAndArtillery(data);
    if (!isWW2V2(data) && addArtilleryAndDestroyers) {
        final CompositeChange change = new CompositeChange();
        final ProductionRule artillery = data.getProductionRuleList().getProductionRule("buyArtillery");
        final ProductionRule destroyer = data.getProductionRuleList().getProductionRule("buyDestroyer");
        final ProductionFrontier frontier = data.getProductionFrontierList().getProductionFrontier("production");
        if (artillery != null && !frontier.getRules().contains(artillery)) {
            change.add(ChangeFactory.addProductionRule(artillery, frontier));
        }
        if (destroyer != null && !frontier.getRules().contains(destroyer)) {
            change.add(ChangeFactory.addProductionRule(destroyer, frontier));
        }
        final ProductionRule artilleryIndustrialTechnology = data.getProductionRuleList().getProductionRule("buyArtilleryIndustrialTechnology");
        final ProductionRule destroyerIndustrialTechnology = data.getProductionRuleList().getProductionRule("buyDestroyerIndustrialTechnology");
        final ProductionFrontier frontierIndustrialTechnology = data.getProductionFrontierList().getProductionFrontier("productionIndustrialTechnology");
        if (artilleryIndustrialTechnology != null && !frontierIndustrialTechnology.getRules().contains(artilleryIndustrialTechnology)) {
            change.add(ChangeFactory.addProductionRule(artilleryIndustrialTechnology, frontierIndustrialTechnology));
        }
        if (destroyerIndustrialTechnology != null && !frontierIndustrialTechnology.getRules().contains(destroyerIndustrialTechnology)) {
            change.add(ChangeFactory.addProductionRule(destroyerIndustrialTechnology, frontierIndustrialTechnology));
        }
        if (!change.isEmpty()) {
            bridge.getHistoryWriter().startEvent("Adding destroyers and artillery production rules");
            bridge.addChange(change);
        }
    }
}
Also used : GameData(games.strategy.engine.data.GameData) ProductionRule(games.strategy.engine.data.ProductionRule) CompositeChange(games.strategy.engine.data.CompositeChange) ProductionFrontier(games.strategy.engine.data.ProductionFrontier)

Example 5 with ProductionFrontier

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

the class InitializationDelegate method initShipyards.

private static void initShipyards(final IDelegateBridge bridge) {
    final GameData data = bridge.getData();
    final boolean useShipyards = Properties.getUseShipyards(data);
    if (useShipyards) {
        final CompositeChange change = new CompositeChange();
        final ProductionFrontier frontierShipyards = data.getProductionFrontierList().getProductionFrontier("productionShipyards");
        /*
       * Find the productionRules, if the unit is NOT a sea unit, add it to the ShipYards prod rule.
       */
        final ProductionFrontier frontierNonShipyards = data.getProductionFrontierList().getProductionFrontier("production");
        final Collection<ProductionRule> rules = frontierNonShipyards.getRules();
        for (final ProductionRule rule : rules) {
            final String ruleName = rule.getName();
            final IntegerMap<NamedAttachable> ruleResults = rule.getResults();
            final NamedAttachable named = ruleResults.keySet().iterator().next();
            if (!(named instanceof UnitType)) {
                continue;
            }
            final UnitType unit = data.getUnitTypeList().getUnitType(named.getName());
            final boolean isSea = UnitAttachment.get(unit).getIsSea();
            if (!isSea) {
                final ProductionRule prodRule = data.getProductionRuleList().getProductionRule(ruleName);
                change.add(ChangeFactory.addProductionRule(prodRule, frontierShipyards));
            }
        }
        bridge.getHistoryWriter().startEvent("Adding shipyard production rules - land/air units");
        bridge.addChange(change);
    }
}
Also used : GameData(games.strategy.engine.data.GameData) ProductionRule(games.strategy.engine.data.ProductionRule) NamedAttachable(games.strategy.engine.data.NamedAttachable) UnitType(games.strategy.engine.data.UnitType) CompositeChange(games.strategy.engine.data.CompositeChange) ProductionFrontier(games.strategy.engine.data.ProductionFrontier)

Aggregations

ProductionFrontier (games.strategy.engine.data.ProductionFrontier)12 ProductionRule (games.strategy.engine.data.ProductionRule)7 UnitType (games.strategy.engine.data.UnitType)5 GameData (games.strategy.engine.data.GameData)4 NamedAttachable (games.strategy.engine.data.NamedAttachable)4 PlayerID (games.strategy.engine.data.PlayerID)4 Change (games.strategy.engine.data.Change)3 CompositeChange (games.strategy.engine.data.CompositeChange)3 IntegerMap (games.strategy.util.IntegerMap)3 HashSet (java.util.HashSet)3 GameParseException (games.strategy.engine.data.GameParseException)2 Resource (games.strategy.engine.data.Resource)2 Territory (games.strategy.engine.data.Territory)2 Unit (games.strategy.engine.data.Unit)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 ClientLogger (games.strategy.debug.ClientLogger)1 Attachable (games.strategy.engine.data.Attachable)1 IAttachment (games.strategy.engine.data.IAttachment)1 MutableProperty (games.strategy.engine.data.MutableProperty)1 RelationshipType (games.strategy.engine.data.RelationshipType)1