From e03f80ce0cafa865eaa7ac77ca78048ad7304b98 Mon Sep 17 00:00:00 2001 From: Willy-JL Date: Wed, 18 Jan 2023 10:15:41 +0000 Subject: [PATCH] Expose dolphin levels --- .../services/dolphin/helpers/dolphin_state.c | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/applications/services/dolphin/helpers/dolphin_state.c b/applications/services/dolphin/helpers/dolphin_state.c index 2a4ef64d3..72fa75ac0 100644 --- a/applications/services/dolphin/helpers/dolphin_state.c +++ b/applications/services/dolphin/helpers/dolphin_state.c @@ -14,9 +14,10 @@ #define DOLPHIN_STATE_PATH INT_PATH(DOLPHIN_STATE_FILE_NAME) #define DOLPHIN_STATE_HEADER_MAGIC 0xD0 #define DOLPHIN_STATE_HEADER_VERSION 0x01 -int level_array[DOLPHIN_LEVEL_COUNT] = {100, 200, 300, 450, 600, 750, 950, 1150, 1350, 1600, - 1850, 2100, 2400, 2700, 3000, 3350, 3700, 4050, 4450, 4850, - 5250, 5700, 6150, 6600, 7100, 7600, 8100, 8650, 9200}; + +const int DOLPHIN_LEVELS[DOLPHIN_LEVEL_COUNT] = {100, 200, 300, 450, 600, 750, 950, 1150, 1350, 1600, + 1850, 2100, 2400, 2700, 3000, 3350, 3700, 4050, 4450, 4850, + 5250, 5700, 6150, 6600, 7100, 7600, 8100, 8650, 9200}; #define BUTTHURT_MAX 14 #define BUTTHURT_MIN 0 @@ -83,16 +84,20 @@ uint64_t dolphin_state_timestamp() { bool dolphin_state_is_levelup(int icounter) { for(int i = 0; i < DOLPHIN_LEVEL_COUNT; ++i) { - if((icounter == level_array[i])) { + if((icounter == DOLPHIN_LEVELS[i])) { return true; } }; return false; } +const int* dolphin_get_levels() { + return DOLPHIN_LEVELS; +} + uint8_t dolphin_get_level(int icounter) { for(int i = 0; i < DOLPHIN_LEVEL_COUNT; ++i) { - if(icounter <= level_array[i]) { + if(icounter <= DOLPHIN_LEVELS[i]) { return i + 1; } } @@ -101,8 +106,8 @@ uint8_t dolphin_get_level(int icounter) { uint32_t dolphin_state_xp_above_last_levelup(int icounter) { for(int i = DOLPHIN_LEVEL_COUNT; i >= 0; --i) { - if(icounter >= level_array[i]) { - return icounter - level_array[i]; + if(icounter >= DOLPHIN_LEVELS[i]) { + return icounter - DOLPHIN_LEVELS[i]; } } return icounter; @@ -110,8 +115,8 @@ uint32_t dolphin_state_xp_above_last_levelup(int icounter) { uint32_t dolphin_state_xp_to_levelup(int icounter) { for(int i = 0; i < DOLPHIN_LEVEL_COUNT; ++i) { - if(icounter <= level_array[i]) { - return level_array[i] - icounter; + if(icounter <= DOLPHIN_LEVELS[i]) { + return DOLPHIN_LEVELS[i] - icounter; } } return (uint32_t)-1;