-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom_attacks.py
41 lines (36 loc) · 1.89 KB
/
custom_attacks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from typing import Callable
from effects import Effects
from pokemon import Attack_Scheme, Pokemon, Pokemon_basics
from random import randint
class Custom_Attack:
class Half_Life_Damage_Attack(Attack_Scheme):
def __init__(self, name: str, typeatk: Pokemon_basics.types_type_def, uses: tuple[int, int], priority: int, shock_itself: tuple[bool, tuple[int, int] | None]) -> None:
super().__init__(name, typeatk, (1, 1), uses, priority, shock_itself)
def attack(self, pokemon_attacked: Pokemon, pokemon_that_attack: Pokemon, uses: Callable[[], None]):
assert isinstance(pokemon_attacked, Pokemon)
assert isinstance(pokemon_that_attack, Pokemon)
uses()
new_life = pokemon_attacked.get_life() // 2
pokemon_attacked.set_life(new_life)
if self.get_shock_itself()[0]:
shock_itself_damage: tuple[int, int] = self.get_shock_itself()[1] # type: ignore
new_life = pokemon_that_attack.get_life() - randint(shock_itself_damage[0], shock_itself_damage[1])
pokemon_that_attack.set_life(new_life)
return
class Attack_With_Effect(Attack_Scheme):
def __init__(
self,
name: str,
typeatk: Pokemon_basics.types_type_def,
damage: tuple[int, int],
uses: tuple[int, int],
priority: int,
shock_itself: tuple[bool, tuple[int, int] | None],
effect: Effects.Base,
) -> None:
super().__init__(name, typeatk, damage, uses, priority, shock_itself)
# assert(isinstance(effect,Effects.Base))
self.__effect = effect
def attack(self, pokemon_attacked: Pokemon, pokemon_that_attack: Pokemon, uses: Callable[[], None]):
super().attack(pokemon_attacked, pokemon_that_attack, uses)
pokemon_attacked.set_effect(self.__effect)