pokemon_app.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #ifndef POKEMON_APP_H
  2. #define POKEMON_APP_H
  3. #pragma once
  4. #include <gui/scene_manager.h>
  5. #include <gui/view.h>
  6. #include <gui/view_dispatcher.h>
  7. #include <gui/icon.h>
  8. #include <gui/modules/submenu.h>
  9. #include <gui/modules/text_input.h>
  10. #include <gui/modules/variable_item_list.h>
  11. #include "pokemon_data.h"
  12. #define TAG "Pokemon"
  13. /* #defines for the data table entries */
  14. #define GROWTH_FAST 4
  15. #define GROWTH_MEDIUM_FAST 0
  16. #define GROWTH_MEDIUM_SLOW 3
  17. #define GROWTH_SLOW 5
  18. struct pokemon_data_table {
  19. const char* name;
  20. const Icon* icon;
  21. const uint8_t index;
  22. const uint8_t base_hp;
  23. const uint8_t base_atk;
  24. const uint8_t base_def;
  25. const uint8_t base_spd;
  26. const uint8_t base_special;
  27. const uint8_t type[2];
  28. const uint8_t move[4];
  29. const uint8_t growth;
  30. };
  31. typedef struct pokemon_data_table PokemonTable;
  32. struct named_list {
  33. const char* name;
  34. const uint8_t index;
  35. };
  36. typedef struct named_list NamedList;
  37. struct pokemon_fap {
  38. ViewDispatcher* view_dispatcher;
  39. /* View ports for each of the application's steps */
  40. View* select_view;
  41. void* trade;
  42. /* Scene manager */
  43. SceneManager* scene_manager;
  44. /* gui modules used in the application lifetime */
  45. Submenu* submenu;
  46. TextInput* text_input;
  47. VariableItemList* variable_item_list;
  48. /* Table of pokemon data for Gen I */
  49. const PokemonTable* pokemon_table;
  50. /* List of moves, alphabetically ordered */
  51. const NamedList* move_list;
  52. /* List of types, alphabetically ordered */
  53. const NamedList* type_list;
  54. /* Struct for holding trade data */
  55. /* NOTE: There may be some runtime memory savings by adding more intelligence
  56. * to views/trade and slimming down this struct to only contain the single
  57. * pokemon data rather than the full 6 member party data.
  58. */
  59. TradeBlock* trade_block;
  60. /* The currently selected pokemon */
  61. int curr_pokemon;
  62. /* TODO: Other variables will end up here, like selected level, EV/IV,
  63. * moveset, etc. Likely will want to be another sub struct similar to
  64. * the actual pokemon data structure.
  65. */
  66. int curr_stats;
  67. };
  68. typedef struct pokemon_fap PokemonFap;
  69. typedef enum {
  70. AppViewMainMenu,
  71. AppViewOpts, // Generic view ID meant for module re-use
  72. AppViewSelectPokemon,
  73. AppViewTrade,
  74. AppViewExitConfirm,
  75. } AppView;
  76. int pokemon_table_get_num_from_index(const PokemonTable* table, uint8_t index);
  77. int pokemon_named_list_get_num_elements(const NamedList* list);
  78. int pokemon_named_list_get_list_pos_from_index(const NamedList* list, uint8_t index);
  79. const char* pokemon_named_list_get_name_from_index(const NamedList* list, uint8_t index);
  80. void pokemon_trade_block_set_default_name(char* dest, PokemonFap* pokemon_fap, size_t n);
  81. void pokemon_trade_block_recalculate(PokemonFap* pokemon_fap);
  82. void pokemon_trade_block_recalculate_stats_from_level(PokemonFap* pokemon_fap);
  83. #endif /* POKEMON_APP_H */