-
Notifications
You must be signed in to change notification settings - Fork 1
/
turns.py
90 lines (59 loc) · 1.69 KB
/
turns.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
from typing import Any, Optional, Union
import json
import logging
log = logging.getLogger(__name__)
__exclude_exports__ = set(dir())
class Turn():
"""Represents an :class:`Agent`'s turn."""
TurnType: Optional[int] = None
def __init__(self) -> None:
pass
def toJSON(self) -> str:
"""Serialize the turn to submit to the battle API."""
return json.dumps({
"type": self.TurnType,
"args": self.get_args(),
})
def get_args(self) -> dict[str, Any]:
"""Get the turn's parameters."""
return {}
def __repr__(self) -> str:
return f"{type(self)}<{self.get_args()}>"
class FightTurn(Turn):
"""Use a Pokemon's move."""
TurnType = 0
def __init__(self, **kwargs) -> None:
self.target = {
"Party": kwargs.pop("party"),
"Slot": kwargs.pop("slot"),
}
self.move = kwargs.pop("move")
def get_args(self) -> dict[str, Any]:
"""Get the turn's parameters."""
return {"Target": self.target, "move": self.move}
class ItemTurn(Turn):
"""Use an item."""
TurnType = 1
def __init__(self, **kwargs) -> None:
pass
def get_args(self) -> dict[str, Any]:
"""Get the turn's parameters."""
return {}
class SwitchTurn(Turn):
"""Switch a Pokemon out for another Pokemon."""
TurnType = 2
def __init__(self, **kwargs) -> None:
pass
def get_args(self) -> dict[str, Any]:
"""Get the turn's parameters."""
return {}
class RunTurn(Turn):
"""Attempt to run away from the battle."""
TurnType = 3
def __init__(self, **kwargs) -> None:
pass
def get_args(self) -> dict[str, Any]:
"""Get the turn's parameters."""
return {}
__all__ = [x for x in dir() if not x.startswith("_") or x not in __exclude_exports__]
__all__ = ["Turn", "FightTurn", "ItemTurn", "SwitchTurn", "RunTurn"]