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