#include #include "sqrt.hpp" #include "gen/pokemon/moves.hpp" #include "pokemon.hpp" struct determinant_values_t { uint16_t dvs; inline constexpr uint8_t attack() { return (dvs >> 12) & 0b1111; } inline constexpr uint8_t defense() { return (dvs >> 8) & 0b1111; } inline constexpr uint8_t speed() { return (dvs >> 4) & 0b1111; } inline constexpr uint8_t special() { return (dvs >> 0) & 0b1111; } inline constexpr uint8_t hit_points() { return ((attack() & 1) << 3) | ((defense() & 1) << 2) | ((speed() & 1) << 1) | ((special() & 1) << 0); } }; struct stat_experience_t { uint16_t hit_points; uint16_t attack; uint16_t defense; uint16_t speed; uint16_t special; }; // unlike base_stat_values, stat_values is uint16_t struct stat_values_t { union { struct { uint16_t hit_points; uint16_t attack; uint16_t defense; uint16_t speed; uint16_t special; }; uint16_t value[5]; }; }; static_assert((sizeof (stat_values_t)) == 10); struct pokemon_instance_t { enum pokemon_t::pokemon species; uint8_t * nickname[12]; uint8_t level; uint32_t experience; // total experience determinant_values_t determinant_values; stat_values_t stat_values; stat_experience_t stat_experience; enum move_t::move moves[4]; uint16_t current_hit_points; // missing attributes: // - status modifiers (burn, poison, etc...) // "fluff" attributes: // - id number // - original trainer constexpr inline uint16_t determine_stat(enum stat_t stat); constexpr inline void learn_move(enum move_t::move move, uint32_t index); };