pokeplatinum/include/trainer_info.h
2026-01-30 14:37:51 -07:00

311 lines
7.7 KiB
C

#ifndef POKEPLATINUM_TRAINER_INFO_H
#define POKEPLATINUM_TRAINER_INFO_H
#include "constants/string.h"
#include "heap.h"
#include "string_gf.h"
typedef struct TrainerInfo {
charcode_t name[TRAINER_NAME_LEN + 1];
u32 id;
u32 money;
u8 gender;
u8 language;
u8 badgeMask;
u8 appearance;
u8 gameCode;
u8 isMainStoryCleared : 1;
u8 hasNationalDex : 1;
u8 : 6;
} TrainerInfo;
/**
* @brief Get the size of a TrainerInfo struct.
*
* @return Size of the struct.
*/
int TrainerInfo_Size(void);
/**
* @brief Create a new TrainerInfo struct and initialize it.
*
* @see TrainerInfo_Init
*
* @param heapID Heap on which to allocate the new struct.
* @return Address of the new struct.
*/
TrainerInfo *TrainerInfo_New(enum HeapID heapID);
/**
* @brief Copy a source TrainerInfo struct into a destination struct, byte-for-byte.
*
* @param src The source struct.
* @param dst The destination struct.
*/
void TrainerInfo_Copy(const TrainerInfo *src, TrainerInfo *dst);
/**
* @brief Initialize an allocated TrainerInfo struct to the base state.
*
* Zeroes out all data within the given struct and resets the region
* code and version to be those specified for the ROM.
*
* @param info The struct to be initialized.
*/
void TrainerInfo_Init(TrainerInfo *info);
/**
* @brief Check if the trainer has no name.
*
* @param info The trainer info.
* @return TRUE if the trainer's name is empty; FALSE if it contains any data.
*/
BOOL TrainerInfo_HasNoName(const TrainerInfo *info);
/**
* @brief Set the trainer's name.
*
* @param info The trainer info.
* @param name Player's new name, as a character buffer.
*/
void TrainerInfo_SetName(TrainerInfo *info, const charcode_t *name);
/**
* @brief Set the trainer's name.
*
* @param info The trainer info.
* @param name Player's new name, as a String struct.
*/
void TrainerInfo_SetNameFromString(TrainerInfo *info, const String *name);
/**
* @brief Get the trainer's name.
*
* @param info The trainer info.
* @return The trainer's name, as a character buffer.
*/
const charcode_t *TrainerInfo_Name(const TrainerInfo *info);
/**
* @brief Get the trainer's name.
*
* @param info The trainer info.
* @param name Pre-allocated String struct to receive the trainer's name.
*/
void TrainerInfo_NameString(const TrainerInfo *info, String *name);
/**
* @brief Get the trainer's name.
*
* @param info The trainer info.
* @param heapID Heap on which to allocate the new String struct.
* @return The trainer's name, as a String struct.
*/
String *TrainerInfo_NameNewString(const TrainerInfo *info, enum HeapID heapID);
/**
* @brief Set the trainer's ID.
*
* @param info The trainer info.
* @param id New trainer ID.
*/
void TrainerInfo_SetID(TrainerInfo *info, u32 id);
/**
* @brief Get the trainer's ID.
*
* Note that this is the complete 32-byte ID; it includes both the visible
* trainer ID and the invisible "secret ID."
*
* @param info The trainer info.
* @return The trainer's ID.
*/
u32 TrainerInfo_ID(const TrainerInfo *info);
/**
* @brief Get the lower half of the trainer's ID.
*
* This constitutes only the visible trainer ID.
*
* @param info The trainer info.
* @return The lower half of the trainer's ID.
*/
u16 TrainerInfo_ID_LowHalf(const TrainerInfo *info);
/**
* @brief Set the trainer's gender.
*
* @param info The trainer info.
* @param gender New trainer gender.
*/
void TrainerInfo_SetGender(TrainerInfo *info, int gender);
/**
* @brief Get the trainer's gender.
*
* @param info The trainer info.
* @return The trainer's gender.
*/
u32 TrainerInfo_Gender(const TrainerInfo *info);
/**
* @brief Check if the trainer has a certain badge.
*
* @param info The trainer info.
* @param badgeNum Number of the badge to check, 0-indexed.
* @return TRUE if the trainer has the badge, FALSE otherwise.
*/
BOOL TrainerInfo_HasBadge(const TrainerInfo *info, int badgeNum);
/**
* @brief Set the flag denoting possession of a given badge.
*
* @param info The trainer info.
* @param badgeNum Number of the badge to set.
*/
void TrainerInfo_SetBadge(TrainerInfo *info, int badgeNum);
/**
* @brief Get the number of badges owned by the trainer.
*
* @param info The trainer info.
* @return Number of badges acquired.
*/
int TrainerInfo_BadgeCount(const TrainerInfo *info);
/**
* @brief Get the trainer's current money.
*
* @param info The trainer info.
* @return How much money the trainer has.
*/
u32 TrainerInfo_Money(const TrainerInfo *info);
/**
* @brief Set the trainer's current money.
*
* @param info The trainer info.
* @param money How much money the trainer should have.
* @return The trainer's new current money.
*/
u32 TrainerInfo_SetMoney(TrainerInfo *info, u32 money);
/**
* @brief Get the trainer's appearance in the Union Room.
*
* @param info
* @return The trainer's Union Room apperance.
*/
u8 TrainerInfo_Appearance(const TrainerInfo *info);
/**
* @brief Set the trainer's appearance in the Union Room.
*
* @param info The trainer info.
* @param appearance New appearance setting.
*/
void TrainerInfo_SetAppearance(TrainerInfo *info, u8 appearance);
/**
* @brief Give the trainer a specified amount of money.
*
* @param info The trainer info.
* @param money The amount of money to give the trainer.
* @return The trainer's new current money.
*/
u32 TrainerInfo_GiveMoney(TrainerInfo *info, u32 money);
/**
* @brief Take a specified amount of money from the trainer.
*
* @param info The trainer info.
* @param money The amount of money to take from the trainer.
* @return The trainer's new current money.
*/
u32 TrainerInfo_TakeMoney(TrainerInfo *info, u32 money);
/**
* @brief Get the trainer's game code.
*
* @param info The trainer info.
* @return The trainer's game code.
*/
u8 TrainerInfo_GameCode(const TrainerInfo *info);
/**
* @brief Set the trainer's game code.
*
* @param info The trainer info.
* @param gameCode New game code.
*/
void TrainerInfo_SetGameCode(TrainerInfo *info, u8 gameCode);
/**
* @brief Get the game code for interfacing with Diamond and Pearl.
*
* @return 0
*/
u8 TrainerInfo_DPGameCode(void);
/**
* @brief Get the trainer's language.
*
* @param info The trainer info.
* @return The trainer's language.
*/
u8 TrainerInfo_Language(const TrainerInfo *info);
/**
* @brief Set the trainer's language.
*
* @param info The trainer info.
* @param language New language.
*/
void TrainerInfo_SetLanguage(TrainerInfo *info, u8 language);
/**
* @brief Set the "game cleared" flag for the trainer.
*
* @param info The trainer info.
*/
void TrainerInfo_SetMainStoryCleared(TrainerInfo *info);
/**
* @brief Check if the trainer has cleared the main game.
*
* @param info The trainer info.
* @return TRUE if the trainer has cleared the main game; FALSE otherwise.
*/
BOOL TrainerInfo_IsMainStoryCleared(TrainerInfo *info);
/**
* @brief Set the "has the National Dex" flag for the trainer.
*
* @param info The trainer info.
*/
void TrainerInfo_GiveNationalDex(TrainerInfo *info);
/**
* @brief Check if the trainer has the National Dex.
*
* @param info The trainer info.
* @return TRUE if the trainer has the National Dex; FALSE otherwise.
*/
BOOL TrainerInfo_HasNationalDex(TrainerInfo *info);
/**
* @brief Compare two trainer states for equality
*
* Two trainer states are deemed to be equal if:
* 1. They have the same name.
* 2. They have the same 32-byte ID.
*
* @param info1 The first trainer info.
* @param info2 The second trainer info.
* @return TRUE if the trainer states are deemed equal; FALSE if not.
*/
BOOL TrainerInfo_Equals(const TrainerInfo *info1, const TrainerInfo *info2);
#endif // POKEPLATINUM_TRAINER_INFO_H