Many new settings to support the new state machine functionality.

This commit is contained in:
Joe Kearney 2025-03-01 06:09:51 -06:00
parent 908bdbba35
commit 47822bbdec
11 changed files with 84 additions and 21 deletions

View file

@ -226,13 +226,11 @@ void HandleBLETagPacket(const BLE_TagPacket_T *const packet)
else if (packet->damage < 0)
{
Health_In_Percent -= packet->damage;
if (Health_In_Percent > MAX_HEALTH)
if (Health_In_Percent > Get_Max_Health())
{
Health_In_Percent = MAX_HEALTH;
Health_In_Percent = Get_Max_Health();
}
Health_In_Percent = MAX_HEALTH;
Set_Health(Health_In_Percent);
AudioAction_T audio_action = {.ID = AUDIO_PRONOUNCE_NUMBER_0_TO_100, .Play_To_Completion = true, .Data = (void *)&Health_In_Percent};
Perform_Audio_Action(&audio_action);

View file

@ -22,6 +22,22 @@
/* Include Files */
#include "SystemK.h"
static const char *KLOG_TAG = "STATE_PLAYING__TAGGED_OUT";
static void Reset_Bombs()
{
uint8_t n_bombs;
if (SETTINGS_get_uint8_t(SYSTEMK_SETTING_N_SPECIAL_WEAPONS_ON_REENTRY, &n_bombs) == SYSTEMK_RESULT_SUCCESS)
{
Set_Available_Bombs(n_bombs);
}
else
{
Set_Available_Bombs(0);
KLOG_ERROR(KLOG_TAG, "Error getting available bombs!");
}
}
static void Playing__Tagged_Out_Entry(StateMachineContext_T * context);
static void Playing__Tagged_Out_Do(StateMachineContext_T * context);
static void Playing__Tagged_Out_Exit(StateMachineContext_T * context);
@ -78,8 +94,7 @@ static void Playing__Tagged_Out_Do(StateMachineContext_T * context)
if (Back_In() == true)
{
// TODO: Get this from settings.
Set_Available_Bombs(1);
Reset_Bombs();
Transition_For_Event(context, STATE_PLAYING__INTERACTING, &Event);
}
}
@ -101,9 +116,8 @@ static void Playing__Tagged_Out_Do(StateMachineContext_T * context)
// Was it a "long" press?
if (duration_of_press_in_ms > 5000)
{
Set_Health(MAX_HEALTH);
// TODO: Get this from settings.
Set_Available_Bombs(1);
Set_Health(Get_Max_Health());
Reset_Bombs();
Transition_For_Event(context, STATE_PLAYING__INTERACTING, &Event);
}
}
@ -118,9 +132,8 @@ static void Playing__Tagged_Out_Do(StateMachineContext_T * context)
break;
case KEVENT_PLAY_PRESSED_ON_REMOTE:
Set_Health(MAX_HEALTH);
// TODO: Get this from settings.
Set_Available_Bombs(1);
Set_Health(Get_Max_Health());
Reset_Bombs();
Transition_For_Event(context, STATE_PLAYING__INTERACTING, &Event);
break;

View file

@ -22,6 +22,8 @@
/* Include Files */
#include "SystemK.h"
static const char *KLOG_TAG = "STARTING_GAME__COUNTING_DOWN";
static void Starting_Game__Counting_Down_Entry(StateMachineContext_T * context);
static void Starting_Game__Counting_Down_Do(StateMachineContext_T * context);
static void Starting_Game__Counting_Down_Exit(StateMachineContext_T * context);
@ -48,8 +50,17 @@ static void Starting_Game__Counting_Down_Entry(StateMachineContext_T * context)
Reset_Shots_Fired();
Reset_Tags_Received();
Reset_Times_Tagged_Out();
// TODO: Get this from settings.
Set_Available_Bombs(1);
uint8_t n_bombs;
if (SETTINGS_get_uint8_t(SYSTEMK_SETTING_N_SPECIAL_WEAPONS_ON_REENTRY, &n_bombs) == SYSTEMK_RESULT_SUCCESS)
{
Set_Available_Bombs(n_bombs);
}
else
{
Set_Available_Bombs(0);
KLOG_ERROR(KLOG_TAG, "Error getting available bombs!");
}
N_Lights_Lit = 0;
AudioAction_T audio_action = {.ID = AUDIO_SILENCE, .Data = (void *)0x00};

View file

@ -49,6 +49,10 @@ static void Starting_Game__Instigating_Entry(StateMachineContext_T * context)
Starting_Game_Entry(context);
LOG("Entering the Instigating substate of the Starting Game state.");
uint32_t game_length_in_ms;
(void) SETTINGS_get_uint32_t(SYSTEMK_SETTING_T_GAME_LENGTH_in_ms, &game_length_in_ms);
Set_Time_Remaining_Until_Countdown(game_length_in_ms);
Set_Time_Remaining_in_Game(UINT32_MAX);
uint32_t start_game_time_in_ms;

View file

@ -56,6 +56,7 @@ static void Starting_Game__Responding_Entry(StateMachineContext_T * context)
{
uint32_t game_length_in_ms = ((BLE_Packet_T *)context->Cause_Of_Transition->Data)->Instigation.game_length_in_ms;
Set_Time_Remaining_in_Game(game_length_in_ms);
(void) SETTINGS_set_uint32_t(SYSTEMK_SETTING_T_GAME_LENGTH_in_ms, game_length_in_ms);
uint32_t time_remaining_until_countdown_in_ms = ((BLE_Packet_T *)context->Cause_Of_Transition->Data)->Instigation.time_remaining_until_countdown_in_ms;
Set_Time_Remaining_Until_Countdown(time_remaining_until_countdown_in_ms);

View file

@ -330,4 +330,6 @@ void HandleBLEConfigurationPacket(const BLE_ParametersPacket_T *const packet)
}
}
}
BLE_FreePacketBuffer((BLE_GenericPacketType_T *)packet);
}

View file

@ -55,7 +55,7 @@ static void Ready_Entry(StateMachineContext_T * context)
AudioAction_T audio_action = {.ID = AUDIO_PLAY_GAME_ON, .Data = (void *)0x00};
Perform_Audio_Action(&audio_action);
Set_Health(MAX_HEALTH);
Set_Health(Get_Max_Health());
}
//! Executes the Ready state.