Enter the stat mode for a given character.
14 {
16 stats_result_t result = STATS_WINDOW;
17
18
20 const char* menu_options[4];
21
22 menu_options[0] = stats_mode_strings[STRENGTH_STR];
23 menu_options[1] = stats_mode_strings[INTELLIGENCE_STR];
24 menu_options[2] = stats_mode_strings[DEXTERITY_STR];
25 menu_options[3] = stats_mode_strings[CONSTITUTION_STR];
26
28 stats_mode_strings[STATS_MENU_TITLE],
29 menu_options,
30 4,
31 selected_index, "");
32
35
36 switch (input_event.type) {
37 case INPUT_UP:
38 selected_index = (selected_index > 0) ? selected_index - 1 : MAX_STATS - 1;
39 break;
40 case INPUT_DOWN:
41 selected_index = (selected_index + 1) % MAX_STATS;
42 break;
43 case INPUT_CONFIRM:
44 if (player->skill_points > 0) {
45 switch (selected_index) {
46 case 0:
47 raise_skill(&player->base_stats, STRENGTH, player->skill_points);
48 break;
49 case 1:
50 raise_skill(&player->base_stats, INTELLIGENCE, player->skill_points);
51 break;
52 case 2:
53 raise_skill(&player->base_stats, DEXTERITY, player->skill_points);
54 break;
55 case 3:
56 raise_skill(&player->base_stats, CONSTITUTION, player->skill_points);
57 break;
58 default:;
59 }
60 player->skill_points--;
62 } else {
63 char word[MAX_STRING_LENGTH - 4];
64 snprintf(word, MAX_STRING_LENGTH - 4, "%s: 0", stats_mode_strings[AVAILABLE_SKILL_POINTS_STR]);
66 }
67 break;
68 case INPUT_CANCEL:
69 case INPUT_STATS:
70 result = STATS_EXIT;
71 break;
72 default:
73 break;
74 }
75 }
76
78 return result;
79}
void update_character_resources(resources_t *current_resources, resources_t *max_resources, stats_t *base_stats)
Updates the character's resources based on their stats.
void print_text_default(int y, int x, const char *text)
Print text at a specific position with default colors.
bool render_frame(void)
Render the current frame.
void clear_screen(void)
Clear the screen.
void raise_skill(stats_t *stats, stat_type_t stat, int skillpoint)
Raises a specified skill by one point.
void draw_stats_menu(const char *title, const char **options, int option_count, int selected_index, const char *footer)
Draw the stats menu.
void render_stats_window(const character_t *player)
Render the stats window.