Zack Buhman 853457a79d generate: add pokemon
This also includes a handful of functions for creating instances of a
pokemon species, though certainly not complete.
2023-08-02 23:49:42 +00:00

33 lines
765 B
Python

# similar to spritesheet/gfx.py
from parse.generic import tokenize
from parse.generic.flatten import flatten
def tokenize_lines(lines):
for line in lines:
if '::' in line:
yield tokenize.block(line, delim='::')
def parse(path):
with open(path) as f:
tokens = tokenize_lines(f.read().split('\n'))
l = flatten(tokens,
endings=['Front', 'Back', 'Pic'],
base_path='gfx/')
return l
def _parse_all(prefix):
pics = [
"gfx/pics.asm",
"data/pokemon/mew.asm"
]
for pic in pics:
path = prefix / pic
yield from parse(path)
def parse_all(prefix):
l = list(_parse_all(prefix))
d = dict(l)
assert len(l) == len(d)
return d