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)
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)
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)
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)
def test_inactive_switched(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) # Action rah.state = State.online # 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.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)
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)