def test_attr_em_absent(self): fit = Fit() item = ModuleHigh(self.mktype(attrs={ AttrId.capacity: 2.0, self.cycle_attr.id: 2000, AttrId.charge_rate: 1.0, AttrId.reload_time: 10000 }, effects=[self.effect_item], default_effect=self.effect_item).id, state=State.active) item.charge = Charge( self.mktype(attrs={ AttrId.volume: 0.1, AttrId.therm_dmg: 6.3, AttrId.kin_dmg: 7.4, AttrId.expl_dmg: 8.5 }, effects=[self.effect_charge], default_effect=self.effect_charge).id) fit.modules.high.append(item) # Verification volley = item.get_volley() self.assertAlmostEqual(volley.em, 0) self.assertAlmostEqual(volley.thermal, 6.3) self.assertAlmostEqual(volley.kinetic, 7.4) self.assertAlmostEqual(volley.explosive, 8.5) self.assertAlmostEqual(volley.total, 22.2) # Cleanup self.assert_solsys_buffers_empty(fit.solar_system) self.assert_log_entries(0)
def test_pass_autocharge_with_charge(self): charge = Charge(self.mktype(attrs={AttrId.volume: 2}).id) autocharge_type = self.mktype(attrs={AttrId.volume: 2}) container_effect = self.mkeffect( effect_id=EffectId.target_attack, category_id=EffectCategoryId.target) container = ModuleHigh( self.mktype( attrs={ AttrId.capacity: 2, AttrId.ammo_loaded: autocharge_type.id}, effects=[container_effect]).id, state=State.offline) container.charge = charge self.fit.modules.high.append(container) self.assertIn(container_effect.id, container.autocharges) autocharge = container.autocharges[container_effect.id] # Action error1 = self.get_error(container, Restriction.charge_volume) # Verification self.assertIsNone(error1) # Action error2 = self.get_error(charge, Restriction.charge_volume) # Verification self.assertIsNone(error2) # Action error3 = self.get_error(autocharge, Restriction.charge_volume) # Verification self.assertIsNone(error3) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_reload(self): fit = Fit() item = ModuleHigh(self.mktype(attrs={ AttrId.capacity: 60.0, self.cycle_attr.id: 5000, AttrId.charge_rate: 1.0, AttrId.reload_time: 10000, AttrId.module_reactivation_delay: 120000 }, effects=[self.effect_item], default_effect=self.effect_item).id, state=State.active) item.charge = Charge( self.mktype(attrs={ AttrId.volume: 30.0, AttrId.em_dmg: 5200, AttrId.therm_dmg: 6300, AttrId.kin_dmg: 7400, AttrId.expl_dmg: 8500 }, effects=[self.effect_charge], default_effect=self.effect_charge).id) fit.modules.high.append(item) # Verification dps = item.get_dps(reload=True) # Reload doesn't affect DPS because reactivation time is higher, item # manages to reload during that time self.assertAlmostEqual(dps.em, 41.6) self.assertAlmostEqual(dps.thermal, 50.4) self.assertAlmostEqual(dps.kinetic, 59.2) self.assertAlmostEqual(dps.explosive, 68) self.assertAlmostEqual(dps.total, 219.2) # Cleanup self.assert_solsys_buffers_empty(fit.solar_system) self.assert_log_entries(0)
def test_fail_multiple(self): # When multiple consumers require less than cpu output alone, but in sum # want more than total output, it should be erroneous situation self.fit.ship = Ship(self.mktype(attrs={AttrId.cpu_output: 40}).id) item1 = ModuleHigh(self.mktype(attrs={ AttrId.cpu: 25 }, effects=[self.effect]).id, state=State.online) self.fit.modules.high.append(item1) item2 = ModuleHigh(self.mktype(attrs={ AttrId.cpu: 20 }, effects=[self.effect]).id, state=State.online) self.fit.modules.high.append(item2) # Action error1 = self.get_error(item1, Restriction.cpu) # Verification self.assertIsNotNone(error1) self.assertEqual(error1.output, 40) self.assertEqual(error1.total_use, 45) self.assertEqual(error1.item_use, 25) # Action error2 = self.get_error(item2, Restriction.cpu) # Verification self.assertIsNotNone(error2) self.assertEqual(error2.output, 40) self.assertEqual(error2.total_use, 45) self.assertEqual(error2.item_use, 20) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_tgt_recalc_attr_change(self): # Here dogma modifier changes value of one of attributes which are used # as source by python modifier, and sees if python modifier target value # is updated attr4 = self.mkattr() dogma_modifier = self.mkmod(affectee_filter=ModAffecteeFilter.item, affectee_domain=ModDomain.self, affectee_attr_id=self.attr2.id, operator=ModOperator.post_mul, affector_attr_id=attr4.id) dogma_effect = self.mkeffect(category_id=EffectCategoryId.active, modifiers=[dogma_modifier]) item = ModuleHigh( self.mktype(attrs={ self.attr1.id: 100, self.attr2.id: 2, attr4.id: 5 }, effects=(self.python_effect, self.online_effect, dogma_effect), default_effect=dogma_effect).id) self.fit.modules.high.append(item) item.state = State.online self.assertAlmostEqual(item.attrs[self.attr1.id], 600) # Action item.state = State.active # Verification self.assertAlmostEqual(item.attrs[self.attr1.id], 3000) # Cleanup self.fit.ship = None self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_cycles_until_reload_none(self): fit = Fit() item = ModuleHigh( self.mktype( attrs={ AttrId.capacity: 2.0, self.cycle_attr.id: 2000, AttrId.charge_rate: 1.0, AttrId.reload_time: 10000}, effects=[self.effect_item], default_effect=self.effect_item).id, state=State.active) item.charge = Charge(self.mktype( attrs={ AttrId.volume: 2.1, AttrId.em_dmg: 5.2, AttrId.therm_dmg: 6.3, AttrId.kin_dmg: 7.4, AttrId.expl_dmg: 8.5}, effects=[self.effect_charge], default_effect=self.effect_charge).id) fit.modules.high.append(item) # Verification volley = item.get_volley() self.assertAlmostEqual(volley.em, 0) self.assertAlmostEqual(volley.thermal, 0) self.assertAlmostEqual(volley.kinetic, 0) self.assertAlmostEqual(volley.explosive, 0) self.assertAlmostEqual(volley.total, 0) # Cleanup self.assert_solsys_buffers_empty(fit.solar_system) self.assert_log_entries(0)
def test_charge_attr_em_absent(self): fit = Fit() item = ModuleHigh( self.mktype( attrs={ AttrId.dmg_mult: 2.5, AttrId.capacity: 2.0, self.cycle_attr.id: 500, AttrId.charge_rate: 1.0, AttrId.reload_time: 5000}, effects=[self.effect], default_effect=self.effect).id, state=State.active) item.charge = Charge(self.mktype(attrs={ AttrId.volume: 0.2, AttrId.therm_dmg: 6.3, AttrId.kin_dmg: 7.4, AttrId.expl_dmg: 8.5}).id) fit.modules.high.append(item) # Verification volley = item.get_volley() self.assertAlmostEqual(volley.em, 0) self.assertAlmostEqual(volley.thermal, 15.75) self.assertAlmostEqual(volley.kinetic, 18.5) self.assertAlmostEqual(volley.explosive, 21.25) self.assertAlmostEqual(volley.total, 55.5) # Cleanup self.assert_solsys_buffers_empty(fit.solar_system) self.assert_log_entries(0)
def test_item_after_nones(self): fit = Fit() item1 = ModuleHigh(self.mktype().id) item2 = ModuleHigh(self.mktype().id) item3 = ModuleHigh(self.mktype().id) fit.modules.high.append(item1) fit.modules.high.place(3, item2) fit.modules.high.place(6, item3) # Action fit.modules.high.remove(item2) # Verification self.assertIs(len(fit.modules.high), 6) self.assertIs(fit.modules.high[0], item1) self.assertIsNone(fit.modules.high[1]) self.assertIsNone(fit.modules.high[2]) self.assertIsNone(fit.modules.high[3]) self.assertIsNone(fit.modules.high[4]) self.assertIs(fit.modules.high[5], item3) # Action fit.modules.high.remove(item3) # Verification self.assertIs(len(fit.modules.high), 1) self.assertIs(fit.modules.high[0], item1) # Cleanup self.assert_item_buffers_empty(item1) self.assert_item_buffers_empty(item2) self.assert_item_buffers_empty(item3) self.assert_solsys_buffers_empty(fit.solar_system) self.assert_log_entries(0)
def test_charge_not_loaded(self): fit = Fit() item = ModuleHigh( self.mktype( attrs={ AttrId.dmg_mult: 2.5, AttrId.capacity: 2.0, self.cycle_attr.id: 500, AttrId.charge_rate: 1.0, AttrId.reload_time: 5000}, effects=[self.effect], default_effect=self.effect).id, state=State.active) item.charge = Charge(self.allocate_type_id()) fit.modules.high.append(item) # Verification volley = item.get_volley() self.assertAlmostEqual(volley.em, 0) self.assertAlmostEqual(volley.thermal, 0) self.assertAlmostEqual(volley.kinetic, 0) self.assertAlmostEqual(volley.explosive, 0) self.assertAlmostEqual(volley.total, 0) # Cleanup self.assert_solsys_buffers_empty(fit.solar_system) self.assert_log_entries(0)
def test_effect_disabled(self): fit = Fit() item = ModuleHigh( self.mktype( attrs={ AttrId.em_dmg: 52, AttrId.therm_dmg: 63, AttrId.kin_dmg: 74, AttrId.expl_dmg: 85, self.cycle_attr.id: 5000}, effects=[self.effect], default_effect=self.effect).id, state=State.active) item.set_effect_mode(self.effect.id, EffectMode.force_stop) fit.modules.high.append(item) # Verification volley = item.get_volley() self.assertAlmostEqual(volley.em, 0) self.assertAlmostEqual(volley.thermal, 0) self.assertAlmostEqual(volley.kinetic, 0) self.assertAlmostEqual(volley.explosive, 0) self.assertAlmostEqual(volley.total, 0) # Cleanup self.assert_solsys_buffers_empty(fit.solar_system) self.assert_log_entries(0)
def test_total_attr_single_expl_zero(self): fit = Fit() item = ModuleHigh(self.mktype(attrs={ AttrId.dmg_mult: 2.5, AttrId.capacity: 2.0, self.cycle_attr.id: 500, AttrId.charge_rate: 1.0, AttrId.reload_time: 5000 }, effects=[self.effect], default_effect=self.effect).id, state=State.active) item.charge = Charge( self.mktype(attrs={ AttrId.volume: 0.2, AttrId.expl_dmg: 0 }).id) fit.modules.high.append(item) # Verification volley = item.get_volley() self.assertAlmostEqual(volley.em, 0) self.assertAlmostEqual(volley.thermal, 0) self.assertAlmostEqual(volley.kinetic, 0) self.assertAlmostEqual(volley.explosive, 0) self.assertAlmostEqual(volley.total, 0) # Cleanup self.assert_solsys_buffers_empty(fit.solar_system) self.assert_log_entries(0)
def test_reload(self): fit = Fit() item = ModuleHigh( self.mktype( attrs={ AttrId.capacity: 2.0, self.cycle_attr.id: 2000, AttrId.charge_rate: 1.0, AttrId.reload_time: 10000}, effects=[self.effect_item], default_effect=self.effect_item).id, state=State.active) item.charge = Charge(self.mktype( attrs={ AttrId.volume: 0.1, AttrId.em_dmg: 5.2, AttrId.therm_dmg: 6.3, AttrId.kin_dmg: 7.4, AttrId.expl_dmg: 8.5}, effects=[self.effect_charge], default_effect=self.effect_charge).id) fit.modules.high.append(item) # Verification dps = item.get_dps(reload=True) self.assertAlmostEqual(dps.em, 2.08) self.assertAlmostEqual(dps.thermal, 2.52) self.assertAlmostEqual(dps.kinetic, 2.96) self.assertAlmostEqual(dps.explosive, 3.4) self.assertAlmostEqual(dps.total, 10.96) # Cleanup self.assert_solsys_buffers_empty(fit.solar_system) self.assert_log_entries(0)
def test_mix_one(self): # Make sure error is raised for just items which excess restriction, # even if both are from the same group item1 = ModuleHigh( self.mktype(group_id=92, attrs={ AttrId.max_group_fitted: 1 }).id) self.fit.modules.high.append(item1) item2 = ModuleHigh( self.mktype(group_id=92, attrs={ AttrId.max_group_fitted: 2 }).id) self.fit.modules.high.append(item2) # Action error1 = self.get_error(item1, Restriction.max_group_fitted) # Verification self.assertIsNotNone(error1) self.assertEqual(error1.group_id, 92) self.assertEqual(error1.quantity, 2) self.assertEqual(error1.max_allowed_quantity, 1) # Action error2 = self.get_error(item2, Restriction.max_group_fitted) # Verification self.assertIsNone(error2) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_reload(self): fit = Fit() item = ModuleHigh( self.mktype( attrs={ AttrId.capacity: 60.0, self.cycle_attr.id: 5000, AttrId.charge_rate: 1.0, AttrId.reload_time: 10000, AttrId.module_reactivation_delay: 120000}, effects=[self.effect_item], default_effect=self.effect_item).id, state=State.active) item.charge = Charge(self.mktype( attrs={ AttrId.volume: 30.0, AttrId.em_dmg: 5200, AttrId.therm_dmg: 6300, AttrId.kin_dmg: 7400, AttrId.expl_dmg: 8500}, effects=[self.effect_charge], default_effect=self.effect_charge).id) fit.modules.high.append(item) # Verification dps = item.get_dps(reload=True) # Reload doesn't affect DPS because reactivation time is higher, item # manages to reload during that time self.assertAlmostEqual(dps.em, 41.6) self.assertAlmostEqual(dps.thermal, 50.4) self.assertAlmostEqual(dps.kinetic, 59.2) self.assertAlmostEqual(dps.explosive, 68) self.assertAlmostEqual(dps.total, 219.2) # Cleanup self.assert_solsys_buffers_empty(fit.solar_system) self.assert_log_entries(0)
def test_fail_all(self): # Make sure error is raised for all items exceeding their group # restriction item_type = self.mktype(group_id=6, attrs={AttrId.max_group_fitted: 1}) item1 = ModuleHigh(item_type.id) self.fit.modules.high.append(item1) item2 = ModuleHigh(item_type.id) self.fit.modules.high.append(item2) # Action error1 = self.get_error(item1, Restriction.max_group_fitted) # Verification self.assertIsNotNone(error1) self.assertEqual(error1.group_id, 6) self.assertEqual(error1.quantity, 2) self.assertEqual(error1.max_allowed_quantity, 1) # Action error2 = self.get_error(item2, Restriction.max_group_fitted) # Verification self.assertIsNotNone(error2) self.assertEqual(error2.group_id, 6) self.assertEqual(error2.quantity, 2) self.assertEqual(error2.max_allowed_quantity, 1) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_charge_attr_kin_zero(self): item = ModuleHigh( self.mktype( attrs={ AttrId.dmg_mult: 2, AttrId.capacity: 1, AttrId.charge_rate: 1, self.cycle_attr.id: 2500, AttrId.reload_time: 2000}, effects=[self.dd_effect], default_effect=self.dd_effect).id, state=State.active) item.charge = Charge(self.mktype( attrs={AttrId.kin_dmg: 0, AttrId.volume: 1}).id) self.fit.modules.high.append(item) # Action stats_dps = self.fit.stats.get_dps() # Verification self.assertAlmostEqual(stats_dps.em, 0) self.assertAlmostEqual(stats_dps.thermal, 0) self.assertAlmostEqual(stats_dps.kinetic, 0) self.assertAlmostEqual(stats_dps.explosive, 0) self.assertAlmostEqual(stats_dps.total, 0) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_arguments_custom_reload(self): item = ModuleHigh( self.mktype( attrs={ AttrId.dmg_mult: 2, AttrId.capacity: 1, AttrId.charge_rate: 1, self.cycle_attr.id: 3000, AttrId.reload_time: 2000}, effects=[self.dd_effect], default_effect=self.dd_effect).id, state=State.active) item.charge = Charge(self.mktype(attrs={ AttrId.em_dmg: 1.2, AttrId.therm_dmg: 2.4, AttrId.kin_dmg: 4.8, AttrId.expl_dmg: 9.6, AttrId.volume: 1}).id) self.fit.modules.high.append(item) # Action stats_dps = self.fit.stats.get_dps(reload=True) # Verification self.assertAlmostEqual(stats_dps.em, 0.48) self.assertAlmostEqual(stats_dps.thermal, 0.96) self.assertAlmostEqual(stats_dps.kinetic, 1.92) self.assertAlmostEqual(stats_dps.explosive, 3.84) self.assertAlmostEqual(stats_dps.total, 7.2) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_reload(self): fit = Fit() item = ModuleHigh(self.mktype(attrs={ AttrId.dmg_mult: 2.5, AttrId.capacity: 2.0, self.cycle_attr.id: 500, AttrId.charge_rate: 1.0, AttrId.reload_time: 5000 }, effects=[self.effect], default_effect=self.effect).id, state=State.active) item.charge = Charge( self.mktype( attrs={ AttrId.volume: 0.2, AttrId.em_dmg: 5.2, AttrId.therm_dmg: 6.3, AttrId.kin_dmg: 7.4, AttrId.expl_dmg: 8.5 }).id) fit.modules.high.append(item) # Verification dps = item.get_dps(reload=True) self.assertAlmostEqual(dps.em, 13) self.assertAlmostEqual(dps.thermal, 15.75) self.assertAlmostEqual(dps.kinetic, 18.5) self.assertAlmostEqual(dps.explosive, 21.25) self.assertAlmostEqual(dps.total, 68.5) # Cleanup self.assert_solsys_buffers_empty(fit.solar_system) self.assert_log_entries(0)
def test_charge_attr_em_absent(self): fit = Fit() item = ModuleHigh( self.mktype( attrs={ AttrId.capacity: 60.0, self.cycle_attr.id: 5000, AttrId.charge_rate: 1.0, AttrId.reload_time: 10000, AttrId.module_reactivation_delay: 120000}, effects=[self.effect_item], default_effect=self.effect_item).id, state=State.active) item.charge = Charge(self.mktype( attrs={ AttrId.volume: 30.0, AttrId.therm_dmg: 6300, AttrId.kin_dmg: 7400, AttrId.expl_dmg: 8500}, effects=[self.effect_charge], default_effect=self.effect_charge).id) fit.modules.high.append(item) # Verification volley = item.get_volley() self.assertAlmostEqual(volley.em, 0) self.assertAlmostEqual(volley.thermal, 6300) self.assertAlmostEqual(volley.kinetic, 7400) self.assertAlmostEqual(volley.explosive, 8500) self.assertAlmostEqual(volley.total, 22200) # Cleanup self.assert_solsys_buffers_empty(fit.solar_system) self.assert_log_entries(0)
def test_fail_multiple(self): # Check that error works for multiple items self.fit.ship = Ship( self.mktype(attrs={ AttrId.launcher_slots_left: 1 }).id) item_type = self.mktype(effects=[self.effect]) item1 = ModuleHigh(item_type.id) item2 = ModuleHigh(item_type.id) self.fit.modules.high.append(item1) self.fit.modules.high.append(item2) # Action error1 = self.get_error(item1, Restriction.launcher_slot) # Verification self.assertIsNotNone(error1) self.assertEqual(error1.used, 2) self.assertEqual(error1.total, 1) # Action error2 = self.get_error(item2, Restriction.launcher_slot) # Verification self.assertIsNotNone(error2) self.assertEqual(error2.used, 2) self.assertEqual(error2.total, 1) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_effective_attr_single_expl_zero(self): fit = Fit() item = ModuleHigh( self.mktype( attrs={ AttrId.dmg_mult: 2.5, AttrId.capacity: 2.0, self.cycle_attr.id: 500, AttrId.charge_rate: 1.0, AttrId.reload_time: 5000}, effects=[self.effect], default_effect=self.effect).id, state=State.active) item.charge = Charge(self.mktype( attrs={AttrId.volume: 0.2, AttrId.expl_dmg: 0}).id) fit.modules.high.append(item) # Verification profile = ResistProfile(0.2, 0.2, 0.8, 1) volley = item.get_volley(tgt_resists=profile) self.assertAlmostEqual(volley.em, 0) self.assertAlmostEqual(volley.thermal, 0) self.assertAlmostEqual(volley.kinetic, 0) self.assertAlmostEqual(volley.explosive, 0) self.assertAlmostEqual(volley.total, 0) # Cleanup self.assert_solsys_buffers_empty(fit.solar_system) self.assert_log_entries(0)
def test_reload(self): fit = Fit() item = ModuleHigh( self.mktype( attrs={ AttrId.dmg_mult: 2.5, AttrId.capacity: 0.2, self.cycle_attr.id: 500, AttrId.reload_time: 5000}, effects=[self.effect], default_effect=self.effect).id, state=State.active) item.charge = Charge(self.mktype(attrs={ AttrId.volume: 0.1, AttrId.hp: 2.0, AttrId.crystals_get_damaged: 1.0, AttrId.crystal_volatility_dmg: 0.8, AttrId.crystal_volatility_chance: 0.5, AttrId.em_dmg: 5.2, AttrId.therm_dmg: 6.3, AttrId.kin_dmg: 7.4, AttrId.expl_dmg: 8.5}).id) fit.modules.high.append(item) # Verification dps = item.get_dps(reload=True) self.assertAlmostEqual(dps.em, 13) self.assertAlmostEqual(dps.thermal, 15.75) self.assertAlmostEqual(dps.kinetic, 18.5) self.assertAlmostEqual(dps.explosive, 21.25) self.assertAlmostEqual(dps.total, 68.5) # Cleanup self.assert_solsys_buffers_empty(fit.solar_system) self.assert_log_entries(0)
def test_mix_usage_zero(self): # If some item has zero usage and cpu error is still raised, check it's # not raised for item with zero usage self.fit.ship = Ship(self.mktype(attrs={AttrId.cpu_output: 50}).id) item1 = ModuleHigh(self.mktype(attrs={ AttrId.cpu: 100 }, effects=[self.effect]).id, state=State.online) self.fit.modules.high.append(item1) item2 = ModuleHigh(self.mktype(attrs={ AttrId.cpu: 0 }, effects=[self.effect]).id, state=State.online) self.fit.modules.high.append(item2) # Action error1 = self.get_error(item1, Restriction.cpu) # Verification self.assertIsNotNone(error1) self.assertEqual(error1.output, 50) self.assertEqual(error1.total_use, 100) self.assertEqual(error1.item_use, 100) # Action error2 = self.get_error(item2, Restriction.cpu) # Verification self.assertIsNone(error2) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_no_reload(self): fit = Fit() item = ModuleHigh( self.mktype( attrs={ AttrId.dmg_mult: 2.5, AttrId.capacity: 2.0, self.cycle_attr.id: 500, AttrId.charge_rate: 1.0, AttrId.reload_time: 5000}, effects=[self.effect], default_effect=self.effect).id, state=State.active) item.charge = Charge(self.mktype(attrs={ AttrId.volume: 0.2, AttrId.em_dmg: 5.2, AttrId.therm_dmg: 6.3, AttrId.kin_dmg: 7.4, AttrId.expl_dmg: 8.5}).id) fit.modules.high.append(item) # Verification dps = item.get_dps(reload=False) self.assertAlmostEqual(dps.em, 26) self.assertAlmostEqual(dps.thermal, 31.5) self.assertAlmostEqual(dps.kinetic, 37) self.assertAlmostEqual(dps.explosive, 42.5) self.assertAlmostEqual(dps.total, 137) # Cleanup self.assert_solsys_buffers_empty(fit.solar_system) self.assert_log_entries(0)
def test_pass(self): # When total consumption is less than output, no errors should be raised self.fit.ship = Ship(self.mktype(attrs={AttrId.cpu_output: 50}).id) item1 = ModuleHigh(self.mktype(attrs={ AttrId.cpu: 25 }, effects=[self.effect]).id, state=State.online) self.fit.modules.high.append(item1) item2 = ModuleHigh(self.mktype(attrs={ AttrId.cpu: 20 }, effects=[self.effect]).id, state=State.online) self.fit.modules.high.append(item2) # Action error1 = self.get_error(item1, Restriction.cpu) # Verification self.assertIsNone(error1) # Action error2 = self.get_error(item2, Restriction.cpu) # Verification self.assertIsNone(error2) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_fit_charge_to_fully_bound_charge(self): fit = Fit() fit_other = Fit() module = ModuleHigh(self.mktype().id, state=State.active, charge=None) charge = Charge(self.mktype().id) module_other = ModuleHigh( self.mktype().id, state=State.active, charge=None) charge_other = Charge(self.mktype().id) fit.modules.high.append(module) fit_other.modules.high.append(module_other) module.charge = charge module_other.charge = charge_other # Action with self.assertRaises(ValueError): module.charge = charge_other # Verification self.assertIs(module.charge, charge) self.assertIs(module_other.charge, charge_other) # Cleanup self.assert_item_buffers_empty(module) self.assert_item_buffers_empty(charge) self.assert_item_buffers_empty(module_other) self.assert_item_buffers_empty(charge_other) self.assert_solsys_buffers_empty(fit.solar_system) self.assert_solsys_buffers_empty(fit_other.solar_system) self.assert_log_entries(0)
def test_source_to_none(self): tgt_attr = self.mkattr() src_attr = self.mkattr() modifier_container = self.make_modifier(src_attr.id, tgt_attr.id) effect_container = self.mkeffect( category_id=EffectCategoryId.passive, modifiers=[modifier_container]) container = ModuleHigh(self.mktype( attrs={src_attr.id: 20, tgt_attr.id: 100}, effects=[effect_container]).id) modifier_charge = self.make_modifier(src_attr.id, tgt_attr.id) effect_charge = self.mkeffect( category_id=EffectCategoryId.passive, modifiers=[modifier_charge]) charge = Charge(self.mktype( attrs={src_attr.id: 40, tgt_attr.id: 50}, effects=[effect_charge]).id) self.fit.modules.high.append(container) container.charge = charge self.assertAlmostEqual(container.attrs[tgt_attr.id], 140) self.assertAlmostEqual(charge.attrs[tgt_attr.id], 60) # Action self.fit.solar_system.source = None # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_effective_attr_expl_absent(self): fit = Fit() item = ModuleHigh(self.mktype(attrs={ AttrId.dmg_mult: 2.5, AttrId.capacity: 2.0, self.cycle_attr.id: 500, AttrId.charge_rate: 1.0, AttrId.reload_time: 5000 }, effects=[self.effect], default_effect=self.effect).id, state=State.active) item.charge = Charge( self.mktype( attrs={ AttrId.volume: 0.2, AttrId.em_dmg: 5.2, AttrId.therm_dmg: 6.3, AttrId.kin_dmg: 7.4 }).id) fit.modules.high.append(item) # Verification profile = ResistProfile(0.2, 0.2, 0.8, 1) volley = item.get_volley(tgt_resists=profile) self.assertAlmostEqual(volley.em, 10.4) self.assertAlmostEqual(volley.thermal, 12.6) self.assertAlmostEqual(volley.kinetic, 3.7) self.assertAlmostEqual(volley.explosive, 0) self.assertAlmostEqual(volley.total, 26.7) # Cleanup self.assert_solsys_buffers_empty(fit.solar_system) self.assert_log_entries(0)
def setUp(self): CalculatorTestCase.setUp(self) self.tgt_attr = self.mkattr(stackable=1) src_attr1 = self.mkattr() src_attr2 = self.mkattr() src_attr3 = self.mkattr() src_attr4 = self.mkattr() src_attr5 = self.mkattr() modifier_off = self.mkmod(affectee_filter=ModAffecteeFilter.item, affectee_domain=ModDomain.self, affectee_attr_id=self.tgt_attr.id, operator=ModOperator.post_mul, affector_attr_id=src_attr1.id) modifier_on = self.mkmod(affectee_filter=ModAffecteeFilter.item, affectee_domain=ModDomain.self, affectee_attr_id=self.tgt_attr.id, operator=ModOperator.post_mul, affector_attr_id=src_attr2.id) modifier_act = self.mkmod(affectee_filter=ModAffecteeFilter.item, affectee_domain=ModDomain.self, affectee_attr_id=self.tgt_attr.id, operator=ModOperator.post_mul, affector_attr_id=src_attr3.id) modifier_over = self.mkmod(affectee_filter=ModAffecteeFilter.item, affectee_domain=ModDomain.self, affectee_attr_id=self.tgt_attr.id, operator=ModOperator.post_mul, affector_attr_id=src_attr4.id) modifier_disabled = self.mkmod(affectee_filter=ModAffecteeFilter.item, affectee_domain=ModDomain.self, affectee_attr_id=self.tgt_attr.id, operator=ModOperator.post_mul, affector_attr_id=src_attr3.id) effect_cat_offline = self.mkeffect( category_id=EffectCategoryId.passive, modifiers=[modifier_off]) effect_cat_online = self.mkeffect(category_id=EffectCategoryId.online, modifiers=[modifier_on]) effect_cat_active = self.mkeffect(category_id=EffectCategoryId.active, modifiers=[modifier_act]) effect_cat_overload = self.mkeffect( category_id=EffectCategoryId.overload, modifiers=[modifier_over]) online_effect = self.mkeffect(effect_id=EffectId.online, category_id=EffectCategoryId.online) effect_disabled = self.mkeffect(category_id=EffectCategoryId.online, modifiers=[modifier_disabled]) self.item = ModuleHigh( self.mktype(attrs={ self.tgt_attr.id: 100, src_attr1.id: 1.1, src_attr2.id: 1.3, src_attr3.id: 1.5, src_attr4.id: 1.7, src_attr5.id: 2 }, effects=(effect_cat_offline, effect_cat_online, effect_cat_active, effect_cat_overload, online_effect, effect_disabled), default_effect=effect_cat_active).id) self.item.set_effect_mode(effect_disabled.id, EffectMode.force_stop)
def setUp(self): StatsTestCase.setUp(self) self.mkattr(attr_id=AttrId.em_dmg) self.mkattr(attr_id=AttrId.therm_dmg) self.mkattr(attr_id=AttrId.kin_dmg) self.mkattr(attr_id=AttrId.expl_dmg) self.mkattr(attr_id=AttrId.dmg_mult) self.mkattr(attr_id=AttrId.volume) self.mkattr(attr_id=AttrId.capacity) self.mkattr(attr_id=AttrId.reload_time) self.mkattr(attr_id=AttrId.charge_rate) self.mkattr(attr_id=AttrId.fighter_ability_kamikaze_dmg_em) self.mkattr(attr_id=AttrId.fighter_ability_kamikaze_dmg_therm) self.mkattr(attr_id=AttrId.fighter_ability_kamikaze_dmg_kin) self.mkattr(attr_id=AttrId.fighter_ability_kamikaze_dmg_expl) cycle_attr = self.mkattr() effect_dd = self.mkeffect(effect_id=EffectId.projectile_fired, category_id=EffectCategoryId.active, duration_attr_id=cycle_attr.id) effect_suppressor = self.mkeffect( effect_id=EffectId.fighter_ability_kamikaze, category_id=EffectCategoryId.target, duration_attr_id=cycle_attr.id) item_dd = ModuleHigh(self.mktype(attrs={ AttrId.dmg_mult: 2, AttrId.capacity: 1, AttrId.charge_rate: 1, cycle_attr.id: 2500, AttrId.reload_time: 2000 }, effects=[effect_dd], default_effect=effect_dd).id, state=State.active) item_dd.charge = Charge( self.mktype( attrs={ AttrId.volume: 1.0, AttrId.em_dmg: 1.2, AttrId.therm_dmg: 2.4, AttrId.kin_dmg: 4.8, AttrId.expl_dmg: 9.6 }).id) self.item_suppressor = FighterSquad(self.mktype( attrs={ AttrId.fighter_ability_kamikaze_dmg_em: 50000, AttrId.fighter_ability_kamikaze_dmg_therm: 50000, AttrId.fighter_ability_kamikaze_dmg_kin: 50000, AttrId.fighter_ability_kamikaze_dmg_expl: 50000, AttrId.fighter_squadron_max_size: 6, cycle_attr.id: 10000 }, effects=[effect_suppressor], default_effect=effect_suppressor, abilities_data={ FighterAbilityId.kamikaze: AbilityData(0, math.inf) }).id, state=State.active) self.fit.modules.high.append(item_dd) self.fit.fighters.add(self.item_suppressor)
def test_use_multiple_with_none(self): self.fit.modules.high.place(1, ModuleHigh(self.mktype().id)) self.fit.modules.high.place(3, ModuleHigh(self.mktype().id)) # Verification self.assertEqual(self.fit.stats.high_slots.used, 4) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_detached_module_none_to_none(self): module = ModuleHigh(self.mktype().id, state=State.active, charge=None) # Action module.charge = None # Verification self.assertIsNone(module.charge) # Cleanup self.assert_item_buffers_empty(module) self.assert_log_entries(0)
def test_single_item_not_loaded(self): effect_id = self.allocate_effect_id() item = ModuleHigh(self.allocate_type_id()) self.fit.modules.high.append(item) # Verification item.set_effect_mode(effect_id, EffectMode.force_stop) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_detached_module_none_to_free_charge(self): module = ModuleHigh(self.mktype().id, state=State.active, charge=None) charge = Charge(self.mktype().id) # Action module.charge = charge # Verification self.assert_item_buffers_empty(module) self.assert_item_buffers_empty(charge) self.assertIs(module.charge, charge)
def setUp(self): StatsTestCase.setUp(self) self.mkattr(attr_id=AttrId.em_dmg) self.mkattr(attr_id=AttrId.therm_dmg) self.mkattr(attr_id=AttrId.kin_dmg) self.mkattr(attr_id=AttrId.expl_dmg) self.mkattr(attr_id=AttrId.dmg_mult) self.mkattr(attr_id=AttrId.volume) self.mkattr(attr_id=AttrId.capacity) self.mkattr(attr_id=AttrId.reload_time) self.mkattr(attr_id=AttrId.charge_rate) self.mkattr(attr_id=AttrId.fighter_ability_kamikaze_dmg_em) self.mkattr(attr_id=AttrId.fighter_ability_kamikaze_dmg_therm) self.mkattr(attr_id=AttrId.fighter_ability_kamikaze_dmg_kin) self.mkattr(attr_id=AttrId.fighter_ability_kamikaze_dmg_expl) cycle_attr = self.mkattr() effect_dd = self.mkeffect( effect_id=EffectId.projectile_fired, category_id=EffectCategoryId.active, duration_attr_id=cycle_attr.id) effect_suppressor = self.mkeffect( effect_id=EffectId.fighter_ability_kamikaze, category_id=EffectCategoryId.target, duration_attr_id=cycle_attr.id) item_dd = ModuleHigh( self.mktype( attrs={ AttrId.dmg_mult: 2, AttrId.capacity: 1, AttrId.charge_rate: 1, cycle_attr.id: 2500, AttrId.reload_time: 2000}, effects=[effect_dd], default_effect=effect_dd).id, state=State.active) item_dd.charge = Charge(self.mktype(attrs={ AttrId.volume: 1.0, AttrId.em_dmg: 1.2, AttrId.therm_dmg: 2.4, AttrId.kin_dmg: 4.8, AttrId.expl_dmg: 9.6}).id) self.item_suppressor = FighterSquad( self.mktype( attrs={ AttrId.fighter_ability_kamikaze_dmg_em: 50000, AttrId.fighter_ability_kamikaze_dmg_therm: 50000, AttrId.fighter_ability_kamikaze_dmg_kin: 50000, AttrId.fighter_ability_kamikaze_dmg_expl: 50000, AttrId.fighter_squadron_max_size: 6, cycle_attr.id: 10000}, effects=[effect_suppressor], default_effect=effect_suppressor, abilities_data={ FighterAbilityId.kamikaze: AbilityData(0, math.inf)}).id, state=State.active) self.fit.modules.high.append(item_dd) self.fit.fighters.add(self.item_suppressor)
def test_round_down(self): fit = Fit() item = ModuleHigh(self.mktype(attrs={AttrId.capacity: 19.7}).id) item.charge = Charge(self.mktype(attrs={AttrId.volume: 2.0}).id) fit.modules.high.append(item) # Verification self.assertEqual(item.charge_quantity, 9) # Cleanup self.assert_solsys_buffers_empty(fit.solar_system) self.assert_log_entries(0)
def test_charge_attr_volume_absent(self): fit = Fit() item = ModuleHigh(self.mktype(attrs={AttrId.capacity: 20.0}).id) item.charge = Charge(self.mktype().id) fit.modules.high.append(item) # Verification self.assertIsNone(item.charge_quantity) # Cleanup self.assert_solsys_buffers_empty(fit.solar_system) self.assert_log_entries(0)
def test_use_item_effect_absent(self): item1 = ModuleHigh(self.mktype(effects=[self.effect]).id) item2 = ModuleHigh(self.mktype().id) self.fit.modules.high.append(item1) self.fit.modules.high.append(item2) # Verification self.assertEqual(self.fit.stats.launcher_slots.used, 1) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_item_not_loaded(self): fit = Fit() item = ModuleHigh(self.allocate_type_id()) item.charge = Charge(self.mktype(attrs={AttrId.volume: 2.0}).id) fit.modules.high.append(item) # Verification self.assertIsNone(item.charge_quantity) # Cleanup self.assert_solsys_buffers_empty(fit.solar_system) self.assert_log_entries(0)
def test_use_multiple(self): self.fit.modules.high.append( ModuleHigh(self.mktype(effects=[self.effect]).id)) self.fit.modules.high.append( ModuleHigh(self.mktype(effects=[self.effect]).id)) # Verification self.assertEqual(self.fit.stats.launcher_slots.used, 2) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_use_multiple_with_none(self): self.fit.modules.high.place( 1, ModuleHigh(self.mktype(effects=[self.effect]).id)) self.fit.modules.high.place( 3, ModuleHigh(self.mktype(effects=[self.effect]).id)) # Verification # Positions do not matter self.assertEqual(self.fit.stats.launcher_slots.used, 2) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_use_item_effect_disabled(self): item1 = ModuleHigh(self.mktype(effects=[self.effect]).id) item2 = ModuleHigh(self.mktype(effects=[self.effect]).id) item2.set_effect_mode(self.effect.id, EffectMode.force_stop) self.fit.modules.high.append(item1) self.fit.modules.high.append(item2) # Verification self.assertEqual(self.fit.stats.launcher_slots.used, 1) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_use_item_effect_disabled(self): item1 = ModuleHigh(self.mktype(effects=[self.effect]).id) item2 = ModuleHigh(self.mktype(effects=[self.effect]).id) item2.set_effect_mode(self.effect.id, EffectMode.force_stop) self.fit.modules.high.append(item1) self.fit.modules.high.append(item2) # Verification self.assertEqual(self.fit.stats.turret_slots.used, 1) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_fit_none_to_none(self): fit = Fit() module = ModuleHigh(self.mktype().id, state=State.active, charge=None) fit.modules.high.append(module) # Action module.charge = None # Verification self.assertIsNone(module.charge) # Cleanup self.assert_item_buffers_empty(module) self.assert_solsys_buffers_empty(fit.solar_system) self.assert_log_entries(0)
def test_charge_fail_not_loaded(self): item = Charge(self.allocate_type_id()) container = ModuleHigh(self.mktype().id) container.charge = item self.fit.modules.high.append(container) # Action error = self.get_error(item, Restriction.loaded_item) # Verification self.assertIsNotNone(error) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_charge_not_loaded(self): fit = Fit() item = ModuleHigh(self.mktype(attrs={ AttrId.capacity: 100.0, AttrId.charge_rate: 2.0}).id) item.charge = Charge(self.allocate_type_id()) fit.modules.high.append(item) # Verification self.assertIsNone(item.cycles_until_reload) # Cleanup self.assert_solsys_buffers_empty(fit.solar_system) self.assert_log_entries(0)
def test_charge_pass(self): item = Charge(self.mktype(category_id=TypeCategoryId.charge).id) container = ModuleHigh(self.mktype().id) container.charge = item self.fit.modules.high.append(container) # Action error = self.get_error(item, Restriction.item_class) # Verification self.assertIsNone(error) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_charge(self): module = ModuleHigh(self.make_item_types()) charge = Charge(self.make_item_types()) module.charge = charge self.fit.modules.high.append(module) self.assertAlmostEqual(charge.attrs[self.tgt_attr_id], 18) # Action self.fit.solar_system.source = 'src2' # Verification self.assertAlmostEqual(charge.attrs[self.tgt_attr_id], 14) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_pass_item_effect_disabled(self): self.fit.ship = Ship(self.mktype( attrs={AttrId.launcher_slots_left: 0}).id) item = ModuleHigh(self.mktype(effects=[self.effect]).id) item.set_effect_mode(self.effect.id, EffectMode.force_stop) self.fit.modules.high.append(item) # Action error = self.get_error(item, Restriction.launcher_slot) # Verification self.assertIsNone(error) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_status_stopped(self): effect = self.mkeffect(category_id=EffectCategoryId.passive) item = ModuleHigh(self.mktype(effects=[effect]).id, state=State.offline) self.fit.modules.high.append(item) item.set_effect_mode(effect.id, EffectMode.force_stop) # Verification self.assertEqual(len(item.effects), 1) self.assertIn(effect.id, item.effects) effect_data = item.effects[effect.id] self.assertIs(effect_data.status, False) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)