def test_berserk(self): old_damage = self.context.modify_outcoming_damage(Damage(100, 10)) self.context.use_berserk(1.0) self.assertEqual(old_damage, self.context.modify_outcoming_damage(Damage(100, 10))) self.context.use_berserk(1.5) new_damage = self.context.modify_outcoming_damage(Damage(100, 10)) self.assertTrue(old_damage.physic < new_damage.physic) self.assertTrue(old_damage.magic < new_damage.magic)
def test_damage(self): damage = Damage(100, 50) damage.multiply(0.5, 2) self.assertEqual(damage, Damage(50, 100)) damage = Damage(100.5, 50.5) damage.randomize() self.assertEqual(damage.total, 151)
def test_modify_outcoming_damage(self): self.assertEqual(self.context.modify_outcoming_damage(Damage(10, 11)).total, 21) self.assertEqual(self.context.modify_outcoming_damage(Damage(10.4, 11.4)).total, 22) self.assertEqual(self.context.modify_outcoming_damage(Damage(10.5, 11.5)).total, 22) self.assertEqual(self.context.modify_outcoming_damage(Damage(10.8, 11.8)).total, 23) # advantage_modifier self.context.use_pvp_advantage(0.75) self.assertEqual(self.context.modify_outcoming_damage(Damage(20, 10)), Damage(20*(1+c.DAMAGE_PVP_ADVANTAGE_MODIFIER*0.75), 10*(1+c.DAMAGE_PVP_ADVANTAGE_MODIFIER*0.75))) self.assertFalse(self.context.pvp_advantage_used) self.context.use_pvp_advantage(-0.75) self.assertEqual(self.context.modify_outcoming_damage(Damage(20, 10)), Damage(20, 10)) self.assertFalse(self.context.pvp_advantage_used) self.assertEqual(self.context.serialize(), BattleContext.deserialize(self.context.serialize()).serialize())
def check_empty_values(self): self.assertEqual(self.context.ability_magic_mushroom, []) self.assertEqual(self.context.ability_sidestep, []) self.assertEqual(self.context.stun_length, 0) self.assertEqual(self.context.crit_chance, 0) self.assertEqual(self.context.berserk_damage_modifier, 1.0) self.assertEqual(self.context.ninja, 0) self.assertEqual(self.context.damage_queue_fire, []) self.assertEqual(self.context.damage_queue_poison, []) self.assertEqual(self.context.initiative_queue, []) self.assertEqual(self.context.incoming_magic_damage_modifier, 1.0) self.assertEqual(self.context.incoming_physic_damage_modifier, 1.0) self.assertEqual(self.context.outcoming_magic_damage_modifier, 1.0) self.assertEqual(self.context.outcoming_physic_damage_modifier, 1.0) self.assertEqual(self.context.pvp_advantage, 0) self.assertFalse(self.context.pvp_advantage_used) self.assertEqual(self.context.pvp_advantage_strike_damage, Damage(0, 0))
def test_ability_magic_mushroom(self): self.context.use_ability_magic_mushroom([2.0, 1.0, 0.5]) self.assertEqual(self.context.ability_magic_mushroom, [None, 2.0, 1.0, 0.5]) self.context.on_own_turn() self.assertEqual(self.context.ability_magic_mushroom, [2.0, 1.0, 0.5]) self.assertEqual(self.context.modify_outcoming_damage(Damage(10, 5)), Damage(20, 10)) self.context.on_own_turn() self.assertEqual(self.context.ability_magic_mushroom, [1.0, 0.5]) self.assertEqual(self.context.modify_outcoming_damage(Damage(10, 5)), Damage(10, 5)) self.context.on_own_turn() self.assertEqual(self.context.ability_magic_mushroom, [0.5]) self.assertEqual(self.context.modify_outcoming_damage(Damage(10, 5)).total, 8) self.context.on_own_turn() self.assertEqual(self.context.ability_magic_mushroom, []) self.assertEqual(self.context.modify_outcoming_damage(Damage(10, 5)), Damage(10, 5))
def test_damage_queue_poison(self): self.assertEqual(self.context.poison_damage, None) self.context.use_damage_queue_poison([Damage(0, 0)]) self.assertEqual(self.context.poison_damage, None) self.context.use_damage_queue_poison([Damage(5, 5), Damage(5, 5), Damage(5, 5)]) self.assertEqual(self.context.damage_queue_poison, [Damage(0, 0), Damage(5, 5), Damage(5, 5), Damage(5, 5)]) self.context.on_own_turn() self.assertEqual(self.context.damage_queue_poison, [Damage(5, 5), Damage(5, 5), Damage(5, 5)]) self.assertEqual(self.context.poison_damage, Damage(5, 5)) self.context.use_damage_queue_poison([Damage(10, 10), Damage(5, 5), Damage(5, 5)]) self.context.on_own_turn() self.assertEqual(self.context.damage_queue_poison, [Damage(15, 15), Damage(10, 10), Damage(5, 5)]) self.assertEqual(self.context.poison_damage, Damage(15, 15)) self.context.on_own_turn() self.assertEqual(self.context.damage_queue_poison, [Damage(10, 10), Damage(5, 5)]) self.assertEqual(self.context.poison_damage, Damage(10, 10)) self.context.use_damage_queue_poison([Damage(1, 1), Damage(1, 1), Damage(1, 1), Damage(1, 1)]) self.assertEqual(self.context.damage_queue_poison, [Damage(10, 10), Damage(6, 6), Damage(1, 1), Damage(1, 1), Damage(1, 1)]) self.context.on_own_turn() self.assertEqual(self.context.damage_queue_poison, [Damage(6, 6), Damage(1, 1), Damage(1, 1), Damage(1, 1)]) self.assertEqual(self.context.poison_damage, Damage(6, 6)) self.assertEqual(self.context.serialize(), BattleContext.deserialize(self.context.serialize()).serialize())
def test_incoming_damage_modifier(self): self.assertEqual(self.context.modify_incoming_damage(Damage(100, 1000)), Damage(100, 1000)) self.context.use_incoming_damage_modifier(5, 0.25) self.assertEqual(self.context.modify_incoming_damage(Damage(100, 1000)), Damage(500, 250)) self.context.use_incoming_damage_modifier(2, 10) self.assertEqual(self.context.modify_incoming_damage(Damage(100, 1000)), Damage(1000, 2500))
def test_critical_hit(self): old_damage = self.context.modify_outcoming_damage(Damage(100, 1000)) self.context.use_crit_chance(100) new_damage = self.context.modify_outcoming_damage(Damage(100, 1000)) self.assertTrue(old_damage.physic < new_damage.physic) self.assertTrue(old_damage.magic < new_damage.magic)
def test_modify_outcoming_damage_advantage_strike(self): self.context.use_pvp_advantage(1.0) self.assertEqual(self.context.modify_outcoming_damage(Damage(20, 10)), Damage(0, 0)) # pvp_advantage_strike_damage not set self.context.use_pvp_advantage_stike_damage(Damage(333, 666)) self.assertEqual(self.context.modify_outcoming_damage(Damage(20, 10)), Damage(333, 666)) self.assertTrue(self.context.pvp_advantage_used)