mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-12 15:28:36 -07:00
Dolphin add missing deeds + fix&clean state code
This commit is contained in:
@@ -100,7 +100,7 @@ bool xtreme_app_apply(XtremeApp* app) {
|
|||||||
if(app->save_level || app->save_angry) {
|
if(app->save_level || app->save_angry) {
|
||||||
Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN);
|
Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN);
|
||||||
if(app->save_level) {
|
if(app->save_level) {
|
||||||
int32_t xp = app->dolphin_level > 1 ? dolphin_get_levels()[app->dolphin_level - 2] : 0;
|
int32_t xp = app->dolphin_level > 1 ? DOLPHIN_LEVELS[app->dolphin_level - 2] : 0;
|
||||||
dolphin->state->data.icounter = xp + 1;
|
dolphin->state->data.icounter = xp + 1;
|
||||||
}
|
}
|
||||||
if(app->save_angry) {
|
if(app->save_angry) {
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ static const DolphinDeedWeight dolphin_deed_weights[] = {
|
|||||||
{1, DolphinAppPlugin}, // DolphinDeedGpioUartBridge
|
{1, DolphinAppPlugin}, // DolphinDeedGpioUartBridge
|
||||||
|
|
||||||
{2, DolphinAppPlugin}, // DolphinDeedPluginStart
|
{2, DolphinAppPlugin}, // DolphinDeedPluginStart
|
||||||
|
{0, DolphinAppPlugin}, // DolphinDeedPluginGameStart
|
||||||
|
{0, DolphinAppPlugin}, // DolphinDeedPluginGameWin
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint8_t dolphin_deed_limits[] = {
|
static uint8_t dolphin_deed_limits[] = {
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ typedef enum {
|
|||||||
DolphinDeedGpioUartBridge,
|
DolphinDeedGpioUartBridge,
|
||||||
|
|
||||||
DolphinDeedPluginStart,
|
DolphinDeedPluginStart,
|
||||||
|
DolphinDeedPluginGameStart,
|
||||||
|
DolphinDeedPluginGameWin,
|
||||||
|
|
||||||
DolphinDeedMAX,
|
DolphinDeedMAX,
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,10 @@
|
|||||||
#define DOLPHIN_STATE_HEADER_MAGIC 0xD0
|
#define DOLPHIN_STATE_HEADER_MAGIC 0xD0
|
||||||
#define DOLPHIN_STATE_HEADER_VERSION 0x01
|
#define DOLPHIN_STATE_HEADER_VERSION 0x01
|
||||||
|
|
||||||
const int DOLPHIN_LEVELS[DOLPHIN_LEVEL_COUNT] = {100, 200, 300, 450, 600, 750, 950, 1150,
|
const uint32_t DOLPHIN_LEVELS[] = {100, 200, 300, 450, 600, 750, 950, 1150, 1350, 1600,
|
||||||
1350, 1600, 1850, 2100, 2400, 2700, 3000, 3350,
|
1850, 2100, 2400, 2700, 3000, 3350, 3700, 4050, 4450, 4850,
|
||||||
3700, 4050, 4450, 4850, 5250, 5700, 6150, 6600,
|
5250, 5700, 6150, 6600, 7100, 7600, 8100, 8650, 9200};
|
||||||
7100, 7600, 8100, 8650, 9200};
|
const size_t DOLPHIN_LEVEL_COUNT = COUNT_OF(DOLPHIN_LEVELS);
|
||||||
|
|
||||||
DolphinState* dolphin_state_alloc() {
|
DolphinState* dolphin_state_alloc() {
|
||||||
return malloc(sizeof(DolphinState));
|
return malloc(sizeof(DolphinState));
|
||||||
@@ -78,8 +78,8 @@ uint64_t dolphin_state_timestamp() {
|
|||||||
return furi_hal_rtc_datetime_to_timestamp(&datetime);
|
return furi_hal_rtc_datetime_to_timestamp(&datetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dolphin_state_is_levelup(int icounter) {
|
bool dolphin_state_is_levelup(uint32_t icounter) {
|
||||||
for(int i = 0; i < DOLPHIN_LEVEL_COUNT; ++i) {
|
for(size_t i = 0; i < DOLPHIN_LEVEL_COUNT; ++i) {
|
||||||
if((icounter == DOLPHIN_LEVELS[i])) {
|
if((icounter == DOLPHIN_LEVELS[i])) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -87,12 +87,8 @@ bool dolphin_state_is_levelup(int icounter) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int* dolphin_get_levels() {
|
uint8_t dolphin_get_level(uint32_t icounter) {
|
||||||
return DOLPHIN_LEVELS;
|
for(size_t i = 0; i < DOLPHIN_LEVEL_COUNT; ++i) {
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t dolphin_get_level(int icounter) {
|
|
||||||
for(int i = 0; i < DOLPHIN_LEVEL_COUNT; ++i) {
|
|
||||||
if(icounter <= DOLPHIN_LEVELS[i]) {
|
if(icounter <= DOLPHIN_LEVELS[i]) {
|
||||||
return i + 1;
|
return i + 1;
|
||||||
}
|
}
|
||||||
@@ -100,20 +96,18 @@ uint8_t dolphin_get_level(int icounter) {
|
|||||||
return DOLPHIN_LEVEL_COUNT + 1;
|
return DOLPHIN_LEVEL_COUNT + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t dolphin_state_xp_above_last_levelup(int icounter) {
|
uint32_t dolphin_state_xp_above_last_levelup(uint32_t icounter) {
|
||||||
for(int i = DOLPHIN_LEVEL_COUNT; i >= 0; --i) {
|
uint8_t level_idx = dolphin_get_level(icounter) - 1; // Level = index + 1
|
||||||
if(icounter >= DOLPHIN_LEVELS[i]) {
|
if(level_idx > 0) {
|
||||||
return icounter - DOLPHIN_LEVELS[i];
|
return icounter - DOLPHIN_LEVELS[level_idx - 1]; // Get prev level
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return icounter;
|
return icounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t dolphin_state_xp_to_levelup(int icounter) {
|
uint32_t dolphin_state_xp_to_levelup(uint32_t icounter) {
|
||||||
for(int i = 0; i < DOLPHIN_LEVEL_COUNT; ++i) {
|
uint8_t level_idx = dolphin_get_level(icounter) - 1; // Level = index + 1
|
||||||
if(icounter <= DOLPHIN_LEVELS[i]) {
|
if(level_idx < DOLPHIN_LEVEL_COUNT) {
|
||||||
return DOLPHIN_LEVELS[i] - icounter;
|
return DOLPHIN_LEVELS[level_idx] - icounter;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return (uint32_t)-1;
|
return (uint32_t)-1;
|
||||||
}
|
}
|
||||||
@@ -172,7 +166,7 @@ void dolphin_state_on_deed(DolphinState* dolphin_state, DolphinDeed deed) {
|
|||||||
|
|
||||||
FURI_LOG_D(
|
FURI_LOG_D(
|
||||||
TAG,
|
TAG,
|
||||||
"icounter %ld, butthurt %ld",
|
"icounter %lu, butthurt %ld",
|
||||||
dolphin_state->data.icounter,
|
dolphin_state->data.icounter,
|
||||||
dolphin_state->data.butthurt);
|
dolphin_state->data.butthurt);
|
||||||
}
|
}
|
||||||
@@ -194,7 +188,7 @@ void dolphin_state_increase_level(DolphinState* dolphin_state) {
|
|||||||
void dolphin_state_clear_limits(DolphinState* dolphin_state) {
|
void dolphin_state_clear_limits(DolphinState* dolphin_state) {
|
||||||
furi_assert(dolphin_state);
|
furi_assert(dolphin_state);
|
||||||
|
|
||||||
for(int i = 0; i < DolphinAppMAX; ++i) {
|
for(size_t i = 0; i < DolphinAppMAX; ++i) {
|
||||||
dolphin_state->data.icounter_daily_limit[i] = 0;
|
dolphin_state->data.icounter_daily_limit[i] = 0;
|
||||||
}
|
}
|
||||||
dolphin_state->data.butthurt_daily_limit = 0;
|
dolphin_state->data.butthurt_daily_limit = 0;
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ extern "C" {
|
|||||||
#define DOLPHIN_STATE_OLD_PATH INT_PATH(".dolphin.state")
|
#define DOLPHIN_STATE_OLD_PATH INT_PATH(".dolphin.state")
|
||||||
#define DOLPHIN_STATE_PATH CFG_PATH("dolphin.state")
|
#define DOLPHIN_STATE_PATH CFG_PATH("dolphin.state")
|
||||||
|
|
||||||
#define DOLPHIN_LEVEL_COUNT 29
|
extern const uint32_t DOLPHIN_LEVELS[];
|
||||||
|
extern const size_t DOLPHIN_LEVEL_COUNT;
|
||||||
|
|
||||||
#define BUTTHURT_MAX 14
|
#define BUTTHURT_MAX 14
|
||||||
#define BUTTHURT_MIN 0
|
#define BUTTHURT_MIN 0
|
||||||
@@ -49,17 +50,15 @@ void dolphin_state_on_deed(DolphinState* dolphin_state, DolphinDeed deed);
|
|||||||
|
|
||||||
void dolphin_state_butthurted(DolphinState* dolphin_state);
|
void dolphin_state_butthurted(DolphinState* dolphin_state);
|
||||||
|
|
||||||
uint32_t dolphin_state_xp_to_levelup(int icounter);
|
uint32_t dolphin_state_xp_to_levelup(uint32_t icounter);
|
||||||
|
|
||||||
uint32_t dolphin_state_xp_above_last_levelup(int icounter);
|
uint32_t dolphin_state_xp_above_last_levelup(uint32_t icounter);
|
||||||
|
|
||||||
const int* dolphin_get_levels();
|
bool dolphin_state_is_levelup(uint32_t icounter);
|
||||||
|
|
||||||
bool dolphin_state_is_levelup(int icounter);
|
|
||||||
|
|
||||||
void dolphin_state_increase_level(DolphinState* dolphin_state);
|
void dolphin_state_increase_level(DolphinState* dolphin_state);
|
||||||
|
|
||||||
uint8_t dolphin_get_level(int icounter);
|
uint8_t dolphin_get_level(uint32_t icounter);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -810,21 +810,20 @@ Function,+,dolphin_deed_get_app,DolphinApp,DolphinDeed
|
|||||||
Function,+,dolphin_deed_get_app_limit,uint8_t,DolphinApp
|
Function,+,dolphin_deed_get_app_limit,uint8_t,DolphinApp
|
||||||
Function,+,dolphin_deed_get_weight,uint8_t,DolphinDeed
|
Function,+,dolphin_deed_get_weight,uint8_t,DolphinDeed
|
||||||
Function,+,dolphin_flush,void,Dolphin*
|
Function,+,dolphin_flush,void,Dolphin*
|
||||||
Function,+,dolphin_get_level,uint8_t,int
|
Function,+,dolphin_get_level,uint8_t,uint32_t
|
||||||
Function,+,dolphin_get_levels,const int*,
|
|
||||||
Function,+,dolphin_get_pubsub,FuriPubSub*,Dolphin*
|
Function,+,dolphin_get_pubsub,FuriPubSub*,Dolphin*
|
||||||
Function,+,dolphin_state_alloc,DolphinState*,
|
Function,+,dolphin_state_alloc,DolphinState*,
|
||||||
Function,+,dolphin_state_butthurted,void,DolphinState*
|
Function,+,dolphin_state_butthurted,void,DolphinState*
|
||||||
Function,+,dolphin_state_clear_limits,void,DolphinState*
|
Function,+,dolphin_state_clear_limits,void,DolphinState*
|
||||||
Function,+,dolphin_state_free,void,DolphinState*
|
Function,+,dolphin_state_free,void,DolphinState*
|
||||||
Function,+,dolphin_state_increase_level,void,DolphinState*
|
Function,+,dolphin_state_increase_level,void,DolphinState*
|
||||||
Function,+,dolphin_state_is_levelup,_Bool,int
|
Function,+,dolphin_state_is_levelup,_Bool,uint32_t
|
||||||
Function,+,dolphin_state_load,_Bool,DolphinState*
|
Function,+,dolphin_state_load,_Bool,DolphinState*
|
||||||
Function,+,dolphin_state_on_deed,void,"DolphinState*, DolphinDeed"
|
Function,+,dolphin_state_on_deed,void,"DolphinState*, DolphinDeed"
|
||||||
Function,+,dolphin_state_save,_Bool,DolphinState*
|
Function,+,dolphin_state_save,_Bool,DolphinState*
|
||||||
Function,+,dolphin_state_timestamp,uint64_t,
|
Function,+,dolphin_state_timestamp,uint64_t,
|
||||||
Function,+,dolphin_state_xp_above_last_levelup,uint32_t,int
|
Function,+,dolphin_state_xp_above_last_levelup,uint32_t,uint32_t
|
||||||
Function,+,dolphin_state_xp_to_levelup,uint32_t,int
|
Function,+,dolphin_state_xp_to_levelup,uint32_t,uint32_t
|
||||||
Function,+,dolphin_stats,DolphinStats,Dolphin*
|
Function,+,dolphin_stats,DolphinStats,Dolphin*
|
||||||
Function,+,dolphin_upgrade_level,void,Dolphin*
|
Function,+,dolphin_upgrade_level,void,Dolphin*
|
||||||
Function,-,dprintf,int,"int, const char*, ..."
|
Function,-,dprintf,int,"int, const char*, ..."
|
||||||
@@ -3311,6 +3310,8 @@ Variable,+,A_Sub1ghz_14,Icon,
|
|||||||
Variable,+,A_U2F_14,Icon,
|
Variable,+,A_U2F_14,Icon,
|
||||||
Variable,+,A_Xtreme_14,Icon,
|
Variable,+,A_Xtreme_14,Icon,
|
||||||
Variable,+,A_iButton_14,Icon,
|
Variable,+,A_iButton_14,Icon,
|
||||||
|
Variable,+,DOLPHIN_LEVELS,const uint32_t[],
|
||||||
|
Variable,+,DOLPHIN_LEVEL_COUNT,const size_t,
|
||||||
Variable,+,FLIPPER_APPS,const FlipperInternalApplication[],
|
Variable,+,FLIPPER_APPS,const FlipperInternalApplication[],
|
||||||
Variable,+,FLIPPER_APPS_COUNT,const size_t,
|
Variable,+,FLIPPER_APPS_COUNT,const size_t,
|
||||||
Variable,-,FLIPPER_ARCHIVE,const FlipperInternalApplication,
|
Variable,-,FLIPPER_ARCHIVE,const FlipperInternalApplication,
|
||||||
|
|||||||
|
Reference in New Issue
Block a user