コード例 #1
0
 def __get_effectiveness_multiplier(self) -> float:
     """
     Check if we have a damage reduction or bonus from ability.element vs target.element.
     Eg. the lightning target is weak to earth, so an earth ability does 1.5x damage and is marked as effective.
     Eg. the wind target is strong to fire, so a fire ability does 0.5x damage and is marked as resisted.
     """
     effectiveness = Effectiveness(self.damage_source.element, self.target.element)
     return effectiveness.calculate_multiplier()
コード例 #2
0
 def test_chaos_effective(self):
     error = "Chaos is supposed to be effective against other elements"
     expected = True
     for attr in vars(Elements):
         chaos_vs_other = Effectiveness(Elements.CHAOS,
                                        getattr(Elements, attr))
         multiplier = chaos_vs_other.calculate_multiplier()
         expected = multiplier > 1
         if not expected:
             break
     self.assertTrue(expected, error)
コード例 #3
0
 def test_others_vs_chaos_effective(self):
     error = "Other elements are supposed to be effective against chaos"
     expected = True
     for attr in vars(Elements):
         other_vs_chaos = Effectiveness(getattr(Elements, attr),
                                        Elements.CHAOS)
         multiplier = other_vs_chaos.calculate_multiplier()
         expected = multiplier > 1
         if not expected:
             break
     self.assertTrue(expected, error)
コード例 #4
0
ファイル: combat_ai.py プロジェクト: Hammerlord/Monbot
    def switch(self) -> None:
        if not self.team.eligible_bench:
            return

        effective_elementals = Effectiveness.find_effective(self.team.eligible_bench,
                                                            self.combat.get_active_enemy(self.team).element)
        if effective_elementals:
            self.team.attempt_switch(effective_elementals[0])
            return

        neutral_elementals = Effectiveness.find_neutral(self.team.eligible_bench,
                                                        self.combat.get_active_enemy(self.team).element)
        if neutral_elementals:
            self.team.attempt_switch(neutral_elementals[0])
            return

        self.team.attempt_switch(self.roll(self.team.eligible_bench))
コード例 #5
0
 def test_find_neutral(self):
     error = "Should have found a neutral elemental given a list"
     elementals = [
         ElementalBuilder().with_element(Elements.LIGHT).build(),
         ElementalBuilder().with_element(Elements.EARTH).build(),
         ElementalBuilder().with_element(Elements.WIND).build()
     ]
     result = Effectiveness.find_effective(elementals, Elements.FIRE)
     self.assertEqual(len(result), 1, error)
コード例 #6
0
 def test_light_vs_dark(self):
     error = "Light and dark are supposed to be effective against each other"
     light_vs_dark = Effectiveness(Elements.DARK, Elements.LIGHT)
     light_vs_dark_multiplier = light_vs_dark.calculate_multiplier()
     dark_vs_light = Effectiveness(Elements.LIGHT, Elements.DARK)
     dark_vs_light_multiplier = dark_vs_light.calculate_multiplier()
     self.assertGreater(light_vs_dark_multiplier, 1, error)
     self.assertGreater(dark_vs_light_multiplier, 1, error)
コード例 #7
0
 def test_fire_vs_earth(self):
     error = "Fire is supposed to be effective against earth"
     fire_vs_earth = Effectiveness(Elements.FIRE, Elements.EARTH)
     multipler = fire_vs_earth.calculate_multiplier()
     self.assertGreater(multipler, 1, error)
コード例 #8
0
 def test_fire_vs_wind(self):
     error = "Wind is supposed to resist fire"
     fire_vs_wind = Effectiveness(Elements.FIRE, Elements.WIND)
     multiplier = fire_vs_wind.calculate_multiplier()
     self.assertLess(multiplier, 1, error)
コード例 #9
0
 def test_wind_vs_fire(self):
     error = "Wind is supposed to be effective against fire"
     wind_vs_fire = Effectiveness(Elements.WIND, Elements.FIRE)
     multiplier = wind_vs_fire.calculate_multiplier()
     self.assertGreater(multiplier, 1, error)
コード例 #10
0
 def test_water_vs_lightning(self):
     error = "Lightning is supposed to resist water"
     water_vs_lightning = Effectiveness(Elements.WATER, Elements.LIGHTNING)
     multiplier = water_vs_lightning.calculate_multiplier()
     self.assertLess(multiplier, 1, error)
コード例 #11
0
 def test_lightning_vs_water(self):
     error = "Lightning is supposed to be effective against water"
     lightning_vs_water = Effectiveness(Elements.LIGHTNING, Elements.WATER)
     multiplier = lightning_vs_water.calculate_multiplier()
     self.assertGreater(multiplier, 1, error)
コード例 #12
0
 def test_earth_vs_fire(self):
     error = "Fire is supposed to resist earth"
     earth_vs_fire = Effectiveness(Elements.EARTH, Elements.FIRE)
     multiplier = earth_vs_fire.calculate_multiplier()
     self.assertLess(multiplier, 1, error)