def test_drone_dps(DB, Saveddata, RifterFit): """ Tests applied drone damage """ # set pilot char0 = Saveddata['Character'].getAll0() RifterFit.character = char0 # configure DPS analysis to include as many factors as possible # (damage type reistance) graph = FitDpsGraph(RifterFit) data = graph.defaults.copy() data['emRes'] = 10.0 # add a drone drone = Saveddata['Drone'](DB['db'].getItem("Acolyte II")) drone.amount = 1 drone.amountActive = 1 RifterFit.drones.append(drone) # calculate applied DPS RifterFit.clear() RifterFit.calculateModifiedAttributes() dps = graph.calcDps(data) assert abs(dps - 7.6) < 0.05
def test_multiply_stacking_penalties(DB, Saveddata, RifterFit): """ Tests the stacking penalties under multiply """ char0 = Saveddata['Character'].getAll0() RifterFit.character = char0 starting_em_resist = RifterFit.ship.getModifiedItemAttr("shieldEmDamageResonance") mod = Saveddata['Module'](DB['db'].getItem("EM Ward Amplifier II")) item_modifer = mod.item.getAttribute("emDamageResistanceBonus") RifterFit.calculateModifiedAttributes() for _ in range(10): if _ == 0: # First run we have no modules, se don't try and calculate them. calculated_resist = RifterFit.ship.getModifiedItemAttr("shieldEmDamageResonance") else: # Calculate what our next resist should be # Denominator: [math.exp((i / 2.67) ** 2.0) for i in xrange(8)] current_effectiveness = 1 / math.exp(((_ - 1) / 2.67) ** 2.0) new_item_modifier = 1 + ((item_modifer * current_effectiveness) / 100) calculated_resist = (em_resist * new_item_modifier) # Add another resist module to our fit. RifterFit.modules.append(mod) # Modify our fit so that Eos generates new numbers for us. RifterFit.clear() RifterFit.calculateModifiedAttributes() em_resist = RifterFit.ship.getModifiedItemAttr("shieldEmDamageResonance") assert em_resist == calculated_resist
def test_multiply_stacking_penalties(DB, Saveddata, RifterFit): """ Tests the stacking penalties under multiply """ char0 = Saveddata['Character'].getAll0() RifterFit.character = char0 starting_em_resist = RifterFit.ship.getModifiedItemAttr( "shieldEmDamageResonance") mod = Saveddata['Module'](DB['db'].getItem("EM Ward Amplifier II")) item_modifer = mod.item.getAttribute("emDamageResistanceBonus") RifterFit.calculateModifiedAttributes() for _ in range(10): if _ == 0: # First run we have no modules, se don't try and calculate them. calculated_resist = RifterFit.ship.getModifiedItemAttr( "shieldEmDamageResonance") else: # Calculate what our next resist should be # Denominator: [math.exp((i / 2.67) ** 2.0) for i in xrange(8)] current_effectiveness = 1 / math.exp(((_ - 1) / 2.67)**2.0) new_item_modifier = 1 + ( (item_modifer * current_effectiveness) / 100) calculated_resist = (em_resist * new_item_modifier) # Add another resist module to our fit. RifterFit.modules.append(mod) # Modify our fit so that Eos generates new numbers for us. RifterFit.clear() RifterFit.calculateModifiedAttributes() em_resist = RifterFit.ship.getModifiedItemAttr( "shieldEmDamageResonance") assert em_resist == calculated_resist
def test_rifter_coprocessor(DB, Saveddata, RifterFit): char5 = Saveddata['Character'].getAll5() char0 = Saveddata['Character'].getAll0() RifterFit.character = char0 mod = Saveddata['Module'](DB['db'].getItem("Co-Processor II")) mod.state = Saveddata['State'].OFFLINE RifterFit.modules.append(mod) assert RifterFit.ship.getModifiedItemAttr("cpuOutput") == 130 RifterFit.calculateModifiedAttributes() assert RifterFit.ship.getModifiedItemAttr("cpuOutput") == 130 mod.state = Saveddata['State'].ONLINE RifterFit.clear() RifterFit.calculateModifiedAttributes() assert RifterFit.ship.getModifiedItemAttr("cpuOutput") == 143 RifterFit.character = char5 RifterFit.clear() RifterFit.calculateModifiedAttributes() assert RifterFit.ship.getModifiedItemAttr("cpuOutput") == 178.75
def test_turret_dps(DB, Saveddata, RifterFit): """ Tests applied turret damage """ # set pilot char0 = Saveddata['Character'].getAll0() RifterFit.character = char0 # configure DPS analysis to include as many factors as possible # (damage type reistance, distance past turret optimal, sig/speed/angle to incur turret tracking penalty) graph = FitDpsGraph(RifterFit) data = graph.defaults.copy() data['emRes'] = 10.0 data['distance'] = 7.0 data['signatureRadius'] = 100.0 data['tgtAngle'] = 90.0 data['tgtSpeed'] = 100.0 # add a turret mod = Saveddata['Module'](DB['db'].getItem("280mm Howitzer Artillery II")) mod.owner = RifterFit mod.state = Saveddata['State'].ACTIVE # there must be a better way to fetch this ammo directly, but I couldn't figure out the appropriate Gamedata voodoo; # this, for example, did not work: # mod.charge = DB['gamedata_session'].query(Gamedata['Item']).filter(Gamedata['Item'].name == "EMP S").first() for charge in mod.getValidCharges(): if charge.name == "EMP S": mod.charge = charge break RifterFit.modules.append(mod) # calculate applied DPS RifterFit.clear() RifterFit.calculateModifiedAttributes() dps = graph.calcDps(data) assert abs(dps - 8.8) < 0.05
def test_calculateModifiedAttributes_withProjected(DB, RifterFit, HeronFit): # TODO: This test is not currently functional or meaningful as projections are not happening correctly. # This is true for all tested branches (master, dev, etc) rifter_modifier_dicts = { '_ModifiedAttributeDict__affectedBy' : 26, '_ModifiedAttributeDict__forced' : 0, '_ModifiedAttributeDict__intermediary' : 0, '_ModifiedAttributeDict__modified' : 26, '_ModifiedAttributeDict__multipliers' : 22, '_ModifiedAttributeDict__overrides' : 0, '_ModifiedAttributeDict__penalizedMultipliers': 0, '_ModifiedAttributeDict__postIncreases' : 0, '_ModifiedAttributeDict__preAssigns' : 0, '_ModifiedAttributeDict__preIncreases' : 4, } # Test before calculating attributes for test_dict in rifter_modifier_dicts: assert len(getattr(RifterFit.ship.itemModifiedAttributes, test_dict)) == 0 # Get base stats max_target_range_1 = RifterFit.ship.getModifiedItemAttr('maxTargetRange') scan_resolution_1 = RifterFit.ship.getModifiedItemAttr('scanResolution') RifterFit.clear() RifterFit.calculateModifiedAttributes() # Get self calculated stats max_target_range_2 = RifterFit.ship.getModifiedItemAttr('maxTargetRange') scan_resolution_2 = RifterFit.ship.getModifiedItemAttr('scanResolution') RifterFit.clear() # Project Heron fit onto Rifter RifterFit._Fit__projectedFits[HeronFit.ID] = HeronFit # DB['saveddata_session'].commit() # DB['saveddata_session'].flush() # DB['saveddata_session'].refresh(HeronFit) RifterFit.calculateModifiedAttributes() # Get stats with projections max_target_range_3 = RifterFit.ship.getModifiedItemAttr('maxTargetRange') scan_resolution_3 = RifterFit.ship.getModifiedItemAttr('scanResolution') RifterFit.clear() RifterFit.calculateModifiedAttributes() # Get stats with projections max_target_range_4 = RifterFit.ship.getModifiedItemAttr('maxTargetRange') scan_resolution_4 = RifterFit.ship.getModifiedItemAttr('scanResolution') RifterFit.clear() HeronFit.calculateModifiedAttributes(targetFit=RifterFit) RifterFit.calculateModifiedAttributes() # Get stats with projections max_target_range_5 = RifterFit.ship.getModifiedItemAttr('maxTargetRange') scan_resolution_5 = RifterFit.ship.getModifiedItemAttr('scanResolution') for test_dict in rifter_modifier_dicts: assert len(getattr(RifterFit.ship.itemModifiedAttributes, test_dict)) == rifter_modifier_dicts[test_dict]
def test_calculateModifiedAttributes_withProjected(DB, RifterFit, HeronFit): # TODO: This test is not currently functional or meaningful as projections are not happening correctly. # This is true for all tested branches (master, dev, etc) rifter_modifier_dicts = { '_ModifiedAttributeDict__affectedBy' : 26, '_ModifiedAttributeDict__forced' : 0, '_ModifiedAttributeDict__intermediary' : 0, '_ModifiedAttributeDict__modified' : 26, '_ModifiedAttributeDict__multipliers' : 22, '_ModifiedAttributeDict__overrides' : 0, '_ModifiedAttributeDict__penalizedMultipliers': 0, '_ModifiedAttributeDict__postIncreases' : 0, '_ModifiedAttributeDict__preAssigns' : 0, '_ModifiedAttributeDict__preIncreases' : 4, } # quick hack to disable test. Need to rewrite ttests to not point to the DB assert 1==1 return # Test before calculating attributes for test_dict in rifter_modifier_dicts: assert len(getattr(RifterFit.ship.itemModifiedAttributes, test_dict)) == 0 # Get base stats max_target_range_1 = RifterFit.ship.getModifiedItemAttr('maxTargetRange') scan_resolution_1 = RifterFit.ship.getModifiedItemAttr('scanResolution') RifterFit.clear() RifterFit.calculateModifiedAttributes() # Get self calculated stats max_target_range_2 = RifterFit.ship.getModifiedItemAttr('maxTargetRange') scan_resolution_2 = RifterFit.ship.getModifiedItemAttr('scanResolution') RifterFit.clear() # Project Heron fit onto Rifter RifterFit._Fit__projectedFits[HeronFit.ID] = HeronFit # DB['saveddata_session'].commit() # DB['saveddata_session'].flush() # DB['saveddata_session'].refresh(HeronFit) RifterFit.calculateModifiedAttributes() # Get stats with projections max_target_range_3 = RifterFit.ship.getModifiedItemAttr('maxTargetRange') scan_resolution_3 = RifterFit.ship.getModifiedItemAttr('scanResolution') RifterFit.clear() RifterFit.calculateModifiedAttributes() # Get stats with projections max_target_range_4 = RifterFit.ship.getModifiedItemAttr('maxTargetRange') scan_resolution_4 = RifterFit.ship.getModifiedItemAttr('scanResolution') RifterFit.clear() HeronFit.calculateModifiedAttributes(targetFit=RifterFit) RifterFit.calculateModifiedAttributes() # Get stats with projections max_target_range_5 = RifterFit.ship.getModifiedItemAttr('maxTargetRange') scan_resolution_5 = RifterFit.ship.getModifiedItemAttr('scanResolution') for test_dict in rifter_modifier_dicts: assert len(getattr(RifterFit.ship.itemModifiedAttributes, test_dict)) == rifter_modifier_dicts[test_dict]