Procházet zdrojové kódy

Set pokemon name to act like no nickname

Darryn Cull před 2 roky
rodič
revize
a712da67db
3 změnil soubory, kde provedl 27 přidání a 28 odebrání
  1. 4 3
      README.md
  2. 13 14
      pokemon_data.h
  3. 10 11
      views/trade.cpp

+ 4 - 3
README.md

@@ -264,13 +264,14 @@ For each image, the color `#aaa` was transformed to `#fff` so that Flipper Zero
 <a href="https://github.com/R4g3D/Flipper-Zero-Game-Boy-Pokemon-Trading/">R4g3D</a>
 <a href="https://github.com/R4g3D/Flipper-Zero-Game-Boy-Pokemon-Trading/">R4g3D</a>
 
 
 ## TODO
 ## TODO
-- [ ] Change the default traded Pokemon's naming to be no nickname (current nickname is the Pokemon's name)
+- [x] Change the default traded Pokemon's naming to be no nickname
 - [x] Add view to allow the traded Pokemon's level to be chosen between 3 and 100
 - [x] Add view to allow the traded Pokemon's level to be chosen between 3 and 100
 - [x] Add view to allow the traded Pokemon's hidden stats to be chosen (IV and EV) from some options
 - [x] Add view to allow the traded Pokemon's hidden stats to be chosen (IV and EV) from some options
 - [x] Add view to allow the traded Pokemon's moveset to be chosen (all 4 moves) allowing no move as an option
 - [x] Add view to allow the traded Pokemon's moveset to be chosen (all 4 moves) allowing no move as an option
+- [ ] Debug traded Pokemon level issue where after a battle the Pokemon's level drops (doesn't affect all traded Pokemon)
 - [ ] Add images for the level selection screen, stats selection screen, and move selection screens as per the original README
 - [ ] Add images for the level selection screen, stats selection screen, and move selection screens as per the original README
-- [ ] Optimise the level selection screen to be a number slider input instead of the current slideshow still selector
-- [ ] Add a view to allow for a custom Pokemon nickname
+- [ ] Optimise the level selection screen to be a number slider input instead of the current slideshow style selector
+- [ ] Add a view to allow for a custom Pokemon nickname (11 chars, 10 chars max used, fill and terminate with TERM_)
 
 
 ## Links
 ## Links
 
 

+ 13 - 14
pokemon_data.h

@@ -143,7 +143,7 @@ struct __attribute__((__packed__)) trade_data_block {
 };
 };
 
 
 struct trade_data_block DATA_BLOCK2 =
 struct trade_data_block DATA_BLOCK2 =
-    {.trainer_name = {F_, l_, i_, p_, p_, e_, r_, TERM_, 0x00, 0x00, 0x00},
+    {.trainer_name = {F_, l_, i_, p_, p_, e_, r_, TERM_, TERM_, TERM_, TERM_},
      .party_cnt = 1,
      .party_cnt = 1,
      .party_members = {0x15, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
      .party_members = {0x15, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
      .party =
      .party =
@@ -281,23 +281,22 @@ struct trade_data_block DATA_BLOCK2 =
               .spd = 0x9800,
               .spd = 0x9800,
               .special = 0x9900},
               .special = 0x9900},
          },
          },
-     /* NOTE: I think this shouldn't exceed 7 chars */
      .ot_name =
      .ot_name =
          {
          {
-             {.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, 0x00, 0x00}},
-             {.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, 0x00, 0x00}},
-             {.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, 0x00, 0x00}},
-             {.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, 0x00, 0x00}},
-             {.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, 0x00, 0x00}},
-             {.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, 0x00, 0x00}},
+             {.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, TERM_, TERM_, TERM_}},
+             {.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, TERM_, TERM_, TERM_}},
+             {.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, TERM_, TERM_, TERM_}},
+             {.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, TERM_, TERM_, TERM_}},
+             {.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, TERM_, TERM_, TERM_}},
+             {.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, TERM_, TERM_, TERM_}},
          },
          },
      .nickname = {
      .nickname = {
-         {.str = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
-         {.str = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
-         {.str = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
-         {.str = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
-         {.str = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
-         {.str = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
+         {.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, TERM_, TERM_, TERM_}},
+         {.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, TERM_, TERM_, TERM_}},
+         {.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, TERM_, TERM_, TERM_}},
+         {.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, TERM_, TERM_, TERM_}},
+         {.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, TERM_, TERM_, TERM_}},
+         {.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, TERM_, TERM_, TERM_}},
      }};
      }};
 
 
 unsigned char INPUT_BLOCK[405];
 unsigned char INPUT_BLOCK[405];

+ 10 - 11
views/trade.cpp

@@ -391,21 +391,15 @@ void trade_enter_callback(void* context) {
     
     
     unsigned char nickname[11];
     unsigned char nickname[11];
     for (size_t i = 0; i < 11; ++i) {
     for (size_t i = 0; i < 11; ++i) {
-        nickname[i] = 0x00;
+        nickname[i] = 0x50;
     }
     }
     for (size_t i = 0; i < strlen(pokemon_table[trade->app->current_pokemon].name); ++i) {
     for (size_t i = 0; i < strlen(pokemon_table[trade->app->current_pokemon].name); ++i) {
         nickname[i] = convertCharToTagHex(pokemon_table[trade->app->current_pokemon].name[i]);
         nickname[i] = convertCharToTagHex(pokemon_table[trade->app->current_pokemon].name[i]);
     }
     }
-    for (size_t i = 0; i < 11; ++i) {
-        if(nickname[i] == 0x00) {
-            nickname[i] = 0x50;
-        }
-        break;
-    }
 
 
     memcpy(DATA_BLOCK2.nickname[0].str, nickname, sizeof(nickname));
     memcpy(DATA_BLOCK2.nickname[0].str, nickname, sizeof(nickname));
 
 
-    FURI_LOG_D(TAG, "[Trade] Pokemon Name: %s", nickname);
+    FURI_LOG_D(TAG, "[Trade] Pokemon Name: %s", pokemon_table[trade->app->current_pokemon].name);
 
 
     // Set the Pokemon hex code
     // Set the Pokemon hex code
 
 
@@ -417,7 +411,7 @@ void trade_enter_callback(void* context) {
 
 
     FURI_LOG_D(TAG, "[Trade] Current Level: %d", trade->app->current_level);
     FURI_LOG_D(TAG, "[Trade] Current Level: %d", trade->app->current_level);
 
 
-    int level = trade->app->current_level;
+    uint8_t level = trade->app->current_level;
     DATA_BLOCK2.party[0].level = level & 0xFF;
     DATA_BLOCK2.party[0].level = level & 0xFF;
     DATA_BLOCK2.party[0].level_again = level & 0xFF;
     DATA_BLOCK2.party[0].level_again = level & 0xFF;
 
 
@@ -425,7 +419,7 @@ void trade_enter_callback(void* context) {
 
 
     // Set the Pokemon experience
     // Set the Pokemon experience
 
 
-    int exp = 0;
+    int32_t exp = 0;
     if(pokemon_table[trade->app->current_pokemon].xp_group == 0) {
     if(pokemon_table[trade->app->current_pokemon].xp_group == 0) {
         exp = 1.25 * level * level * level;
         exp = 1.25 * level * level * level;
     } else if(pokemon_table[trade->app->current_pokemon].xp_group == 1) {
     } else if(pokemon_table[trade->app->current_pokemon].xp_group == 1) {
@@ -435,6 +429,7 @@ void trade_enter_callback(void* context) {
     } else if(pokemon_table[trade->app->current_pokemon].xp_group == 3) {
     } else if(pokemon_table[trade->app->current_pokemon].xp_group == 3) {
         exp = 0.8 * level * level * level;
         exp = 0.8 * level * level * level;
     }
     }
+
     DATA_BLOCK2.party[0].exp[0] = (exp >> 16) & 0xFF;
     DATA_BLOCK2.party[0].exp[0] = (exp >> 16) & 0xFF;
     DATA_BLOCK2.party[0].exp[1] = (exp >> 8) & 0xFF;
     DATA_BLOCK2.party[0].exp[1] = (exp >> 8) & 0xFF;
     DATA_BLOCK2.party[0].exp[2] = exp & 0xFF;
     DATA_BLOCK2.party[0].exp[2] = exp & 0xFF;
@@ -509,7 +504,11 @@ void trade_enter_callback(void* context) {
     // Set the Pokemon types
     // Set the Pokemon types
 
 
     DATA_BLOCK2.party[0].type[0] = pokemon_table[trade->app->current_pokemon].type1;
     DATA_BLOCK2.party[0].type[0] = pokemon_table[trade->app->current_pokemon].type1;
-    DATA_BLOCK2.party[0].type[1] = pokemon_table[trade->app->current_pokemon].type2;
+    if(pokemon_table[trade->app->current_pokemon].type2 == 0xFF) {
+        DATA_BLOCK2.party[0].type[1] = pokemon_table[trade->app->current_pokemon].type1;
+    } else {
+        DATA_BLOCK2.party[0].type[1] = pokemon_table[trade->app->current_pokemon].type2;
+    }
 
 
     FURI_LOG_D(TAG, "[Trade] Type 1: %x", DATA_BLOCK2.party[0].type[0]);
     FURI_LOG_D(TAG, "[Trade] Type 1: %x", DATA_BLOCK2.party[0].type[0]);
     FURI_LOG_D(TAG, "[Trade] Type 2: %x", DATA_BLOCK2.party[0].type[1]);
     FURI_LOG_D(TAG, "[Trade] Type 2: %x", DATA_BLOCK2.party[0].type[1]);