pokemon/tools/parse/move/moves.py

34 lines
764 B
Python

from dataclasses import dataclass
from functools import partial
from parse import number
from parse.generic import macro_line
tokenize_lines = partial(macro_line.tokenize_lines, prefix='move ')
@dataclass
class Move:
name: str
effect: str
power: int
type: str
accuracy: int
pp: int
def flatten(tokens):
for t in tokens:
assert t[0] == 'move', t
_, (name, effect, power, type, accuracy, pp) = t
return Move(
name,
effect,
number(power),
type,
number(accuracy),
number(pp)
)
def parse(prefix):
path = prefix / 'data/moves/moves.asm'
with open(path) as f:
return dict(flatten(tokenize_lines(f.read().split('\n'))))