Skip to content

Commit de8ef7d

Browse files
committed
pokemon: Reimplement logging
1 parent 788848a commit de8ef7d

8 files changed

+57
-0
lines changed

pokemon_app.c

+30
Original file line numberDiff line numberDiff line change
@@ -1920,6 +1920,7 @@ void pokemon_trade_block_set_default_name(char* dest, PokemonFap* pokemon_fap, s
19201920
toupper(pokemon_fap->pokemon_table[pokemon_fap->curr_pokemon].name[i]));
19211921
buf[i] = toupper(pokemon_fap->pokemon_table[pokemon_fap->curr_pokemon].name[i]);
19221922
}
1923+
FURI_LOG_D(TAG, "[app] Set default nickname");
19231924

19241925
if(dest != NULL) {
19251926
strncpy(dest, buf, n);
@@ -1972,6 +1973,8 @@ void pokemon_trade_block_recalculate_stats_from_level(PokemonFap* pokemon_fap) {
19721973

19731974
pkmn->level_again = level;
19741975
UINT32_TO_EXP(experience, pkmn->exp);
1976+
FURI_LOG_D(TAG, "[app] Set pkmn level %d", level);
1977+
FURI_LOG_D(TAG, "[app] Set pkmn exp %d", (int)experience);
19751978

19761979
/* Generate STATEXP */
19771980
switch(curr_stats) {
@@ -1988,6 +1991,7 @@ void pokemon_trade_block_recalculate_stats_from_level(PokemonFap* pokemon_fap) {
19881991
break;
19891992
}
19901993

1994+
FURI_LOG_D(TAG, "[app] EVs set to %d", stat);
19911995
stat = __builtin_bswap16(stat);
19921996

19931997
pkmn->hp_ev = stat;
@@ -2006,33 +2010,50 @@ void pokemon_trade_block_recalculate_stats_from_level(PokemonFap* pokemon_fap) {
20062010
((special_iv & 0x0f));
20072011
hp_iv = (pkmn->iv & 0xAA) >> 4;
20082012
}
2013+
FURI_LOG_D(
2014+
TAG,
2015+
"[app] atk_iv %d, def_iv %d, spd_iv %d, spc_iv %d, hp_iv %d",
2016+
atk_iv,
2017+
def_iv,
2018+
spd_iv,
2019+
special_iv,
2020+
hp_iv);
20092021

20102022
/* Calculate HP */
20112023
// https://bulbapedia.bulbagarden.net/wiki/Stat#Generations_I_and_II
20122024
stat = floor((((2 * (table->base_hp + hp_iv)) + floor(sqrt(pkmn->hp_ev) / 4)) * level) / 100) +
20132025
(level + 10);
2026+
FURI_LOG_D(TAG, "[app] HP set to %d", stat);
20142027
pkmn->hp = __builtin_bswap16(stat);
20152028
pkmn->max_hp = pkmn->hp;
20162029

20172030
/* Calculate ATK, DEF, SPD, SP */
2031+
/* TODO: these all use the same calculations, could put the stats in a sub-array and iterate
2032+
* through each element in order rather than having to repeat the code. IVs would also need
2033+
* to be in a similar array.
2034+
**/
20182035
// https://bulbapedia.bulbagarden.net/wiki/Stat#Generations_I_and_II
20192036
stat =
20202037
floor((((2 * (table->base_atk + atk_iv)) + floor(sqrt(pkmn->atk_ev) / 4)) * level) / 100) +
20212038
5;
2039+
FURI_LOG_D(TAG, "[app] ATK set to %d", stat);
20222040
pkmn->atk = __builtin_bswap16(stat);
20232041
stat =
20242042
floor((((2 * (table->base_def + def_iv)) + floor(sqrt(pkmn->def_ev) / 4)) * level) / 100) +
20252043
5;
2044+
FURI_LOG_D(TAG, "[app] DEF set to %d", stat);
20262045
pkmn->def = __builtin_bswap16(stat);
20272046
stat =
20282047
floor((((2 * (table->base_spd + spd_iv)) + floor(sqrt(pkmn->spd_ev) / 4)) * level) / 100) +
20292048
5;
2049+
FURI_LOG_D(TAG, "[app] SPD set to %d", stat);
20302050
pkmn->spd = __builtin_bswap16(stat);
20312051
stat = floor(
20322052
(((2 * (table->base_special + special_iv)) + floor(sqrt(pkmn->special_ev) / 4)) *
20332053
level) /
20342054
100) +
20352055
5;
2056+
FURI_LOG_D(TAG, "[app] SPC set to %d", stat);
20362057
pkmn->special = __builtin_bswap16(stat);
20372058
}
20382059

@@ -2045,15 +2066,24 @@ void pokemon_trade_block_recalculate(PokemonFap* pokemon_fap) {
20452066
/* Set current pokemon to the trade structure */
20462067
pkmn->index = table->index;
20472068
pokemon_fap->trade_block->party_members[0] = table->index;
2069+
FURI_LOG_D(TAG, "[app] Set %s in trade block", table->name);
20482070

20492071
/* Set current pokemon's moves to the trade structure */
20502072
for(i = 0; i < 4; i++) {
20512073
pkmn->move[i] = table->move[i];
2074+
FURI_LOG_D(
2075+
TAG,
2076+
"[app] Set %s in trade block",
2077+
pokemon_named_list_get_name_from_index(pokemon_fap->move_list, pkmn->move[i]));
20522078
}
20532079

20542080
/* Set current pokemon's types to the trade structure */
20552081
for(i = 0; i < 2; i++) {
20562082
pkmn->type[i] = table->type[i];
2083+
FURI_LOG_D(
2084+
TAG,
2085+
"[app] Set %s in trade block",
2086+
pokemon_named_list_get_name_from_index(pokemon_fap->type_list, pkmn->type[i]));
20572087
}
20582088

20592089
pokemon_trade_block_recalculate_stats_from_level(pokemon_fap);

scenes/pokemon_move.c

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ static void select_move_selected_callback(void* context, uint32_t index) {
1515
} else {
1616
pokemon_fap->trade_block->party[0].move[move] = (uint8_t)index;
1717
}
18+
FURI_LOG_D(
19+
TAG,
20+
"[move] Set move %s to %d",
21+
pokemon_named_list_get_name_from_index(
22+
pokemon_fap->move_list, pokemon_fap->trade_block->party[0].move[move]),
23+
(int)move);
1824

1925
/* Move back to move menu */
2026
scene_manager_search_and_switch_to_previous_scene(pokemon_fap->scene_manager, SelectMoveScene);

scenes/pokemon_nickname.c

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ static bool select_nickname_input_validator(const char* text, FuriString* error,
4141
(uint8_t*)pokemon_fap->trade_block->nickname, (char*)text, strlen(text));
4242
}
4343

44+
FURI_LOG_D(TAG, "[nickname] Set nickname to %s", text);
45+
4446
return rc;
4547
}
4648

scenes/pokemon_ot_id.c

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ static bool select_ot_id_input_validator(const char* text, FuriString* error, vo
3636
pokemon_fap->trade_block->party[0].ot_id = ot_id_16;
3737
}
3838

39+
FURI_LOG_D(TAG, "[ot_id] Set OT ID to %05d", (uint16_t)ot_id);
40+
3941
return rc;
4042
}
4143

scenes/pokemon_ot_name.c

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ static bool select_ot_name_input_validator(const char* text, FuriString* error,
3737
(uint8_t*)pokemon_fap->trade_block->ot_name, (char*)text, strlen(text));
3838
}
3939

40+
FURI_LOG_D(TAG, "[ot_name] Set OT name to %s", text);
41+
4042
return rc;
4143
}
4244

scenes/pokemon_stats.c

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ static void select_stats_selected_callback(void* context, uint32_t index) {
1919

2020
pokemon_trade_block_recalculate_stats_from_level(pokemon_fap);
2121

22+
FURI_LOG_D(TAG, "[stats] Set stats to %s", stats_text[index]);
23+
2224
scene_manager_previous_scene(pokemon_fap->scene_manager);
2325
}
2426

scenes/pokemon_type.c

+12
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ static void select_type_1_callback(VariableItem* item) {
1818

1919
variable_item_set_current_value_text(item, pokemon_fap->type_list[index].name);
2020
pokemon_fap->trade_block->party[0].type[0] = pokemon_fap->type_list[index].index;
21+
22+
FURI_LOG_D(
23+
TAG,
24+
"[type] Set type1 to %s",
25+
pokemon_named_list_get_name_from_index(
26+
pokemon_fap->type_list, pokemon_fap->type_list[index].index));
2127
}
2228

2329
static void select_type_2_callback(VariableItem* item) {
@@ -26,6 +32,12 @@ static void select_type_2_callback(VariableItem* item) {
2632

2733
variable_item_set_current_value_text(item, pokemon_fap->type_list[index].name);
2834
pokemon_fap->trade_block->party[0].type[1] = pokemon_fap->type_list[index].index;
35+
36+
FURI_LOG_D(
37+
TAG,
38+
"[type] Set type2 to %s",
39+
pokemon_named_list_get_name_from_index(
40+
pokemon_fap->type_list, pokemon_fap->type_list[index].index));
2941
}
3042

3143
void select_type_scene_on_exit(void* context) {

views/select_pokemon.c

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ static bool select_pokemon_input_callback(InputEvent* event, void* context) {
4949
/* Advance to next view with the selected pokemon */
5050
case InputKeyOk:
5151
pokemon_fap->curr_pokemon = selected_pokemon;
52+
FURI_LOG_D(TAG, "[Select] Selected %s", pokemon_fap->pokemon_table[selected_pokemon].name);
5253
scene_manager_previous_scene(pokemon_fap->scene_manager);
5354
consumed = true;
5455
break;

0 commit comments

Comments
 (0)