""" struct move_t { uint8_t effect; // fixme: constants/move_effect_constants.asm uint8_t power; uint8_t type; // fixme: constants/type_constants.asm uint8_t accuracy; uint8_t pp; enum move { wing_attack, }; }; const move_t moves[] = { [move_t::pound] = { .effect = .power = .type = .accuracy = .pp = }, }; """ from generate.generate import renderer from parse import parse # parse.move_constants_list() # parse.move_names_list() # parse.move_moves_list() def includes_header(): yield "#pragma once" yield "" def move_constants(): _move_constants = parse.move_constants_list() _moves = list(parse.move_moves_list()) for constant_ix, constant_name in enumerate(_move_constants): # move_constants is also used for animation names it will be # modeled in a separate enum (e.g: there is no such move as # "shrinking_square_black_anim", so it shouldn't appear in # this enum). This appears to be a questionable decision in # the pokered decompilation project, not an original design # decision in the game. if constant_ix < len(_moves): yield constant_name def struct_move_t(): _move_constants = move_constants() _move_constants_str = (f"{s.lower()}," for s in _move_constants) return [ "struct move_t {", "uint8_t animation;", "uint8_t effect;", "uint8_t power;", "uint8_t type;", "uint8_t accuracy;", "uint8_t pp;", "", "enum move {", *_move_constants_str, "};", "};", ] def extern_moves(): yield "extern const move_t moves[];" def generate_header(): render, out = renderer() render(includes_header()) render(struct_move_t()) render(extern_moves()) return out def move(constant_index, constant_name): _move = parse.move_moves_list()[constant_index] return [ f"[move_t::{constant_name.lower()}] = {{", ".animation = 0,", ".effect = 0,", f".power = {_move.power},", ".type = 0,", f".accuracy = {_move.accuracy},", f".pp = {_move.pp},", "}," ] def moves(): yield "const move_t moves[] = {" for constant_index, constant_name in enumerate(move_constants()): if constant_index == 0: # no_move yield f"[move_t::{constant_name.lower()}] = {{ 0 }}," else: yield from move(constant_index - 1, constant_name) yield "};" def includes_source(): yield '#include ' yield '' yield '#include "moves.hpp"' yield '' def generate_source(): render, out = renderer() render(includes_source()) render(moves()) return out