Ejemplo n.º 1
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)
Ejemplo n.º 2
0
 def test_item_inside_value_failure(self):
     fit = Fit()
     fit_other = Fit()
     item1 = ModuleHigh(self.mktype().id)
     item2 = ModuleHigh(self.mktype().id)
     item3 = ModuleHigh(self.mktype().id)
     fit.modules.high.append(item1)
     fit.modules.high.append(item2)
     fit_other.modules.high.append(item3)
     # Action
     with self.assertRaises(ValueError):
         fit.modules.high.insert(1, item3)
     # Verification
     self.assertIs(len(fit.modules.high), 2)
     self.assertIs(fit.modules.high[0], item1)
     self.assertIs(fit.modules.high[1], item2)
     self.assertIs(len(fit_other.modules.high), 1)
     self.assertIs(fit_other.modules.high[0], item3)
     # 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_solsys_buffers_empty(fit_other.solar_system)
     self.assert_log_entries(0)
Ejemplo n.º 3
0
 def test_switch_item(self):
     # Here we create 2 separate fits with ships; each ship affects module
     # with different strength. When we pass module from one fit to another,
     # its internal attribute storage should be cleared. If it wasn't
     # cleared, we wouldn't be able to get refreshed value of attribute
     # Setup
     src_attr_id = self.allocate_attr_id('src1', 'src2')
     self.mkattr(src='src1', attr_id=src_attr_id)
     self.mkattr(src='src2', attr_id=src_attr_id)
     tgt_attr_id = self.allocate_attr_id('src1', 'src2')
     self.mkattr(src='src1', attr_id=tgt_attr_id)
     self.mkattr(src='src2', attr_id=tgt_attr_id)
     modifier = self.mkmod(affectee_filter=ModAffecteeFilter.domain,
                           affectee_domain=ModDomain.ship,
                           affectee_attr_id=tgt_attr_id,
                           operator=ModOperator.post_percent,
                           affector_attr_id=src_attr_id)
     effect_id = self.allocate_effect_id('src1', 'src2')
     effect_src1 = self.mkeffect(src='src1',
                                 effect_id=effect_id,
                                 category_id=EffectCategoryId.passive,
                                 modifiers=[modifier])
     effect_src2 = self.mkeffect(src='src2',
                                 effect_id=effect_id,
                                 category_id=EffectCategoryId.passive,
                                 modifiers=[modifier])
     ship_type_id = self.allocate_type_id('src1', 'src2')
     ship1 = Ship(
         self.mktype(src='src1',
                     type_id=ship_type_id,
                     attrs={
                         src_attr_id: 10
                     },
                     effects=[effect_src1]).id)
     ship2 = Ship(
         self.mktype(src='src2',
                     type_id=ship_type_id,
                     attrs={
                         src_attr_id: 20
                     },
                     effects=[effect_src2]).id)
     item_type_id = self.allocate_type_id('src1', 'src2')
     self.mktype(src='src1', type_id=item_type_id, attrs={tgt_attr_id: 50})
     self.mktype(src='src2', type_id=item_type_id, attrs={tgt_attr_id: 50})
     item = Rig(item_type_id)
     fit1 = Fit(SolarSystem('src1'))
     fit1.ship = ship1
     fit2 = Fit(SolarSystem('src2'))
     fit2.ship = ship2
     fit1.rigs.add(item)
     self.assertAlmostEqual(item.attrs.get(tgt_attr_id), 55)
     # Action
     fit1.rigs.remove(item)
     fit2.rigs.add(item)
     # Verification
     self.assertAlmostEqual(item.attrs.get(tgt_attr_id), 60)
     # Cleanup
     self.assert_solsys_buffers_empty(fit1.solar_system)
     self.assert_solsys_buffers_empty(fit2.solar_system)
     self.assert_log_entries(0)
Ejemplo n.º 4
0
 def test_item_squad_size_absent(self):
     fit = Fit()
     bomb_type = self.make_charge_type({
         AttrId.em_dmg: 52,
         AttrId.therm_dmg: 63,
         AttrId.kin_dmg: 74,
         AttrId.expl_dmg: 85
     })
     item = self.make_item(attrs={
         AttrId.fighter_ability_launch_bomb_type:
         bomb_type.id,
         AttrId.fighter_squadron_max_size:
         9
     },
                           item_class=Drone)
     fit.drones.add(item)
     # Verification
     volley = item.get_volley()
     self.assertAlmostEqual(volley.em, 52)
     self.assertAlmostEqual(volley.thermal, 63)
     self.assertAlmostEqual(volley.kinetic, 74)
     self.assertAlmostEqual(volley.explosive, 85)
     self.assertAlmostEqual(volley.total, 274)
     # Cleanup
     self.assert_solsys_buffers_empty(fit.solar_system)
     self.assert_log_entries(0)
Ejemplo n.º 5
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)
Ejemplo n.º 6
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)
Ejemplo n.º 7
0
 def test_disabling_not_side_effect(self):
     # Setup
     src_attr = self.mkattr()
     tgt_attr = self.mkattr()
     modifier = self.mkmod(affectee_filter=ModAffecteeFilter.item,
                           affectee_domain=ModDomain.self,
                           affectee_attr_id=tgt_attr.id,
                           operator=ModOperator.post_mul,
                           affector_attr_id=src_attr.id)
     effect = self.mkeffect(category_id=EffectCategoryId.passive,
                            modifiers=[modifier])
     fit = Fit()
     item = Booster(
         self.mktype(attrs={
             tgt_attr.id: 100,
             src_attr.id: 1.2
         },
                     effects=[effect]).id)
     fit.boosters.add(item)
     self.assertAlmostEqual(item.attrs[tgt_attr.id], 120)
     # Verification
     with self.assertRaises(NoSuchSideEffectError):
         item.set_side_effect_status(effect.id, False)
     self.assertNotIn(effect.id, item.side_effects)
     self.assertAlmostEqual(item.attrs[tgt_attr.id], 120)
     # Cleanup
     self.assert_solsys_buffers_empty(fit.solar_system)
     self.assert_log_entries(0)
Ejemplo n.º 8
0
 def test_slice(self):
     fit = Fit()
     item1 = ModuleHigh(self.mktype().id)
     item2 = ModuleHigh(self.mktype().id)
     fit.modules.high.append(item1)
     fit.modules.high.place(3, item2)
     slice_full = fit.modules.high[:]
     self.assertEqual(len(slice_full), 4)
     self.assertIs(slice_full[0], item1)
     self.assertIsNone(slice_full[1])
     self.assertIsNone(slice_full[2])
     self.assertIs(slice_full[3], item2)
     slice_positive = fit.modules.high[0:2]
     self.assertEqual(len(slice_positive), 2)
     self.assertIs(slice_positive[0], item1)
     self.assertIsNone(slice_positive[1])
     slice_negative = fit.modules.high[-2:]
     self.assertEqual(len(slice_negative), 2)
     self.assertIsNone(slice_negative[0])
     self.assertIs(slice_negative[1], item2)
     slice_step = fit.modules.high[::2]
     self.assertEqual(len(slice_step), 2)
     self.assertIs(slice_step[0], item1)
     self.assertIsNone(slice_step[1])
     # Cleanup
     self.assert_item_buffers_empty(item1)
     self.assert_item_buffers_empty(item2)
     self.assert_solsys_buffers_empty(fit.solar_system)
     self.assert_log_entries(0)
Ejemplo n.º 9
0
 def test_none(self):
     fit = Fit()
     item1 = ModuleHigh(self.mktype().id)
     item2 = ModuleHigh(self.mktype().id)
     fit.modules.high.append(item1)
     fit.modules.high.append(item2)
     # Action
     with self.assertRaises(ValueError):
         fit.modules.high.free(None)
     # Verification
     self.assertIs(len(fit.modules.high), 2)
     self.assertIs(fit.modules.high[0], item1)
     self.assertIs(fit.modules.high[1], item2)
     # Cleanup
     fit.modules.high.free(item1)
     # Action
     fit.modules.high.free(None)
     # Verification
     self.assertIs(len(fit.modules.high), 2)
     self.assertIsNone(fit.modules.high[0])
     self.assertIs(fit.modules.high[1], item2)
     # Cleanup
     self.assert_item_buffers_empty(item1)
     self.assert_item_buffers_empty(item2)
     self.assert_solsys_buffers_empty(fit.solar_system)
     self.assert_log_entries(0)
Ejemplo n.º 10
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)
Ejemplo n.º 11
0
 def test_status_item_inactive(self):
     # Even when item is not set to active, ability statuses should be shown
     # like item is active
     # Setup
     effect1 = self.mkeffect(
         effect_id=EffectId.fighter_ability_attack_m,
         category_id=EffectCategoryId.active)
     effect2 = self.mkeffect(
         effect_id=EffectId.fighter_ability_microwarpdrive,
         category_id=EffectCategoryId.active)
     effect3 = self.mkeffect(
         effect_id=EffectId.fighter_ability_missiles,
         category_id=EffectCategoryId.active)
     fighter_type = self.mktype(
         effects=(effect1, effect2, effect3),
         default_effect=effect1,
         abilities_data={
             FighterAbilityId.pulse_cannon: AbilityData(0, math.inf),
             FighterAbilityId.microwarpdrive: AbilityData(60, math.inf),
             FighterAbilityId.heavy_rocket_salvo_em: AbilityData(0, 12)})
     fit = Fit()
     item = FighterSquad(fighter_type.id, state=State.online)
     fit.fighters.add(item)
     # Verification
     abilities = item.abilities
     self.assertEqual(len(abilities), 3)
     self.assertIs(abilities[FighterAbilityId.pulse_cannon], True)
     self.assertIs(abilities[FighterAbilityId.microwarpdrive], False)
     self.assertIs(abilities[FighterAbilityId.heavy_rocket_salvo_em], False)
     # Cleanup
     self.assert_solsys_buffers_empty(fit.solar_system)
     self.assert_log_entries(0)
Ejemplo n.º 12
0
 def test_ability_disabling_no_ability(self):
     # Setup
     src_attr = self.mkattr()
     tgt_attr = self.mkattr()
     modifier = self.mkmod(
         affectee_filter=ModAffecteeFilter.item,
         affectee_domain=ModDomain.self,
         affectee_attr_id=tgt_attr.id,
         operator=ModOperator.post_percent,
         affector_attr_id=src_attr.id)
     effect = self.mkeffect(
         effect_id=EffectId.fighter_ability_attack_m,
         category_id=EffectCategoryId.active,
         modifiers=[modifier])
     fighter_type = self.mktype(
         attrs={src_attr.id: 50, tgt_attr.id: 10},
         effects=[effect],
         default_effect=effect,
         abilities_data={
             FighterAbilityId.pulse_cannon: AbilityData(0, math.inf)})
     fit = Fit()
     item = FighterSquad(fighter_type.id, state=State.active)
     fit.fighters.add(item)
     self.assertAlmostEqual(item.attrs[tgt_attr.id], 15)
     # Verification
     with self.assertRaises(NoSuchAbilityError):
         item.set_ability_status(FighterAbilityId.beam_cannon, False)
     self.assertIs(item.abilities[FighterAbilityId.pulse_cannon], True)
     self.assertAlmostEqual(item.attrs[tgt_attr.id], 15)
     # Cleanup
     self.assert_solsys_buffers_empty(fit.solar_system)
     self.assert_log_entries(0)
Ejemplo n.º 13
0
 def test_generic(self):
     fit = Fit()
     item = Ship(self.mktype(attrs={
         AttrId.em_dmg_resonance: 0.01,
         AttrId.therm_dmg_resonance: 0.02,
         AttrId.kin_dmg_resonance: 0.03,
         AttrId.expl_dmg_resonance: 0.04,
         AttrId.armor_em_dmg_resonance: 0.05,
         AttrId.armor_therm_dmg_resonance: 0.06,
         AttrId.armor_kin_dmg_resonance: 0.07,
         AttrId.armor_expl_dmg_resonance: 0.08,
         AttrId.shield_em_dmg_resonance: 0.09,
         AttrId.shield_therm_dmg_resonance: 0.1,
         AttrId.shield_kin_dmg_resonance: 0.11,
         AttrId.shield_expl_dmg_resonance: 0.12}).id)
     fit.ship = item
     # Verification
     self.assertAlmostEqual(item.resists.hull.em, 0.99)
     self.assertAlmostEqual(item.resists.hull.thermal, 0.98)
     self.assertAlmostEqual(item.resists.hull.kinetic, 0.97)
     self.assertAlmostEqual(item.resists.hull.explosive, 0.96)
     self.assertAlmostEqual(item.resists.armor.em, 0.95)
     self.assertAlmostEqual(item.resists.armor.thermal, 0.94)
     self.assertAlmostEqual(item.resists.armor.kinetic, 0.93)
     self.assertAlmostEqual(item.resists.armor.explosive, 0.92)
     self.assertAlmostEqual(item.resists.shield.em, 0.91)
     self.assertAlmostEqual(item.resists.shield.thermal, 0.9)
     self.assertAlmostEqual(item.resists.shield.kinetic, 0.89)
     self.assertAlmostEqual(item.resists.shield.explosive, 0.88)
     # Cleanup
     self.assert_solsys_buffers_empty(fit.solar_system)
     self.assert_log_entries(0)
Ejemplo n.º 14
0
 def test_generic(self):
     fit = Fit()
     bomb_type = self.make_charge_type({
         AttrId.em_dmg: 52,
         AttrId.therm_dmg: 63,
         AttrId.kin_dmg: 74,
         AttrId.expl_dmg: 85
     })
     item = self.make_item({
         AttrId.fighter_ability_launch_bomb_type:
         bomb_type.id,
         AttrId.fighter_squadron_max_size:
         9
     })
     fit.fighters.add(item)
     # Verification
     volley = item.get_volley()
     self.assertAlmostEqual(volley.em, 468)
     self.assertAlmostEqual(volley.thermal, 567)
     self.assertAlmostEqual(volley.kinetic, 666)
     self.assertAlmostEqual(volley.explosive, 765)
     self.assertAlmostEqual(volley.total, 2466)
     # Cleanup
     self.assert_solsys_buffers_empty(fit.solar_system)
     self.assert_log_entries(0)
Ejemplo n.º 15
0
 def test_ability_charges_zero(self):
     self.abilities_data = {FighterAbilityId.launch_bomb: AbilityData(0, 0)}
     fit = Fit()
     bomb_type = self.make_charge_type({
         AttrId.em_dmg: 52,
         AttrId.therm_dmg: 63,
         AttrId.kin_dmg: 74,
         AttrId.expl_dmg: 85
     })
     item = self.make_item({
         AttrId.fighter_ability_launch_bomb_type:
         bomb_type.id,
         AttrId.fighter_squadron_max_size:
         9
     })
     fit.fighters.add(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)
Ejemplo n.º 16
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)
Ejemplo n.º 17
0
 def test_reload(self):
     fit = Fit()
     bomb_type = self.make_charge_type({
         AttrId.em_dmg: 52,
         AttrId.therm_dmg: 63,
         AttrId.kin_dmg: 74,
         AttrId.expl_dmg: 85
     })
     item = self.make_item({
         AttrId.fighter_ability_launch_bomb_type:
         bomb_type.id,
         AttrId.fighter_squadron_max_size:
         9,
         self.cycle_attr.id:
         60000
     })
     fit.fighters.add(item)
     # Verification
     dps = item.get_dps(reload=True)
     self.assertAlmostEqual(dps.em, 7.8)
     self.assertAlmostEqual(dps.thermal, 9.45)
     self.assertAlmostEqual(dps.kinetic, 11.1)
     self.assertAlmostEqual(dps.explosive, 12.75)
     self.assertAlmostEqual(dps.total, 41.1)
     # Cleanup
     self.assert_solsys_buffers_empty(fit.solar_system)
     self.assert_log_entries(0)
Ejemplo n.º 18
0
 def test_none_to_item_value_failure(self):
     fit = Fit()
     fit_other = Fit()
     item = Ship(self.mktype().id)
     fit_other.ship = item
     # Action
     with self.assertRaises(ValueError):
         fit.ship = item
     # Verification
     self.assertIsNone(fit.ship)
     self.assertIs(fit_other.ship, item)
     # Cleanup
     self.assert_item_buffers_empty(item)
     self.assert_solsys_buffers_empty(fit.solar_system)
     self.assert_solsys_buffers_empty(fit_other.solar_system)
     self.assert_log_entries(0)
Ejemplo n.º 19
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.free(item2)
     # Verification
     self.assertEqual(len(fit.modules.high), 7)
     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.assertIsNone(fit.modules.high[5])
     self.assertIs(fit.modules.high[6], item3)
     # Action
     fit.modules.high.free(item3)
     # Verification
     self.assertEqual(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)
Ejemplo n.º 20
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)
Ejemplo n.º 21
0
 def test_item_attr_hp_all_absent(self):
     fit = Fit()
     item = Ship(
         self.mktype(
             attrs={
                 AttrId.em_dmg_resonance: 0.8,
                 AttrId.therm_dmg_resonance: 0.8,
                 AttrId.kin_dmg_resonance: 0.8,
                 AttrId.expl_dmg_resonance: 0.8,
                 AttrId.armor_em_dmg_resonance: 0.4,
                 AttrId.armor_therm_dmg_resonance: 0.4,
                 AttrId.armor_kin_dmg_resonance: 0.4,
                 AttrId.armor_expl_dmg_resonance: 0.4,
                 AttrId.shield_em_dmg_resonance: 0.2,
                 AttrId.shield_therm_dmg_resonance: 0.2,
                 AttrId.shield_kin_dmg_resonance: 0.2,
                 AttrId.shield_expl_dmg_resonance: 0.2
             }).id)
     fit.ship = item
     # Verification
     self.assertAlmostEqual(item.worst_case_ehp.hull, 0)
     self.assertAlmostEqual(item.worst_case_ehp.armor, 0)
     self.assertAlmostEqual(item.worst_case_ehp.shield, 0)
     self.assertAlmostEqual(item.worst_case_ehp.total, 0)
     # Cleanup
     self.assert_solsys_buffers_empty(fit.solar_system)
     self.assert_log_entries(0)
Ejemplo n.º 22
0
 def test_worst_em(self):
     fit = Fit()
     item = Ship(
         self.mktype(
             attrs={
                 AttrId.hp: 1,
                 AttrId.em_dmg_resonance: 0.8,
                 AttrId.therm_dmg_resonance: 0.7,
                 AttrId.kin_dmg_resonance: 0.7,
                 AttrId.expl_dmg_resonance: 0.7,
                 AttrId.armor_hp: 10,
                 AttrId.armor_em_dmg_resonance: 0.4,
                 AttrId.armor_therm_dmg_resonance: 0.3,
                 AttrId.armor_kin_dmg_resonance: 0.3,
                 AttrId.armor_expl_dmg_resonance: 0.3,
                 AttrId.shield_capacity: 100,
                 AttrId.shield_em_dmg_resonance: 0.2,
                 AttrId.shield_therm_dmg_resonance: 0.1,
                 AttrId.shield_kin_dmg_resonance: 0.1,
                 AttrId.shield_expl_dmg_resonance: 0.1
             }).id)
     fit.ship = item
     # Verification
     self.assertAlmostEqual(item.worst_case_ehp.hull, 1.25)
     self.assertAlmostEqual(item.worst_case_ehp.armor, 25)
     self.assertAlmostEqual(item.worst_case_ehp.shield, 500)
     self.assertAlmostEqual(item.worst_case_ehp.total, 526.25)
     # Cleanup
     self.assert_solsys_buffers_empty(fit.solar_system)
     self.assert_log_entries(0)
Ejemplo n.º 23
0
 def test_contains(self):
     fit = Fit()
     item1 = ModuleHigh(self.mktype().id)
     item2 = ModuleHigh(self.mktype().id)
     self.assertFalse(item1 in fit.modules.high)
     self.assertFalse(None in fit.modules.high)
     self.assertFalse(item2 in fit.modules.high)
     fit.modules.high.append(item1)
     self.assertTrue(item1 in fit.modules.high)
     self.assertFalse(None in fit.modules.high)
     self.assertFalse(item2 in fit.modules.high)
     fit.modules.high.place(3, item2)
     self.assertTrue(item1 in fit.modules.high)
     self.assertTrue(None in fit.modules.high)
     self.assertTrue(item2 in fit.modules.high)
     fit.modules.high.remove(item1)
     self.assertFalse(item1 in fit.modules.high)
     self.assertTrue(None in fit.modules.high)
     self.assertTrue(item2 in fit.modules.high)
     fit.modules.high.remove(item2)
     self.assertFalse(item1 in fit.modules.high)
     self.assertFalse(None in fit.modules.high)
     self.assertFalse(item2 in fit.modules.high)
     # Cleanup
     self.assert_item_buffers_empty(item1)
     self.assert_item_buffers_empty(item2)
     self.assert_solsys_buffers_empty(fit.solar_system)
     self.assert_log_entries(0)
Ejemplo n.º 24
0
 def test_round_down(self):
     fit = Fit()
     item = ModuleHigh(self.mktype(attrs={
         AttrId.capacity: 1.0
     },
                                   effects=[self.effect],
                                   default_effect=self.effect).id,
                       state=State.active)
     item.charge = Charge(
         self.mktype(
             attrs={
                 AttrId.volume: 1.0,
                 AttrId.crystals_get_damaged: 1.0,
                 AttrId.hp: 1.0,
                 AttrId.crystal_volatility_chance: 0.1,
                 AttrId.crystal_volatility_dmg: 0.01,
                 AttrId.em_dmg: 1.0,
                 AttrId.therm_dmg: 1.0,
                 AttrId.kin_dmg: 1.0,
                 AttrId.expl_dmg: 1.0
             }).id)
     fit.modules.high.append(item)
     # Verification
     self.assertEqual(item.cycles_until_reload, 1000)
     # Cleanup
     self.assert_solsys_buffers_empty(fit.solar_system)
     self.assert_log_entries(0)
Ejemplo n.º 25
0
 def test_enabling(self):
     # Setup
     chance_attr = self.mkattr()
     src_attr = self.mkattr()
     tgt_attr = self.mkattr()
     modifier = self.mkmod(affectee_filter=ModAffecteeFilter.item,
                           affectee_domain=ModDomain.self,
                           affectee_attr_id=tgt_attr.id,
                           operator=ModOperator.post_mul,
                           affector_attr_id=src_attr.id)
     effect = self.mkeffect(category_id=EffectCategoryId.passive,
                            fitting_usage_chance_attr_id=chance_attr.id,
                            modifiers=[modifier])
     fit = Fit()
     item = Booster(
         self.mktype(attrs={
             chance_attr.id: 0.5,
             tgt_attr.id: 100,
             src_attr.id: 1.2
         },
                     effects=[effect]).id)
     fit.boosters.add(item)
     self.assertAlmostEqual(item.attrs[tgt_attr.id], 100)
     # Action
     item.set_side_effect_status(effect.id, True)
     # Verification
     self.assertIs(item.side_effects[effect.id].status, True)
     self.assertAlmostEqual(item.attrs[tgt_attr.id], 120)
     # Cleanup
     self.assert_solsys_buffers_empty(fit.solar_system)
     self.assert_log_entries(0)
Ejemplo n.º 26
0
 def test_effective(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
     profile = ResistProfile(0.2, 0.2, 0.8, 1)
     dps = item.get_dps(tgt_resists=profile)
     self.assertAlmostEqual(dps.em, 20.8)
     self.assertAlmostEqual(dps.thermal, 25.2)
     self.assertAlmostEqual(dps.kinetic, 7.4)
     self.assertAlmostEqual(dps.explosive, 0)
     self.assertAlmostEqual(dps.total, 53.4)
     # Cleanup
     self.assert_solsys_buffers_empty(fit.solar_system)
     self.assert_log_entries(0)
Ejemplo n.º 27
0
 def test_effect_disabled(self):
     fit = Fit()
     item = Drone(self.mktype(attrs={
         AttrId.dmg_mult: 2.5,
         AttrId.em_dmg: 52,
         AttrId.therm_dmg: 63,
         AttrId.kin_dmg: 74,
         AttrId.expl_dmg: 85,
         self.cycle_attr.id: 4000
     },
                              effects=[self.effect],
                              default_effect=self.effect).id,
                  state=State.active)
     item.set_effect_mode(self.effect.id, EffectMode.force_stop)
     fit.drones.add(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)
Ejemplo n.º 28
0
 def test_reactivation_shorter_than_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: 6500,
         AttrId.module_reactivation_delay: 1500
     },
                                   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, 5.2)
     self.assertAlmostEqual(dps.thermal, 6.3)
     self.assertAlmostEqual(dps.kinetic, 7.4)
     self.assertAlmostEqual(dps.explosive, 8.5)
     self.assertAlmostEqual(dps.total, 27.4)
     # Cleanup
     self.assert_solsys_buffers_empty(fit.solar_system)
     self.assert_log_entries(0)
Ejemplo n.º 29
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)
Ejemplo n.º 30
0
 def test_non_uniform(self):
     fit = Fit()
     item = Ship(
         self.mktype(
             attrs={
                 AttrId.hp: 10,
                 AttrId.em_dmg_resonance: 0.9,
                 AttrId.therm_dmg_resonance: 0.8,
                 AttrId.kin_dmg_resonance: 0.7,
                 AttrId.expl_dmg_resonance: 0.6,
                 AttrId.armor_hp: 50,
                 AttrId.armor_em_dmg_resonance: 0.4,
                 AttrId.armor_therm_dmg_resonance: 0.6,
                 AttrId.armor_kin_dmg_resonance: 0.8,
                 AttrId.armor_expl_dmg_resonance: 0.9,
                 AttrId.shield_capacity: 600,
                 AttrId.shield_em_dmg_resonance: 1.0,
                 AttrId.shield_therm_dmg_resonance: 0.8,
                 AttrId.shield_kin_dmg_resonance: 0.6,
                 AttrId.shield_expl_dmg_resonance: 0.5
             }).id)
     fit.ship = item
     # Verification
     results = item.get_ehp(DmgProfile(25, 6, 8.333, 1))
     self.assertAlmostEqual(results.hull, 11.957, places=3)
     self.assertAlmostEqual(results.armor, 95.276, places=3)
     self.assertAlmostEqual(results.shield, 685.551, places=3)
     self.assertAlmostEqual(results.total, 792.783, places=3)
     # Cleanup
     self.assert_solsys_buffers_empty(fit.solar_system)
     self.assert_log_entries(0)