Accessory btn now selects team in Configuring state.

This commit is contained in:
Joe Kearney 2025-01-27 20:01:28 -06:00
parent 6f51f5b006
commit 80b4987bcb
4 changed files with 189 additions and 141 deletions

View file

@ -23,24 +23,55 @@
#define GAME_H
#include "Weapons.h"
#define MAX_HEALTH 10
//! Implemented according to the 2024-07-20 "KTag Teams Compatibility Matrix".
typedef enum
{
TEAM_PURPLE = 0,
TEAM_RED = 1,
TEAM_BLUE = 2,
TEAM_WHITE = 3,
COMMON_TEAM_ID_MASK = 3,
TEAM_ORANGE = 4,
TEAM_GREEN = 5,
TEAM_YELLOW = 6,
TEAM_BLACK = 7,
EXTENDED_TEAM_ID_MASK = 7
TEAM_PURPLE = 0,
BASIC_TEAMS_MINIMUM = 0,
TEAM_RED = 1,
TEAM_BLUE = 2,
BASIC_TEAMS_MAXIMUM = 2,
TEAM_WHITE = 3,
COMMON_TEAM_ID_MASK = 3,
TEAM_ORANGE = 4,
TEAM_GREEN = 5,
TEAM_YELLOW = 6,
TEAM_BLACK = 7,
EXTENDED_TEAM_ID_MASK = 7,
MAXIMUM_TEAM_ID = 7
} TeamID_t;
__attribute__((always_inline)) static inline SystemKResult_T Set_Team_With_Audio_Feedback(uint8_t team_ID)
{
static uint8_t Team_ID = 0; // This is static because AUDIO_PRONOUNCE_NUMBER_0_TO_100 needs a *pointer*.
SystemKResult_T result = SYSTEMK_RESULT_SUCCESS;
Team_ID = team_ID;
if (Team_ID > MAXIMUM_TEAM_ID)
{
result = SYSTEMK_RESULT_OVERFLOW;
}
else
{
result = SETTINGS_set_uint8_t(SYSTEMK_SETTING_TEAMID, Team_ID);
if (result == SYSTEMK_RESULT_SUCCESS)
{
AudioAction_T audio_action = {.ID = AUDIO_PLAY_TEAM_ID_PROMPT, .Play_To_Completion = true, .Data = (void *)0x00};
Perform_Audio_Action(&audio_action);
AudioAction_T volume_action = {.ID = AUDIO_PRONOUNCE_NUMBER_0_TO_100, .Play_To_Completion = true, .Data = (void *)&Team_ID};
Perform_Audio_Action(&volume_action);
}
}
return result;
}
__attribute__((always_inline)) inline TeamID_t Resolve_Common_Team_ID(uint8_t team_ID)
{
return (team_ID & COMMON_TEAM_ID_MASK);
@ -50,9 +81,9 @@ __attribute__((always_inline)) inline bool Team_Can_Tag_Me(uint8_t tagging_team_
{
bool can_tag = false;
uint8_t team_ID;
(void) SETTINGS_get_uint8_t(SYSTEMK_SETTING_TEAMID, &team_ID);
(void)SETTINGS_get_uint8_t(SYSTEMK_SETTING_TEAMID, &team_ID);
TeamID_t my_common_team_ID = Resolve_Common_Team_ID(team_ID);
if (tagging_team_ID == TEAM_PURPLE)
{
can_tag = true;
@ -67,7 +98,7 @@ __attribute__((always_inline)) inline bool Team_Can_Tag_Me(uint8_t tagging_team_
return can_tag;
}
typedef struct
{
uint8_t My_Health;
@ -82,7 +113,7 @@ typedef struct
} KTag_Game_Data_T;
extern KTag_Game_Data_T KTAG_Game_Data;
__attribute__((always_inline)) inline uint8_t Get_Health()
{
return KTAG_Game_Data.My_Health;
@ -91,10 +122,10 @@ __attribute__((always_inline)) inline uint8_t Get_Health()
__attribute__((always_inline)) inline void Set_Health(uint8_t health)
{
KTAG_Game_Data.My_Health = health;
if (KTAG_Game_Data.My_Health == 0)
{
KEvent_T tagged_out_event = { .ID = KEVENT_TAGGED_OUT, .Data = (void *)0x00 };
KEvent_T tagged_out_event = {.ID = KEVENT_TAGGED_OUT, .Data = (void *)0x00};
Post_KEvent(&tagged_out_event);
}
}
@ -108,7 +139,7 @@ __attribute__((always_inline)) inline void Reduce_Health(uint8_t reduction)
else
{
KTAG_Game_Data.My_Health = 0;
KEvent_T tagged_out_event = { .ID = KEVENT_TAGGED_OUT, .Data = (void *)0x00 };
KEvent_T tagged_out_event = {.ID = KEVENT_TAGGED_OUT, .Data = (void *)0x00};
Post_KEvent(&tagged_out_event);
}
}
@ -234,5 +265,5 @@ __attribute__((always_inline)) inline bool Use_Bomb_If_Available()
return available;
}
#endif // GAME_H