Exemple #1
0
 def test_fail_multiple_with_nones(self):
     # Make sure Nones are processed properly
     self.fit.ship = Ship(self.mktype(attrs={AttrId.low_slots: 3}).id)
     item_type = self.mktype()
     item1 = ModuleLow(item_type.id)
     item2 = ModuleLow(item_type.id)
     item3 = ModuleLow(item_type.id)
     self.fit.modules.low.place(1, item1)
     self.fit.modules.low.place(4, item2)
     self.fit.modules.low.place(6, item3)
     # Action
     error1 = self.get_error(item1, Restriction.low_slot)
     # Verification
     self.assertIsNone(error1)
     # Action
     error2 = self.get_error(item2, Restriction.low_slot)
     # Verification
     self.assertIsNotNone(error2)
     self.assertEqual(error2.used, 7)
     self.assertEqual(error2.total, 3)
     # Action
     error3 = self.get_error(item2, Restriction.low_slot)
     # Verification
     self.assertIsNotNone(error3)
     self.assertEqual(error3.used, 7)
     self.assertEqual(error3.total, 3)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
 def test_rep_amount_recalc_aar_attr_mult_changed(self):
     multmod_src_attr = self.mkattr()
     multmod_mod = self.mkmod(
         affectee_filter=ModAffecteeFilter.domain,
         affectee_domain=ModDomain.ship,
         affectee_attr_id=AttrId.charged_armor_dmg_mult,
         operator=ModOperator.post_percent,
         affector_attr_id=multmod_src_attr.id)
     multmod_effect = self.mkeffect(
         category_id=EffectCategoryId.passive,
         modifiers=[multmod_mod])
     multmod = ModuleLow(self.mktype(
         attrs={multmod_src_attr.id: 50},
         effects=[multmod_effect]).id)
     effect = self.mkeffect(
         effect_id=EffectId.fueled_armor_repair,
         category_id=EffectCategoryId.active)
     aar = ModuleLow(
         self.mktype(
             attrs={
                 AttrId.armor_dmg_amount: 50,
                 AttrId.charged_armor_dmg_mult: 3},
             effects=[effect],
             default_effect=effect).id,
         state=State.active)
     aar.charge = Charge(self.mktype(type_id=TypeId.nanite_repair_paste).id)
     self.fit.modules.low.append(aar)
     self.assertAlmostEqual(aar.attrs[AttrId.armor_dmg_amount], 150)
     # Action
     self.fit.modules.low.append(multmod)
     # Verification
     self.assertAlmostEqual(aar.attrs[AttrId.armor_dmg_amount], 225)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemple #3
0
 def test_no_loop_half_history(self):
     # Setup
     ship = Ship(self.make_ship_type((0.5, 0.65, 0.75, 0.9)).id)
     self.fit.ship = ship
     rah_type = self.make_rah_type((0.85, 0.85, 0.85, 0.85), 6, 1000)
     rah1 = ModuleLow(rah_type.id, state=State.active)
     rah2 = ModuleLow(rah_type.id, state=State.overload)
     self.fit.modules.low.equip(rah1)
     self.fit.modules.low.equip(rah2)
     # Verification
     # Same as previous test, but here whole history is just 5 ticks, and we
     # cannot ignore all of them - here we should ignore just 2 first ticks
     self.assertAlmostEqual(rah1.attrs[self.armor_em.id], 0.94, places=3)
     self.assertAlmostEqual(rah1.attrs[self.armor_therm.id], 0.88, places=3)
     self.assertAlmostEqual(rah1.attrs[self.armor_kin.id], 0.82, places=3)
     self.assertAlmostEqual(rah1.attrs[self.armor_expl.id], 0.76, places=3)
     self.assertAlmostEqual(rah2.attrs[self.armor_em.id], 0.97, places=3)
     self.assertAlmostEqual(rah2.attrs[self.armor_therm.id], 0.85, places=3)
     self.assertAlmostEqual(rah2.attrs[self.armor_kin.id], 0.85, places=3)
     self.assertAlmostEqual(rah2.attrs[self.armor_expl.id], 0.73, places=3)
     self.assertAlmostEqual(ship.attrs[self.armor_em.id], 0.458, places=3)
     self.assertAlmostEqual(ship.attrs[self.armor_therm.id],
                            0.495,
                            places=3)
     self.assertAlmostEqual(ship.attrs[self.armor_kin.id], 0.535, places=3)
     self.assertAlmostEqual(ship.attrs[self.armor_expl.id], 0.52, places=3)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemple #4
0
 def test_double_run_unsynced(self):
     # Setup
     ship = Ship(self.make_ship_type((0.5, 0.65, 0.75, 0.9)).id)
     self.fit.ship = ship
     rah_type = self.make_rah_type((0.85, 0.85, 0.85, 0.85), 6, 1000)
     rah1 = ModuleLow(rah_type.id, state=State.active)
     rah2 = ModuleLow(rah_type.id, state=State.overload)
     self.fit.modules.low.equip(rah1)
     self.fit.modules.low.equip(rah2)
     # Verification
     self.assertAlmostEqual(rah1.attrs[self.armor_em.id], 0.975, places=3)
     self.assertAlmostEqual(rah1.attrs[self.armor_therm.id],
                            0.835,
                            places=3)
     self.assertAlmostEqual(rah1.attrs[self.armor_kin.id], 0.83, places=3)
     self.assertAlmostEqual(rah1.attrs[self.armor_expl.id], 0.76, places=3)
     self.assertAlmostEqual(rah2.attrs[self.armor_em.id], 0.979, places=3)
     self.assertAlmostEqual(rah2.attrs[self.armor_therm.id], 0.91, places=3)
     self.assertAlmostEqual(rah2.attrs[self.armor_kin.id], 0.796, places=3)
     self.assertAlmostEqual(rah2.attrs[self.armor_expl.id], 0.715, places=3)
     self.assertAlmostEqual(ship.attrs[self.armor_em.id], 0.479, places=3)
     self.assertAlmostEqual(ship.attrs[self.armor_therm.id], 0.5, places=3)
     self.assertAlmostEqual(ship.attrs[self.armor_kin.id], 0.509, places=3)
     self.assertAlmostEqual(ship.attrs[self.armor_expl.id], 0.509, places=3)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemple #5
0
 def test_stacking(self):
     # Setup
     ship = Ship(self.make_ship_type((0.5, 0.65, 0.75, 0.9)).id)
     self.fit.ship = ship
     rah = ModuleLow(
         self.make_rah_type((0.85, 0.85, 0.85, 0.85), 6, 1000).id,
         state=State.active)
     self.fit.modules.low.equip(rah)
     resmod_src_attr = self.mkattr()
     resmod_mod_em = self.mkmod(
         affectee_filter=ModAffecteeFilter.item,
         affectee_domain=ModDomain.ship,
         affectee_attr_id=self.armor_em.id,
         operator=ModOperator.pre_mul,
         affector_attr_id=resmod_src_attr.id)
     resmod_mod_therm = self.mkmod(
         affectee_filter=ModAffecteeFilter.item,
         affectee_domain=ModDomain.ship,
         affectee_attr_id=self.armor_therm.id,
         operator=ModOperator.pre_mul,
         affector_attr_id=resmod_src_attr.id)
     resmod_mod_kin = self.mkmod(
         affectee_filter=ModAffecteeFilter.item,
         affectee_domain=ModDomain.ship,
         affectee_attr_id=self.armor_kin.id,
         operator=ModOperator.pre_mul,
         affector_attr_id=resmod_src_attr.id)
     resmod_mod_expl = self.mkmod(
         affectee_filter=ModAffecteeFilter.item,
         affectee_domain=ModDomain.ship,
         affectee_attr_id=self.armor_expl.id,
         operator=ModOperator.pre_mul,
         affector_attr_id=resmod_src_attr.id)
     resmod_effect = self.mkeffect(
         category_id=EffectCategoryId.passive,
         modifiers=[
             resmod_mod_em,
             resmod_mod_therm,
             resmod_mod_kin,
             resmod_mod_expl])
     resmod = ModuleLow(self.mktype(
         attrs={resmod_src_attr.id: 0.85},
         effects=[resmod_effect]).id)
     self.fit.modules.low.append(resmod)
     # Verification
     self.assertAlmostEqual(rah.attrs[self.armor_em.id], 1)
     self.assertAlmostEqual(rah.attrs[self.armor_therm.id], 0.925)
     self.assertAlmostEqual(rah.attrs[self.armor_kin.id], 0.82)
     self.assertAlmostEqual(rah.attrs[self.armor_expl.id], 0.655)
     # These values should be set to ship armor if RAH uses premul operator,
     # otherwise resistances will be better as there will be no stacking
     # penalty
     self.assertAlmostEqual(ship.attrs[self.armor_em.id], 0.425, places=3)
     self.assertAlmostEqual(ship.attrs[self.armor_therm.id], 0.516, places=3)
     self.assertAlmostEqual(ship.attrs[self.armor_kin.id], 0.535, places=3)
     self.assertAlmostEqual(ship.attrs[self.armor_expl.id], 0.513, places=3)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemple #6
0
 def test_use_multiple_with_none(self):
     self.fit.modules.low.place(1, ModuleLow(self.mktype().id))
     self.fit.modules.low.place(3, ModuleLow(self.mktype().id))
     # Verification
     self.assertEqual(self.fit.stats.low_slots.used, 4)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemple #7
0
 def setUp(self):
     CustomizationTestCase.setUp(self)
     # Create character
     self.mkattr(attr_id=AttrId.missile_dmg_mult)
     self.fit.character = Character(self.mktype(
         type_id=TypeId.character_static,
         group_id=TypeGroupId.character,
         attrs={AttrId.missile_dmg_mult: 1}).id)
     # Create Ballistic Control System item
     bcs_src_attr = self.mkattr()
     bcs_mod = self.mkmod(
         affectee_filter=ModAffecteeFilter.item,
         affectee_domain=ModDomain.character,
         affectee_attr_id=AttrId.missile_dmg_mult,
         operator=ModOperator.post_percent,
         affector_attr_id=bcs_src_attr.id)
     bcs_effect = self.mkeffect(
         category_id=EffectCategoryId.online,
         modifiers=[bcs_mod])
     online_effect = self.mkeffect(
         effect_id=EffectId.online,
         category_id=EffectCategoryId.active)
     bcs_type = self.mktype(
         attrs={bcs_src_attr.id: 10},
         effects=[bcs_effect, online_effect])
     bcs = ModuleLow(bcs_type.id, state=State.online)
     self.fit.modules.low.append(bcs)
     # Create launcher
     self.launcher = ModuleHigh(self.mktype())
     self.fit.modules.high.append(self.launcher)
Exemple #8
0
 def test_rah_state_switch_up(self):
     # Setup
     ship = Ship(self.make_ship_type((0.5, 0.65, 0.75, 0.9)).id)
     self.fit.ship = ship
     rah = ModuleLow(self.make_rah_type((0.85, 0.85, 0.85, 0.85), 6,
                                        1000).id,
                     state=State.online)
     self.fit.modules.low.equip(rah)
     # Force resonance calculation
     self.assertAlmostEqual(rah.attrs[self.armor_em.id], 0.85)
     self.assertAlmostEqual(rah.attrs[self.armor_therm.id], 0.85)
     self.assertAlmostEqual(rah.attrs[self.armor_kin.id], 0.85)
     self.assertAlmostEqual(rah.attrs[self.armor_expl.id], 0.85)
     self.assertAlmostEqual(ship.attrs[self.armor_em.id], 0.5)
     self.assertAlmostEqual(ship.attrs[self.armor_therm.id], 0.65)
     self.assertAlmostEqual(ship.attrs[self.armor_kin.id], 0.75)
     self.assertAlmostEqual(ship.attrs[self.armor_expl.id], 0.9)
     # Action
     rah.state = State.active
     # Verification
     self.assertAlmostEqual(rah.attrs[self.armor_em.id], 1)
     self.assertAlmostEqual(rah.attrs[self.armor_therm.id], 0.925)
     self.assertAlmostEqual(rah.attrs[self.armor_kin.id], 0.82)
     self.assertAlmostEqual(rah.attrs[self.armor_expl.id], 0.655)
     self.assertAlmostEqual(ship.attrs[self.armor_em.id], 0.5)
     self.assertAlmostEqual(ship.attrs[self.armor_therm.id], 0.60125)
     self.assertAlmostEqual(ship.attrs[self.armor_kin.id], 0.615)
     self.assertAlmostEqual(ship.attrs[self.armor_expl.id], 0.5895)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemple #9
0
 def test_override_priority(self):
     # Setup
     ship = Ship(self.make_ship_type((0.5, 0.65, 0.75, 0.9)).id)
     self.fit.ship = ship
     rah = ModuleLow(
         self.make_rah_type((0.85, 0.85, 0.85, 0.85), 6, 1000).id,
         state=State.online)
     self.fit.modules.low.equip(rah)
     # Calculate modified values
     self.assertAlmostEqual(rah.attrs[self.armor_em.id], 0.85)
     self.assertAlmostEqual(rah.attrs[self.armor_therm.id], 0.85)
     self.assertAlmostEqual(rah.attrs[self.armor_kin.id], 0.85)
     self.assertAlmostEqual(rah.attrs[self.armor_expl.id], 0.85)
     self.assertAlmostEqual(ship.attrs[self.armor_em.id], 0.5)
     self.assertAlmostEqual(ship.attrs[self.armor_therm.id], 0.65)
     self.assertAlmostEqual(ship.attrs[self.armor_kin.id], 0.75)
     self.assertAlmostEqual(ship.attrs[self.armor_expl.id], 0.9)
     # Action
     rah.state = State.active
     # Verification
     # Make sure override values are returned, even when modified values were
     # stored
     self.assertAlmostEqual(rah.attrs[self.armor_em.id], 1)
     self.assertAlmostEqual(rah.attrs[self.armor_therm.id], 0.925)
     self.assertAlmostEqual(rah.attrs[self.armor_kin.id], 0.82)
     self.assertAlmostEqual(rah.attrs[self.armor_expl.id], 0.655)
     self.assertAlmostEqual(ship.attrs[self.armor_em.id], 0.5)
     self.assertAlmostEqual(ship.attrs[self.armor_therm.id], 0.60125)
     self.assertAlmostEqual(ship.attrs[self.armor_kin.id], 0.615)
     self.assertAlmostEqual(ship.attrs[self.armor_expl.id], 0.5895)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemple #10
0
 def test_dmg_profile_rah_to_default(self):
     # Setup
     ship = Ship(self.make_ship_type((0.5, 0.65, 0.75, 0.9)).id)
     self.fit.ship = ship
     rah = ModuleLow(self.make_rah_type((0.85, 0.85, 0.85, 0.85), 6,
                                        1000).id,
                     state=State.active)
     self.fit.modules.low.equip(rah)
     self.fit.rah_incoming_dmg = DmgProfile(1, 0, 0, 0)
     # Force resonance calculation
     self.assertAlmostEqual(rah.attrs[self.armor_em.id], 0.4)
     self.assertAlmostEqual(rah.attrs[self.armor_therm.id], 1)
     self.assertAlmostEqual(rah.attrs[self.armor_kin.id], 1)
     self.assertAlmostEqual(rah.attrs[self.armor_expl.id], 1)
     self.assertAlmostEqual(ship.attrs[self.armor_em.id], 0.2)
     self.assertAlmostEqual(ship.attrs[self.armor_therm.id], 0.65)
     self.assertAlmostEqual(ship.attrs[self.armor_kin.id], 0.75)
     self.assertAlmostEqual(ship.attrs[self.armor_expl.id], 0.9)
     # Action
     self.fit.rah_incoming_dmg = None
     # Verification
     self.assertAlmostEqual(rah.attrs[self.armor_em.id], 1)
     self.assertAlmostEqual(rah.attrs[self.armor_therm.id], 0.925)
     self.assertAlmostEqual(rah.attrs[self.armor_kin.id], 0.82)
     self.assertAlmostEqual(rah.attrs[self.armor_expl.id], 0.655)
     self.assertAlmostEqual(ship.attrs[self.armor_em.id], 0.5)
     self.assertAlmostEqual(ship.attrs[self.armor_therm.id], 0.60125)
     self.assertAlmostEqual(ship.attrs[self.armor_kin.id], 0.615)
     self.assertAlmostEqual(ship.attrs[self.armor_expl.id], 0.5895)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemple #11
0
 def test_order_em_therm_kin(self):
     # Setup
     self.fit.rah_incoming_dmg = DmgProfile(1, 1, 1, 0)
     ship = Ship(self.make_ship_type((0.675, 0.675, 0.675, 0.675)).id)
     self.fit.ship = ship
     rah = ModuleLow(self.make_rah_type((0.85, 0.85, 0.85, 0.85), 6,
                                        1000).id,
                     state=State.active)
     self.fit.modules.low.equip(rah)
     # Verification
     # From real tests, gecko vs gnosis with 2 explosive hardeners
     # 0 0.850 0.850 0.850 0.850
     # 1 0.910 0.790 0.790 0.910 (kin therm > em)
     # 2 0.850 0.730 0.850 0.970 (therm > kin)
     # ---loop---
     # 3 0.805 0.790 0.805 1.000
     # 4 0.775 0.850 0.775 1.000
     # 5 0.835 0.820 0.745 1.000 (kin > em)
     self.assertAlmostEqual(rah.attrs[self.armor_em.id], 0.805)
     self.assertAlmostEqual(rah.attrs[self.armor_therm.id], 0.82)
     self.assertAlmostEqual(rah.attrs[self.armor_kin.id], 0.775)
     self.assertAlmostEqual(rah.attrs[self.armor_expl.id], 1)
     self.assertAlmostEqual(ship.attrs[self.armor_em.id], 0.543, places=3)
     self.assertAlmostEqual(ship.attrs[self.armor_therm.id],
                            0.553,
                            places=3)
     self.assertAlmostEqual(ship.attrs[self.armor_kin.id], 0.523, places=3)
     self.assertAlmostEqual(ship.attrs[self.armor_expl.id], 0.675, places=3)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemple #12
0
 def setUp(self):
     ContainerTestCase.setUp(self)
     self.mod_high1 = ModuleHigh(self.mktype().id)
     self.mod_high2 = ModuleHigh(self.mktype().id)
     self.mod_mid1 = ModuleMid(self.mktype().id)
     self.mod_mid2 = ModuleMid(self.mktype().id)
     self.mod_low1 = ModuleLow(self.mktype().id)
     self.mod_low2 = ModuleLow(self.mktype().id)
     self.mod_low3 = ModuleLow(self.mktype().id)
     self.fit = Fit()
     self.fit.modules.high.place(0, self.mod_high1)
     self.fit.modules.high.place(3, self.mod_high2)
     self.fit.modules.mid.place(1, self.mod_mid1)
     self.fit.modules.mid.place(4, self.mod_mid2)
     self.fit.modules.low.place(0, self.mod_low1)
     self.fit.modules.low.place(4, self.mod_low2)
Exemple #13
0
 def test_unexpected_exception(self):
     # Setup
     ship = Ship(self.make_ship_type((0.5, 0.65, 0.75, 0.9)).id)
     self.fit.ship = ship
     # Set cycle time to zero to force exception
     rah = ModuleLow(self.make_rah_type((0.85, 0.85, 0.85, 0.85), 6, 0).id,
                     state=State.active)
     self.fit.modules.low.equip(rah)
     # Verification
     self.assertAlmostEqual(rah.attrs[self.armor_em.id], 0.85)
     self.assertAlmostEqual(rah.attrs[self.armor_therm.id], 0.85)
     self.assertAlmostEqual(rah.attrs[self.armor_kin.id], 0.85)
     self.assertAlmostEqual(rah.attrs[self.armor_expl.id], 0.85)
     self.assertAlmostEqual(ship.attrs[self.armor_em.id], 0.425)
     self.assertAlmostEqual(ship.attrs[self.armor_therm.id], 0.5525)
     self.assertAlmostEqual(ship.attrs[self.armor_kin.id], 0.6375)
     self.assertAlmostEqual(ship.attrs[self.armor_expl.id], 0.765)
     self.assert_log_entries(1)
     log_record = self.log[0]
     self.assertEqual(log_record.name, 'eos.sim.reactive_armor_hardener')
     self.assertEqual(log_record.levelno, logging.WARNING)
     self.assertEqual(
         log_record.msg,
         'unexpected exception, setting unsimulated resonances')
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
Exemple #14
0
 def test_use_item_not_loaded(self):
     self.fit.modules.low.append(ModuleLow(self.allocate_type_id()))
     # Verification
     self.assertEqual(self.fit.stats.low_slots.used, 1)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemple #15
0
 def test_use_item_class_other(self):
     self.fit.modules.low.place(3, ModuleLow(self.mktype().id))
     # Verification
     self.assertEqual(self.fit.stats.mid_slots.used, 0)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemple #16
0
 def test_stacking_signature(self):
     ship = self.make_ship()
     mwd = self.make_prop_mod(EffectId.module_bonus_microwarpdrive)
     mwd.state = State.active
     self.fit.ship = ship
     self.fit.modules.mid.append(mwd)
     sigmod_src_attr = self.mkattr()
     sigmod_mod = self.mkmod(affectee_filter=ModAffecteeFilter.item,
                             affectee_domain=ModDomain.ship,
                             affectee_attr_id=AttrId.signature_radius,
                             operator=ModOperator.post_percent,
                             affector_attr_id=sigmod_src_attr.id)
     sigmod_effect = self.mkeffect(category_id=EffectCategoryId.passive,
                                   modifiers=[sigmod_mod])
     sigmod = ModuleLow(
         self.mktype(attrs={
             sigmod_src_attr.id: 10
         },
                     effects=[sigmod_effect]).id)
     self.fit.modules.low.append(sigmod)
     # Verification
     # One of modules are stacking penalized, if they were not, value would
     # be higher
     self.assertAlmostEqual(ship.attrs[AttrId.signature_radius],
                            177.384,
                            places=3)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemple #17
0
 def test_velocity_modifier_recalc_propmod_attr_thrust_changed(self):
     thrustmod_src_attr = self.mkattr()
     thrustmod_mod = self.mkmod(affectee_filter=ModAffecteeFilter.domain,
                                affectee_domain=ModDomain.ship,
                                affectee_attr_id=AttrId.speed_boost_factor,
                                operator=ModOperator.mod_add,
                                affector_attr_id=thrustmod_src_attr.id)
     thrustmod_effect = self.mkeffect(category_id=EffectCategoryId.passive,
                                      modifiers=[thrustmod_mod])
     thrustmod = ModuleLow(
         self.mktype(attrs={
             thrustmod_src_attr.id: 500000
         },
                     effects=[thrustmod_effect]).id)
     ship = self.make_ship()
     propmod = self.make_prop_mod(EffectId.module_bonus_microwarpdrive)
     propmod.state = State.active
     self.fit.ship = ship
     self.fit.modules.mid.append(propmod)
     self.assertAlmostEqual(ship.attrs[AttrId.max_velocity],
                            2735.871,
                            places=3)
     # Action
     self.fit.modules.low.append(thrustmod)
     # Verification
     self.assertAlmostEqual(ship.attrs[AttrId.max_velocity],
                            3496.161,
                            places=3)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemple #18
0
 def test_order_multi(self):
     # Setup
     ship = Ship(self.make_ship_type((0.675, 0.675, 0.675, 0.675)).id)
     self.fit.ship = ship
     rah = ModuleLow(self.make_rah_type((0.85, 0.85, 0.85, 0.85), 6,
                                        1000).id,
                     state=State.active)
     self.fit.modules.low.equip(rah)
     # Verification
     # From real tests, gecko vs gnosis
     # ---loop---
     # 0 0.850 0.850 0.850 0.850
     # 1 0.910 0.790 0.790 0.910 (kin therm > em expl)
     self.assertAlmostEqual(rah.attrs[self.armor_em.id], 0.88)
     self.assertAlmostEqual(rah.attrs[self.armor_therm.id], 0.82)
     self.assertAlmostEqual(rah.attrs[self.armor_kin.id], 0.82)
     self.assertAlmostEqual(rah.attrs[self.armor_expl.id], 0.88)
     self.assertAlmostEqual(ship.attrs[self.armor_em.id], 0.594, places=3)
     self.assertAlmostEqual(ship.attrs[self.armor_therm.id],
                            0.554,
                            places=3)
     self.assertAlmostEqual(ship.attrs[self.armor_kin.id], 0.554, places=3)
     self.assertAlmostEqual(ship.attrs[self.armor_expl.id], 0.594, places=3)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemple #19
0
 def test_rah_modified_resonance_update(self):
     # Setup
     skill_attr = self.mkattr(high_is_good=False, stackable=False)
     skill_modifiers = tuple(
         self.mkmod(affectee_filter=ModAffecteeFilter.domain,
                    affectee_domain=ModDomain.ship,
                    affectee_attr_id=attr,
                    operator=ModOperator.post_mul,
                    affector_attr_id=skill_attr.id)
         for attr in (self.armor_em.id, self.armor_therm.id,
                      self.armor_kin.id, self.armor_expl.id))
     skill_effect = self.mkeffect(category_id=EffectCategoryId.passive,
                                  modifiers=skill_modifiers)
     skill_type = self.mktype(attrs={skill_attr.id: 0.5},
                              effects=[skill_effect])
     ship = Ship(self.make_ship_type((0.5, 0.65, 0.75, 0.9)).id)
     self.fit.ship = ship
     rah = ModuleLow(self.make_rah_type((0.85, 0.85, 0.85, 0.85), 6,
                                        1000).id,
                     state=State.online)
     self.fit.modules.low.equip(rah)
     skill = Skill(skill_type.id)
     # Force resonance calculation
     self.assertAlmostEqual(rah.attrs[self.armor_em.id], 0.85)
     self.assertAlmostEqual(rah.attrs[self.armor_therm.id], 0.85)
     self.assertAlmostEqual(rah.attrs[self.armor_kin.id], 0.85)
     self.assertAlmostEqual(rah.attrs[self.armor_expl.id], 0.85)
     self.assertAlmostEqual(ship.attrs[self.armor_em.id], 0.5)
     self.assertAlmostEqual(ship.attrs[self.armor_therm.id], 0.65)
     self.assertAlmostEqual(ship.attrs[self.armor_kin.id], 0.75)
     self.assertAlmostEqual(ship.attrs[self.armor_expl.id], 0.9)
     # Switch state up to enable RAH
     rah.state = State.active
     # Callbacks are installed, sim is doing its job
     self.assertAlmostEqual(rah.attrs[self.armor_em.id], 1)
     self.assertAlmostEqual(rah.attrs[self.armor_therm.id], 0.925)
     self.assertAlmostEqual(rah.attrs[self.armor_kin.id], 0.82)
     self.assertAlmostEqual(rah.attrs[self.armor_expl.id], 0.655)
     self.assertAlmostEqual(ship.attrs[self.armor_em.id], 0.5)
     self.assertAlmostEqual(ship.attrs[self.armor_therm.id], 0.60125)
     self.assertAlmostEqual(ship.attrs[self.armor_kin.id], 0.615)
     self.assertAlmostEqual(ship.attrs[self.armor_expl.id], 0.5895)
     # Action
     self.fit.skills.add(skill)
     rah.state = State.online
     # Verification
     # Despite all changes were masked by override, we should have correct
     # values after overrides are removed
     self.assertAlmostEqual(rah.attrs[self.armor_em.id], 0.425)
     self.assertAlmostEqual(rah.attrs[self.armor_therm.id], 0.425)
     self.assertAlmostEqual(rah.attrs[self.armor_kin.id], 0.425)
     self.assertAlmostEqual(rah.attrs[self.armor_expl.id], 0.425)
     self.assertAlmostEqual(ship.attrs[self.armor_em.id], 0.5)
     self.assertAlmostEqual(ship.attrs[self.armor_therm.id], 0.65)
     self.assertAlmostEqual(ship.attrs[self.armor_kin.id], 0.75)
     self.assertAlmostEqual(ship.attrs[self.armor_expl.id], 0.9)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemple #20
0
 def test_pass_greater(self):
     self.fit.ship = Ship(self.mktype(attrs={AttrId.low_slots: 5}).id)
     item_type = self.mktype()
     item1 = ModuleLow(item_type.id)
     item2 = ModuleLow(item_type.id)
     self.fit.modules.low.append(item1)
     self.fit.modules.low.append(item2)
     # Action
     error1 = self.get_error(item1, Restriction.low_slot)
     # Verification
     self.assertIsNone(error1)
     # Action
     error2 = self.get_error(item2, Restriction.low_slot)
     # Verification
     self.assertIsNone(error2)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemple #21
0
 def test_cycle_time(self):
     # Setup
     ship = Ship(self.make_ship_type((0.5, 0.65, 0.75, 0.9)).id)
     self.fit.ship = ship
     rah_type = self.make_rah_type((0.85, 0.85, 0.85, 0.85), 6, 1000)
     rah1 = ModuleLow(rah_type.id, state=State.active)
     rah2 = ModuleLow(rah_type.id, state=State.active)
     self.fit.modules.low.equip(rah1)
     self.fit.modules.low.equip(rah2)
     # Force resonance calculation
     self.assertAlmostEqual(rah1.attrs[self.armor_em.id], 0.97)
     self.assertAlmostEqual(rah1.attrs[self.armor_therm.id], 0.88)
     self.assertAlmostEqual(rah1.attrs[self.armor_kin.id], 0.805)
     self.assertAlmostEqual(rah1.attrs[self.armor_expl.id], 0.745)
     self.assertAlmostEqual(rah2.attrs[self.armor_em.id], 0.97)
     self.assertAlmostEqual(rah2.attrs[self.armor_therm.id], 0.88)
     self.assertAlmostEqual(rah2.attrs[self.armor_kin.id], 0.805)
     self.assertAlmostEqual(rah2.attrs[self.armor_expl.id], 0.745)
     self.assertAlmostEqual(ship.attrs[self.armor_em.id], 0.472, places=3)
     self.assertAlmostEqual(ship.attrs[self.armor_therm.id],
                            0.512,
                            places=3)
     self.assertAlmostEqual(ship.attrs[self.armor_kin.id], 0.501, places=3)
     self.assertAlmostEqual(ship.attrs[self.armor_expl.id], 0.522, places=3)
     # Action
     rah2.state = State.overload
     # Verification
     self.assertAlmostEqual(rah1.attrs[self.armor_em.id], 0.975, places=3)
     self.assertAlmostEqual(rah1.attrs[self.armor_therm.id],
                            0.835,
                            places=3)
     self.assertAlmostEqual(rah1.attrs[self.armor_kin.id], 0.83, places=3)
     self.assertAlmostEqual(rah1.attrs[self.armor_expl.id], 0.76, places=3)
     self.assertAlmostEqual(rah2.attrs[self.armor_em.id], 0.979, places=3)
     self.assertAlmostEqual(rah2.attrs[self.armor_therm.id], 0.91, places=3)
     self.assertAlmostEqual(rah2.attrs[self.armor_kin.id], 0.796, places=3)
     self.assertAlmostEqual(rah2.attrs[self.armor_expl.id], 0.715, places=3)
     self.assertAlmostEqual(ship.attrs[self.armor_em.id], 0.479, places=3)
     self.assertAlmostEqual(ship.attrs[self.armor_therm.id], 0.5, places=3)
     self.assertAlmostEqual(ship.attrs[self.armor_kin.id], 0.509, places=3)
     self.assertAlmostEqual(ship.attrs[self.armor_expl.id], 0.509, places=3)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemple #22
0
 def test_module_low_fail_not_loaded(self):
     item = ModuleLow(self.allocate_type_id())
     self.fit.modules.low.append(item)
     # 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)
Exemple #23
0
 def test_module_low(self):
     module = ModuleLow(self.make_item_types())
     self.fit.modules.low.append(module)
     self.assertAlmostEqual(module.attrs[self.tgt_attr_id], 18)
     # Action
     self.fit.solar_system.source = 'src2'
     # Verification
     self.assertAlmostEqual(module.attrs[self.tgt_attr_id], 14)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemple #24
0
 def test_fail_multiple(self):
     # Check that error works for multiple items, and raised only for those
     # which lie out of bounds
     self.fit.ship = Ship(self.mktype(attrs={AttrId.low_slots: 1}).id)
     item_type = self.mktype()
     item1 = ModuleLow(item_type.id)
     item2 = ModuleLow(item_type.id)
     self.fit.modules.low.append(item1)
     self.fit.modules.low.append(item2)
     # Action
     error1 = self.get_error(item1, Restriction.low_slot)
     # Verification
     self.assertIsNone(error1)
     # Action
     error2 = self.get_error(item2, Restriction.low_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)
Exemple #25
0
 def test_fail_ship_not_loaded(self):
     self.fit.ship = Ship(self.allocate_type_id())
     item = ModuleLow(self.mktype().id)
     self.fit.modules.low.append(item)
     # Action
     error = self.get_error(item, Restriction.low_slot)
     # Verification
     self.assertIsNotNone(error)
     self.assertEqual(error.used, 1)
     self.assertEqual(error.total, 0)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemple #26
0
 def test_module_low_pass(self):
     effect = self.mkeffect(effect_id=EffectId.lo_power,
                            category_id=EffectCategoryId.passive)
     item = ModuleLow(
         self.mktype(category_id=TypeCategoryId.module,
                     effects=[effect]).id)
     self.fit.modules.low.append(item)
     # 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)
Exemple #27
0
 def test_ship_absent(self):
     # Setup
     rah = ModuleLow(self.make_rah_type((0.85, 0.85, 0.85, 0.85), 6,
                                        1000).id,
                     state=State.active)
     self.fit.modules.low.equip(rah)
     # Verification
     self.assertAlmostEqual(rah.attrs[self.armor_em.id], 0.85)
     self.assertAlmostEqual(rah.attrs[self.armor_therm.id], 0.85)
     self.assertAlmostEqual(rah.attrs[self.armor_kin.id], 0.85)
     self.assertAlmostEqual(rah.attrs[self.armor_expl.id], 0.85)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemple #28
0
 def test_fail_ship_absent(self):
     # When stats module does not specify total slot quantity, make sure it's
     # assumed to be 0
     item = ModuleLow(self.mktype().id)
     self.fit.modules.low.append(item)
     # Action
     error = self.get_error(item, Restriction.low_slot)
     # Verification
     self.assertIsNotNone(error)
     self.assertEqual(error.used, 1)
     self.assertEqual(error.total, 0)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemple #29
0
 def test_fail_item_not_loaded(self):
     # Item still counts even when it's not loaded
     self.fit.ship = Ship(self.mktype(attrs={AttrId.low_slots: 0}).id)
     item = ModuleLow(self.allocate_type_id())
     self.fit.modules.low.append(item)
     # Action
     error = self.get_error(item, Restriction.low_slot)
     # Verification
     self.assertIsNotNone(error)
     self.assertEqual(error.used, 1)
     self.assertEqual(error.total, 0)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemple #30
0
 def test_module_low_fail_category_other(self):
     effect = self.mkeffect(effect_id=EffectId.lo_power,
                            category_id=EffectCategoryId.passive)
     item = ModuleLow(self.mktype(category_id=1008, effects=[effect]).id)
     self.fit.modules.low.append(item)
     # Action
     error = self.get_error(item, Restriction.item_class)
     # Verification
     self.assertIsNotNone(error)
     self.assertEqual(error.item_class, ModuleLow)
     self.assertCountEqual(error.allowed_classes, [])
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)