use of games.strategy.triplea.attachments.TechAttachment in project triplea by triplea-game.
the class GenericTechChange method perform.
@Override
public void perform(final GameData data) {
final TechAttachment attachment = (TechAttachment) m_attachedTo.getAttachment(m_attachmentName);
attachment.setGenericTech(m_property, m_newValue);
}
use of games.strategy.triplea.attachments.TechAttachment in project triplea by triplea-game.
the class TechTracker method getFullyResearchedPlayerTechCategories.
/**
* Returns what tech categories are no longer available for this player, because all techs in them have been
* successfully researched
* already.
*/
public static Collection<TechnologyFrontier> getFullyResearchedPlayerTechCategories(final PlayerID id) {
final Collection<TechnologyFrontier> technologyFrontiers = new ArrayList<>();
final TechAttachment attachment = TechAttachment.get(id);
for (final TechnologyFrontier tf : TechAdvance.getPlayerTechCategories(id)) {
boolean has = true;
for (final TechAdvance t : tf.getTechs()) {
has = t.hasTech(attachment);
if (!has) {
break;
}
}
if (has) {
technologyFrontiers.add(tf);
}
}
return technologyFrontiers;
}
use of games.strategy.triplea.attachments.TechAttachment in project triplea by triplea-game.
the class TechTracker method getCurrentTechAdvances.
/**
* Returns what tech advances this player already has successfully researched (including ones that may not be in their
* tech frontier).
*/
public static Collection<TechAdvance> getCurrentTechAdvances(final PlayerID id, final GameData data) {
final Collection<TechAdvance> techAdvances = new ArrayList<>();
final TechAttachment attachment = TechAttachment.get(id);
// search all techs
for (final TechAdvance ta : TechAdvance.getTechAdvances(data)) {
if (ta.hasTech(attachment)) {
techAdvances.add(ta);
}
}
return techAdvances;
}
use of games.strategy.triplea.attachments.TechAttachment in project triplea by triplea-game.
the class RevisedTest method testTechRolls.
@Test
public void testTechRolls() {
// Set up the test
final PlayerID germans = GameDataTestUtil.germans(gameData);
final ITestDelegateBridge delegateBridge = getDelegateBridge(germans);
delegateBridge.setStepName("germanTech");
final TechnologyDelegate techDelegate = techDelegate(gameData);
techDelegate.setDelegateBridgeAndPlayer(delegateBridge);
techDelegate.start();
final TechAttachment ta = TechAttachment.get(germans);
// PlayerAttachment pa = PlayerAttachment.get(germans);
final TechnologyFrontier rockets = new TechnologyFrontier("", gameData);
rockets.addAdvance(TechAdvance.findAdvance(TechAdvance.TECH_PROPERTY_ROCKETS, gameData, null));
final TechnologyFrontier jet = new TechnologyFrontier("", gameData);
jet.addAdvance(TechAdvance.findAdvance(TechAdvance.TECH_PROPERTY_JET_POWER, gameData, null));
// Check to make sure it was successful
final int initPUs = germans.getResources().getQuantity("PUs");
// Fail the roll
delegateBridge.setRandomSource(new ScriptedRandomSource(new int[] { 3, 4 }));
final TechResults roll = techDelegate.rollTech(2, rockets, 0, null);
// Check to make sure it failed
assertEquals(0, roll.getHits());
final int midPUs = germans.getResources().getQuantity("PUs");
assertEquals(initPUs - 10, midPUs);
// Make a Successful roll
delegateBridge.setRandomSource(new ScriptedRandomSource(new int[] { 5 }));
final TechResults roll2 = techDelegate.rollTech(1, rockets, 0, null);
// Check to make sure it succeeded
assertEquals(1, roll2.getHits());
final int finalPUs = germans.getResources().getQuantity("PUs");
assertEquals(midPUs - 5, finalPUs);
// Test the variable tech cost
// Make a Successful roll
ta.setTechCost("6");
delegateBridge.setRandomSource(new ScriptedRandomSource(new int[] { 5 }));
final TechResults roll3 = techDelegate.rollTech(1, jet, 0, null);
// Check to make sure it succeeded
assertEquals(1, roll3.getHits());
final int variablePus = germans.getResources().getQuantity("PUs");
assertEquals(finalPUs - 6, variablePus);
}
use of games.strategy.triplea.attachments.TechAttachment in project triplea by triplea-game.
the class DelegateTest method setUp.
@BeforeEach
public void setUp() throws Exception {
gameData = TestMapGameData.DELEGATE_TEST.getGameData();
british = GameDataTestUtil.british(gameData);
british.addAttachment(Constants.TECH_ATTACHMENT_NAME, new TechAttachment());
japanese = GameDataTestUtil.japanese(gameData);
japanese.addAttachment(Constants.TECH_ATTACHMENT_NAME, new TechAttachment());
russians = GameDataTestUtil.russians(gameData);
russians.addAttachment(Constants.TECH_ATTACHMENT_NAME, new TechAttachment());
germans = GameDataTestUtil.germans(gameData);
germans.addAttachment(Constants.TECH_ATTACHMENT_NAME, new TechAttachment());
northSea = gameData.getMap().getTerritory("North Sea Zone");
blackSea = gameData.getMap().getTerritory("Black Sea Zone");
uk = gameData.getMap().getTerritory("United Kingdom");
japan = gameData.getMap().getTerritory("Japan");
japanSeaZone = gameData.getMap().getTerritory("Japan Sea Zone");
sfeSeaZone = gameData.getMap().getTerritory("Soviet Far East Sea Zone");
brazil = gameData.getMap().getTerritory("Brazil");
westCanada = gameData.getMap().getTerritory("West Canada");
germany = gameData.getMap().getTerritory("Germany");
syria = gameData.getMap().getTerritory("Syria Jordan");
manchuria = gameData.getMap().getTerritory("Manchuria");
egypt = gameData.getMap().getTerritory("Anglo Sudan Egypt");
congo = gameData.getMap().getTerritory("Congo");
congoSeaZone = gameData.getMap().getTerritory("Congo Sea Zone");
northAtlantic = gameData.getMap().getTerritory("North Atlantic Sea Zone");
westAfricaSea = gameData.getMap().getTerritory("West Africa Sea Zone");
kenya = gameData.getMap().getTerritory("Kenya-Rhodesia");
eastAfrica = gameData.getMap().getTerritory("Italian East Africa");
libya = gameData.getMap().getTerritory("Libya");
algeria = gameData.getMap().getTerritory("Algeria");
equatorialAfrica = gameData.getMap().getTerritory("French Equatorial Africa");
redSea = gameData.getMap().getTerritory("Red Sea Zone");
westAfrica = gameData.getMap().getTerritory("French West Africa");
angola = gameData.getMap().getTerritory("Angola");
angolaSeaZone = gameData.getMap().getTerritory("Angola Sea Zone");
eastCompass = gameData.getMap().getTerritory("East Compass Sea Zone");
westCompass = gameData.getMap().getTerritory("West Compass Sea Zone");
mozambiqueSeaZone = gameData.getMap().getTerritory("Mozambique Sea Zone");
eastMediteranean = gameData.getMap().getTerritory("East Mediteranean Sea Zone");
indianOcean = gameData.getMap().getTerritory("Indian Ocean Sea Zone");
westAfricaSeaZone = gameData.getMap().getTerritory("West Africa Sea Zone");
southAfrica = gameData.getMap().getTerritory("South Africa");
saudiArabia = gameData.getMap().getTerritory("Saudi Arabia");
india = gameData.getMap().getTerritory("India");
southAtlantic = gameData.getMap().getTerritory("South Atlantic Sea Zone");
antarticSea = gameData.getMap().getTerritory("Antartic Sea Zone");
southAfricaSeaZone = gameData.getMap().getTerritory("South Africa Sea Zone");
southBrazilSeaZone = gameData.getMap().getTerritory("South Brazil Sea Zone");
russia = gameData.getMap().getTerritory("Russia");
spain = gameData.getMap().getTerritory("Spain");
gibraltar = gameData.getMap().getTerritory("Gibraltar");
balticSeaZone = gameData.getMap().getTerritory("Baltic Sea Zone");
karelia = gameData.getMap().getTerritory("Karelia S.S.R.");
westEurope = gameData.getMap().getTerritory("West Europe");
finlandNorway = gameData.getMap().getTerritory("Finland Norway");
armour = GameDataTestUtil.armour(gameData);
infantry = GameDataTestUtil.infantry(gameData);
transport = GameDataTestUtil.transport(gameData);
submarine = GameDataTestUtil.submarine(gameData);
factory = GameDataTestUtil.factory(gameData);
aaGun = GameDataTestUtil.aaGun(gameData);
fighter = GameDataTestUtil.fighter(gameData);
bomber = GameDataTestUtil.bomber(gameData);
carrier = GameDataTestUtil.carrier(gameData);
pus = gameData.getResourceList().getResource("PUs");
}
Aggregations