helapordo 1.4.12
Loading...
Searching...
No Matches
game_utils.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#include <inttypes.h>
#include <signal.h>
#include "../core/game_core.h"
#include "../release_data/release_data.h"
Include dependency graph for game_utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define _POSIX_C_SOURCE   200809L
 
#define hlpd_d_keyval(key)
 

Functions

void * s4c_gui_malloc (size_t size)
 
void * s4c_gui_calloc (size_t count, size_t size)
 
void hlpd_sigint_handler (int signum)
 Function to handle Ctrl+C signal.
 
void initWincon (Wincon *w, Path *p, winconClass class)
 Takes a Wincon and a Path pointers and a winconClass and initialises the passed Wincon.
 
void printGlobVars (void)
 Prints global vars to stdout.
 
void red (void)
 Prints an ASCII escape code that makes subsequent output a thick red color.
 
void lightRed (void)
 Prints an ASCII escape code that makes subsequent output a light red color.
 
void strongWhite (void)
 Prints an ASCII escape code that makes subsequent output a thick white color.
 
void white (void)
 Prints an ASCII escape code that makes subsequent output a light white color.
 
void green (void)
 Prints an ASCII escape code that makes subsequent output a thick green color.
 
void lightGreen (void)
 Prints an ASCII escape code that makes subsequent output a light green color.
 
void yellow (void)
 Prints an ASCII escape code that makes subsequent output a thick yellow color.
 
void lightYellow (void)
 Prints an ASCII escape code that makes subsequent output a light yellow color.
 
void blue (void)
 Prints an ASCII escape code that makes subsequent output a thick blue color.
 
void lightBlue (void)
 Prints an ASCII escape code that makes subsequent output a light blue color.
 
void purple (void)
 Prints an ASCII escape code that makes subsequent output a thick purple color.
 
void lightPurple (void)
 Prints an ASCII escape code that makes subsequent output a light purple color.
 
void cyan (void)
 Prints an ASCII escape code that makes subsequent output a thick cyan color.
 
void lightCyan (void)
 Prints an ASCII escape code that makes subsequent output a light cyan color.
 
void init_game_color_pairs (void)
 
void resolve_staticPath (char static_path[500])
 Sets the passed char array to the expected path for /static/ folder.
 
void dbg_print_floor_layout (Floor *floor)
 Logs floor layout for passed Floor.
 
void dbg_print_explored_layout (Floor *floor)
 Logs explored layout for passed Floor.
 
void dbg_print_roomclass_layout (Floor *floor)
 Logs roomclass layout for passed Floor.
 
void dbg_Gamestate (Gamestate *gmst)
 Debugs the passed (preallocated) Gamestate with log_tag().
 
void dbg_GameScreen (GameScreen *scr)
 Debugs the passed (preallocated) GameScreen with log_tag().
 
void dbg_GameOptions (GameOptions *options)
 
void dbg_Fighter (Fighter *fighter)
 Debugs the passed (preallocated) Fighter with log_tag().
 
void dbg_countStats (countStats *stats)
 Debugs the passed (preallocated) countStats with log_tag().
 
void dbg_Wincon (Wincon *wc)
 Debugs the passed (preallocated) Wincon with log_tag().
 
void dbg_Path (Path *path)
 Debugs the passed (preallocated) Path with log_tag().
 
void dbg_Saveslot (Saveslot *saveslot)
 Debugs the passed (preallocated) Saveslot with log_tag().
 
void update_Gamestate (Gamestate *gmst, int current_fighters, roomClass current_roomtype, int current_room_index, int current_enemy_index, Floor *current_floor, Room *current_room, GameOptions *game_options)
 Updates the passed (preallocated) Gamestate with the passed int values.
 
void update_Equipslots (Fighter *f)
 Updates the passed Fighter's Equipslots item fields, by reading the equipsBag field and setting the equipped ones.
 
void loadLore (char **lore_strings, int loreKind)
 Loads the lore strings from the appropriate lore file.
 
void setRoomType (Path *path, int *roadFork_value, roomClass *room_type, int roomsDone)
 Takes a path pointer, a roadFork value pointer, a room type pointer, and an integer.
 
void freeRoom (Room *room)
 Frees the memory allocated for the passed room pointer.
 
void printTitle (void)
 Prints an hardcoded title screen.
 
void printVersion (void)
 Prints version string.
 
void printFormattedVersion (const char *progname)
 Prints formatted version string.
 
void hlpd_dbg_features (void)
 Prints configuration info.
 
void usage (const char *progname)
 Prints correct argument syntax for command line invocation.
 
void log_tag (char *filename, char *header, const char *format,...)
 Takes a filename string, a string headear and a format string.
 
void log_OP (turnOption_OP op)
 Logs a turnOption_OP to "$STATICDIR/OPS_log.txt".
 
saveType saveTypeFrom_string (char *s)
 Takes a string and returns the corresponding saveType.
 
const char * stringFrom_HLPD_DirectionalKeys_Schema (int dks)
 Takes a integer and returns the corresponding HLPD_DirectionalKeys_Schema string by the inner array position.
 
char * stringFrom_HLPD_KeyClass (HLPD_KeyClass k)
 Takes a integer and returns the corresponding HLPD_KeyClass string by the inner array position.
 
char * stringFrom_HLP_Region_Type (HLP_Region_Type t)
 Takes a integer and returns the corresponding HLP_Region_Type string by the inner array position.
 
char * stringFrom_OP_res (OP_res r)
 Takes a OP_res and returns the corresponding string by the inner array position.
 
char * stringFrom_saveType (saveType s)
 Takes a saveType and returns the corresponding string by the inner array position.
 
char * stringFrom_fightResult (fightResult fr)
 Takes a fightResult fr and returns the corresponding string by the inner array position.
 
char * stringFromTurnOP (turnOption_OP t)
 Takes a turnOption_OP and returns the corresponding string by the inner array position.
 
char * stringFromFoeTurnOP (foeTurnOption_OP ft)
 Takes a foeTurnOption_OP and returns the corresponding string by the inner array position.
 
char * stringFromStatus (fighterStatus s)
 Takes a fighterStatus and returns the corresponding string by the inner array position.
 
char * stringFromClass (fighterClass f)
 Takes a fighterClass and returns the corresponding string by the inner array position.
 
char * stringFromEClass (enemyClass e)
 Takes a enemyClass and returns the corresponding string by the inner array position.
 
char * stringFromBossClass (bossClass b)
 Takes a bossClass and returns the corresponding string by the inner array position.
 
char * stringFromConsumables (int c)
 Takes a integer and returns the corresponding consumable string by the inner array position.
 
char * stringFromEquips (int e)
 Takes a integer and returns the corresponding equip string by the inner array position.
 
char * stringFromEquipzones (int z)
 Takes a integer and returns the corresponding equipzone string by the inner array position.
 
char * stringFromQuality (int q)
 Takes a integer and returns the corresponding quality string by the inner array position.
 
char * stringFromArtifacts (int a)
 Takes a integer and returns the corresponding artifact string by the inner array position.
 
char * stringFromFloorclass (floorClass fc)
 Takes a integer and returns the corresponding floorClass string by the inner array position.
 
char * descStringFromSpecial (fighterClass class, specialMove move)
 Takes a fighterClass and a specialMove and returns the corresponding desc string by the inner array position.
 
char * nameStringFromSpecial (fighterClass class, specialMove move)
 Takes a fighterClass and a specialMove and returns the corresponding name string by the inner array position.
 
int costFromSpecial (fighterClass class, specialMove move)
 Takes a fighterClass and a specialMove and returns the corresponding cost by the inner array position, as an integer.
 
char * descStringFromSkill (skillType class)
 Takes a fighterClass and a specialMove and returns the corresponding desc string by the inner array position.
 
char * nameStringFromSkill (skillType class)
 Takes a skillType and returns the corresponding name string by the inner array position.
 
int costFromSkill (skillType class)
 Takes a skillType and returns the corresponding cost by the inner array position, as an integer.
 
char * nameStringFromPerk (int p)
 Takes a integer and returns the corresponding perk name string by the inner array position.
 
char * descStringFromPerk (int p)
 Takes a integer and returns the corresponding perk desc string by the inner array position.
 
char * descStringFromTreasure (int t)
 Takes a integer and returns the corresponding treasure desc string by the inner array position.
 
char * descStringFromChest (int c)
 Takes a integer and returns the corresponding chest desc string by the inner array position.
 
char * stringFromWinconClass (winconClass w)
 Takes a winconClass and returns the corresponding string by the inner array position.
 
char * stringFromFoePartyClass (foePartyClass fp)
 Takes a integer and returns the corresponding FoeParty desc string by the inner array position.
 
char * stringFromRoom (roomClass r)
 Takes a integer and returns the corresponding room name string by the inner array position.
 
char * stringFromGamemode (Gamemode g)
 Takes a integer and returns the corresponding gamemode string by the inner array position.
 
void scanName (Fighter *player)
 Takes a Fighter pointer and sets its name value to the string provided on stdin.
 
void printClasses (void)
 Prints all the fighterClass values as integers and as strings.
 
int scanClass (void)
 Asks for an integer on stdin and returns it if it's a valid fighterClass index.
 
void pickClass (Fighter *player)
 Takes a Fighter pointer and sets the class value after asking the user for input.
 
void printWincons (void)
 Prints all the winconClass values as integers and as strings.
 
int scanWincon (void)
 Asks for an integer on stdin and returns it if it's a valid winconClass index.
 
void pickWincon (Wincon *w)
 Takes a Wincon pointer and sets its class after asking the user for input.
 
void pickName (Fighter *player)
 Takes a Fighter pointer and sets the name value after asking the user for input.
 
void copy_fighter (Fighter *source, Fighter *dest)
 Takes two Fighter pointers, with all their fields already allocated, and copies all valaues from source to dest.
 
effect_fun getStatusCounterFun (fighterStatus status)
 Takes a fighterStatus and returns the corresponding effect_fun pointer for the function relating to the status.
 
effect_e_fun getStatusCounterEnemyFun (fighterStatus status)
 Takes a fighterStatus and returns the corresponding effect_e_fun pointer for the function relating to the status.
 
effect_b_fun getStatusCounterBossFun (fighterStatus status)
 Takes a fighterStatus and returns the corresponding effect_e_fun pointer for the function relating to the status.
 
effect_fp_fun get_StatusCounter_FoeParty_Fun (fighterStatus status)
 
boost_fun getStatBoostCounterFun (Stat s)
 Takes a Stat and returns the corresponding boost_fun pointer for the function relating to the stat.
 
boost_e_fun getStatBoostCounterEnemyFun (Stat s)
 Takes a Stat and returns the corresponding boost_e_fun pointer for the function relating to the stat.
 
boost_b_fun getStatBoostCounterBossFun (Stat s)
 Takes a Stat and returns the corresponding boost_b_fun pointer for the function relating to the stat.
 
boost_fp_fun get_StatBoostCounter_FoeParty_Fun (Stat s)
 Takes a Stat and returns the corresponding boost_fp_fun pointer for the function relating to the stat.
 
void set_turnboost_atk (Fighter *f, int boost)
 Takes a Fighter pointer and an integer, used to set the turnboost_atk value at the pointer.
 
void set_turnboost_def (Fighter *f, int boost)
 Takes a Fighter pointer and an integer, used to set the turnboost_def value at the pointer.
 
void set_turnboost_vel (Fighter *f, int boost)
 Takes a Fighter pointer and an integer, used to set the turnboost_vel value at the pointer.
 
void set_turnboost_enr (Fighter *f, int boost)
 Takes a Fighter pointer and an integer, used to set the turnboost_enr value at the pointer.
 
void set_enemy_turnboost_atk (Enemy *e, int boost)
 Takes a Enemy pointer and an integer, used to set the turnboost_atk value at the pointer.
 
void set_enemy_turnboost_def (Enemy *e, int boost)
 Takes a Enemy pointer and an integer, used to set the turnboost_def value at the pointer.
 
void set_enemy_turnboost_vel (Enemy *e, int boost)
 Takes a Enemy pointer and an integer, used to set the turnboost_vel value at the pointer.
 
void set_enemy_turnboost_enr (Enemy *e, int boost)
 Takes a Enemy pointer and an integer, used to set the turnboost_enr value at the pointer.
 
void set_boss_turnboost_atk (Boss *b, int boost)
 Takes a Boss pointer and an integer, used to set the turnboost_atk value at the pointer.
 
void set_boss_turnboost_def (Boss *b, int boost)
 Takes a Boss pointer and an integer, used to set the turnboost_def value at the pointer.
 
void set_boss_turnboost_vel (Boss *b, int boost)
 Takes a Boss pointer and an integer, used to set the turnboost_vel value at the pointer.
 
void set_boss_turnboost_enr (Boss *b, int boost)
 Takes a Boss pointer and an integer, used to set the turnboost_enr value at the pointer.
 
void set_foeparty_turnboost_atk (FoeParty *fp, int boost)
 Takes a FoeParty pointer and an integer, used to set the turnboost_atk value at the pointer.
 
void set_foeparty_turnboost_def (FoeParty *fp, int boost)
 Takes a FoeParty pointer and an integer, used to set the turnboost_def value at the pointer.
 
void set_foeparty_turnboost_vel (FoeParty *fp, int boost)
 Takes a FoeParty pointer and an integer, used to set the turnboost_vel value at the pointer.
 
void set_foeparty_turnboost_enr (FoeParty *fp, int boost)
 Takes a FoeParty pointer and an integer, used to set the turnboost_enr value at the pointer.
 
void resetFighterStatus (Fighter *f)
 Takes a Fighter pointer and resets its status value to Normal.
 
void resetEnemyStatus (Enemy *e)
 Takes a Enemy pointer and resets its status value to Normal.
 
void resetBossStatus (Boss *b)
 Takes a Boss pointer and resets its status value to Normal.
 
void setEquipPrices (int size, int *equipPrices, Equip *equips[])
 Takes a size int and a pointer to integer array, initialises all the prices, depending on stats from the Equips array pointer.
 
void setConsumablePrices (int size, int *consumablePrices, Consumable **consumables)
 Takes a size int and a pointer to integer array, initialises all the prices.
 
void statReset (Fighter *player, int force)
 Takes a Fighter pointer and an integer used to force execution.
 
void statResetBoss (Boss *b, int force)
 Takes a Boss pointer and an integer used to force execution.
 
void statResetEnemy (Enemy *e, int force)
 Takes an Enemy pointer and an integer used to force execution.
 
int getBossBoost (int lvl, bossClass bclass)
 Takes one integer and a bossClass and returns the boost relative to the level delta with base boss stats, as an integer.
 
int getEnemyBoost (int lvl, enemyClass eclass)
 Takes one integer and an enemyClass and returns the boost relative to the level delta with base enemy stats, as an integer.
 
void resetPermboosts (Fighter *f)
 Takes a Fighter pointer and resets all of its permboost_STAT values to 0, also correctly updating the current stat values.
 
void applyPermboosts (Fighter *f)
 Takes a Fighter pointer and applies all of its permboost_STAT values by adding them to the current stat values.
 
void resetArtifactsState (Fighter *f)
 Takes a Fighter pointer and Resets the active value for each Artifact in the fighter's artifactsBag array that doesn't have an always active trait.
 
void printSpawnMessage (Enemy *e, int roomIndex, int enemyIndex)
 Takes a Enemy pointer and two integers for current room index and current enemy index, and prints the spawn message formatted.
 
int dropConsumable (Fighter *player)
 Takes a Fighter pointer value and adds a random Consumable to consumablesBag.
 
int dropArtifact (Fighter *player)
 Takes a Fighter pointer value and adds a random Artifact to artifactsBag.
 
int getConsumableQty (Fighter *f, int n)
 Takes a Fighter pointer and an integer denoting the consumableClass and returns the respective qty value from player's consumablesBag at the provided index.
 
void emptyConsumables (Fighter *player)
 Sets the qty value to 0 for all Consumable in f's consumablesBag with positive qty.
 
void emptyArtifacts (Fighter *player)
 Takes a Fighter pointer and sets the qty value to 0 and the active flag to false for all Artifacts in the fighter's artifactsBag with positive qty.
 
void emptyEquips (Fighter *player)
 Takes a Fighter pointer and, for all Equip in equipsBag field with positive qty, sets qty to 0 and frees the Equip pointer.
 
Pathrandomise_path (char *seed, Koliseo *kls, const char *path_to_savefile)
 Takes an integer seed and returns a Path pointer.
 
void printStats (Fighter *f)
 Takes a Fighter pointer and prints most of its values formatted.
 
void printEStats (Enemy *e)
 Takes a Enemy pointer and prints most of its values formatted.
 
void printConsumablesStats (Consumable *c)
 Takes a Consumable pointer and prints most of its values formatted.
 
void printArtifactStats (Artifact *a)
 Takes a Artifact pointer and prints most of its values formatted.
 
void enqueue_notification (char *text, int time, int color, RingaBuf *rb_notifications)
 Takes a RingaBuf pointer and queues the passed text to it.
 
void applyStatus (Fighter *f, RingaBuf *rb_notifications)
 Takes a RingaBuf pointer to queue notifications to, a Fighter pointer value and applies the effect pertaining to its status value.
 
void applyEStatus (Enemy *e, RingaBuf *rb_notifications)
 Takes a RingaBuf pointer to queue notifications to, a Enemy pointer value and applies the effect pertaining to its status value.
 
void applyBStatus (Boss *b, RingaBuf *rb_notifications)
 Takes a RingaBuf pointer to queue notifications to, a Boss pointer value and applies the effect pertaining to its status value.
 
void printStatusText (fighterStatus status, char *subject, int color, RingaBuf *rb_notifications)
 Takes a RingaBuf pointer to queue notifications to, a fighterStatus value and a string of who's the entity to print the respective status message.
 
void dropEquip (Fighter *player, int beast, Koliseo *kls, RingaBuf *rb_notifications)
 Takes a Fighter pointer value and an integer indicating if the drop was from a beast enemy, and adds a random Equip to the fighter's equipsBag.
 
void death (Fighter *player, loadInfo *load_info)
 Takes a Fighter and loadInfo pointers and prints fighter stats and a game over message.
 
void e_death (Enemy *e)
 Takes a Enemy pointer and frees its allocated memory.
 
void b_death (Boss *b)
 Takes a Boss pointer and frees its allocated memory.
 
void updateCounters (Turncounter *counters[], int isEnemy, Fighter *f, Enemy *e)
 Takes a Turncounter array, an integer, a Fighter pointer and an Enemy pointer.
 
void updateCounters_Boss (Turncounter *counters[], int isBoss, Fighter *f, Boss *b)
 Takes a Turncounter array, an integer, a Fighter pointer and a Boss pointer.
 
void checkremainder (Fighter *player, int xp)
 Takes a Fighter pointer and the amount of xp to add.
 
void giveXp (Fighter *player, Enemy *e)
 Takes a Fighter and a Enemy pointers and handles xp gain by fighter.
 
void giveXp_Boss (Fighter *player, Boss *b)
 Takes a Fighter and a Boss pointers and handles xp gain by fighter.
 
int getEnemyXpGain (Enemy *e)
 Takes a Enemy pointer and returns its xp gain as sum of xp field value and level.
 
int getBossXpGain (Boss *b)
 Takes a Boss pointer and returns its xp gain as sum of xp field value and level.
 
void onLevelUp (Fighter *player)
 Takes a Fighter pointer and updated its stats.
 
int getBoost (int lvl, int luck)
 Takes two integers for level to calc against and luck, and returns the boost relative to the level with luck variations, as an integer.
 
void sell_all_equips (Fighter *f, Koliseo_Temp *t_kls)
 Takes a Fighter pointer and deleted all the equips not in use, granting a payment to the Fighter balance.
 
turnOption getTurnChoice (char *ch)
 Returns the chosen option as a turnOption.
 
foeTurnOption enemyTurnPick (Enemy *e, Fighter *f)
 Returns a randomised pick as foeTurnOption.
 
foeTurnOption bossTurnPick (Boss *b, Fighter *f)
 Returns a randomised pick as foeTurnOption.
 
void quit (Fighter *p, Room *room, loadInfo *load_info, Koliseo_Temp *t_kls)
 Takes a Fighter, a Room and a loadInfo pointers, and prints fighter stats and a quitting message, before quitting the program and freeing Room.
 
void setCounter (Turncounter *c, int turns)
 Takes a Turncounter pointer and an integer.
 
void useConsumable (Fighter *f, Enemy *e, Boss *b, char *string, int isBoss)
 Takes a Fighter, an Enemy and a Boss pointers, a string denoting the consumableClass and an int for use on enemy or boss.
 
int hlpd_rand_docount (bool count)
 Wraps over rand() to update G_RNG_ADVANCEMENTS if passed flag is true.
 
int hlpd_rand (void)
 Wraps over hlpd_rand_docount() to update G_RNG_ADVANCEMENTS.
 
unsigned long hlpd_hash (unsigned char *str)
 djb2 by Dan Bernstein.
 
void gen_random_seed (char buffer[PATH_SEED_BUFSIZE+1])
 Sets the passed buffer up to be a random seed.
 
bool check_seed (char buffer[PATH_SEED_BUFSIZE])
 Checks the passed buffer as a seed.
 
void hlpd_reset_logfile (void)
 
void hlpd_use_forced_flags (const char *whoami)
 
int display_colorpairs (void)
 Runs some shell commands to see all color pairs, then returns exitcode Prints the encoded value of the passed char to the window at the coordinates.
 
int hlpd_getopt (size_t argc, char **argv, const char *whoami)
 Parse options from CLI arguments.
 

Macro Definition Documentation

◆ _POSIX_C_SOURCE

#define _POSIX_C_SOURCE   200809L

◆ hlpd_d_keyval

#define hlpd_d_keyval ( key)
Value:
((((key) >= 0) && ((key) <= HLPD_KEYCLASS_MAX)) ? (hlpd_default_keybinds[(key)].val) : -1 )
HLPD_Key hlpd_default_keybinds[HLPD_KEYCLASS_MAX+1]
Array with the keybinds for the game.
Definition game_core.c:46
#define HLPD_KEYCLASS_MAX
Maximum index of HLPD_KeyClass, so that the size has to add 1 for the 0th index.
Definition game_core.h:125
int val
Definition game_core.h:138

Function Documentation

◆ applyBStatus()

void applyBStatus ( Boss * b,
RingaBuf * rb_notifications )

Takes a RingaBuf pointer to queue notifications to, a Boss pointer value and applies the effect pertaining to its status value.

See also
Boss
fighterStatus
printStatusText()
stringFromBossClass()
Parameters
bThe Boss pointer at hand.
rb_notificationsThe RingaBuf used for notifications.

◆ applyEStatus()

void applyEStatus ( Enemy * e,
RingaBuf * rb_notifications )

Takes a RingaBuf pointer to queue notifications to, a Enemy pointer value and applies the effect pertaining to its status value.

See also
Enemy
fighterStatus
printStatusText()
stringFromEClass()
Parameters
eThe Enemy pointer at hand.
rb_notificationsThe RingaBuf used for notifications.
See also
enqueue_notification()

◆ applyPermboosts()

void applyPermboosts ( Fighter * f)

Takes a Fighter pointer and applies all of its permboost_STAT values by adding them to the current stat values.

See also
Fighter
Parameters
fThe fighter pointer whose permboosts will be applied.

◆ applyStatus()

void applyStatus ( Fighter * f,
RingaBuf * rb_notifications )

Takes a RingaBuf pointer to queue notifications to, a Fighter pointer value and applies the effect pertaining to its status value.

See also
Fighter
fighterStatus
printStatusText()
Parameters
fThe Fighter pointer at hand.
rb_notificationsThe RingaBuf pointer used for notifications.

◆ b_death()

void b_death ( Boss * b)

Takes a Boss pointer and frees its allocated memory.

The counters field is freed before the boss pointer.

See also
Boss
Parameters
bThe Boss pointer to free.

◆ blue()

void blue ( void )

Prints an ASCII escape code that makes subsequent output a thick blue color.

◆ bossTurnPick()

foeTurnOption bossTurnPick ( Boss * b,
Fighter * f )

Returns a randomised pick as foeTurnOption.

Parameters
bPointer to the boss to pick for.
fPointer to the target fighter.
Returns
The chosen foeturnOption value representing turn action.

◆ check_seed()

bool check_seed ( char buffer[PATH_SEED_BUFSIZE])

Checks the passed buffer as a seed.

Only chars >= 0, <= Z; not including the symbols between digits and letters. Notably, the passed buffer is checked by applying toupper() to each char.

Parameters
bufferThe buffer to check.
Returns
True for a valid seed.

◆ checkremainder()

void checkremainder ( Fighter * player,
int xp )

Takes a Fighter pointer and the amount of xp to add.

Current level xp is managed by this function, including how much xp is needed to level up again. The values are stored in the fighter struct. Thresholds for each level are checked and eventually onLevelUp() is called, with recursion on this function after.

See also
Fighter
onLevelUp()
Parameters
playerThe Fighter pointer that gets xp.
xpThe amount of xp.

◆ copy_fighter()

void copy_fighter ( Fighter * source,
Fighter * dest )

Takes two Fighter pointers, with all their fields already allocated, and copies all valaues from source to dest.

See also
Fighter
Parameters
sourceThe Fighter pointer to be copied.
destThe Fighter pointer to copy to.

◆ costFromSkill()

int costFromSkill ( skillType class)

Takes a skillType and returns the corresponding cost by the inner array position, as an integer.

Correct result is only possible by having the enum values in a consistent order with the integer array.

See also
fighterClass
skillType
Parameters
classThe skillType.
Returns
int Cost of the corresponding skillType.

◆ costFromSpecial()

int costFromSpecial ( fighterClass class,
specialMove move )

Takes a fighterClass and a specialMove and returns the corresponding cost by the inner array position, as an integer.

Correct result is only possible by having the enum values in a consistent order with the integer array.

See also
fighterClass
specialMove
Parameters
classThe fighterClass.
moveThe specialMove.
Returns
int Cost of the corresponding special move.

◆ cyan()

void cyan ( void )

Prints an ASCII escape code that makes subsequent output a thick cyan color.

◆ dbg_countStats()

void dbg_countStats ( countStats * stats)

Debugs the passed (preallocated) countStats with log_tag().

Parameters
statsThe allocated countStats to debug.

◆ dbg_Fighter()

void dbg_Fighter ( Fighter * fighter)

Debugs the passed (preallocated) Fighter with log_tag().

Parameters
fighterThe allocated Fighter to debug.

◆ dbg_GameOptions()

void dbg_GameOptions ( GameOptions * options)

◆ dbg_GameScreen()

void dbg_GameScreen ( GameScreen * scr)

Debugs the passed (preallocated) GameScreen with log_tag().

Parameters
scrThe allocated GameScreen to debug.

◆ dbg_Gamestate()

void dbg_Gamestate ( Gamestate * gmst)

Debugs the passed (preallocated) Gamestate with log_tag().

Parameters
gmstThe allocated Gamestate to debug.

◆ dbg_Path()

void dbg_Path ( Path * path)

Debugs the passed (preallocated) Path with log_tag().

Parameters
pathThe allocated Path to debug.

◆ dbg_print_explored_layout()

void dbg_print_explored_layout ( Floor * floor)

Logs explored layout for passed Floor.

◆ dbg_print_floor_layout()

void dbg_print_floor_layout ( Floor * floor)

Logs floor layout for passed Floor.

◆ dbg_print_roomclass_layout()

void dbg_print_roomclass_layout ( Floor * floor)

Logs roomclass layout for passed Floor.

◆ dbg_Saveslot()

void dbg_Saveslot ( Saveslot * saveslot)

Debugs the passed (preallocated) Saveslot with log_tag().

Parameters
saveslotThe allocated Saveslot to debug.

◆ dbg_Wincon()

void dbg_Wincon ( Wincon * wc)

Debugs the passed (preallocated) Wincon with log_tag().

Parameters
wcThe allocated countStats to debug.

◆ death()

void death ( Fighter * player,
loadInfo * load_info )

Takes a Fighter and loadInfo pointers and prints fighter stats and a game over message.

Consumables and Artifacts are emptied before freeing the player's specials, counters, perks and stats field. At last, the player pointer is freed.

See also
Fighter
handleStats()
emptyConsumables()
emptyArtifacts()
Parameters
playerThe Fighter pointer to free.
load_infoThe loadInfo pointer to free.

◆ descStringFromChest()

char * descStringFromChest ( int c)

Takes a integer and returns the corresponding chest desc string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
chestClass
Parameters
cThe integer/chestClass.
Returns
String corresponding to the chest desc.

◆ descStringFromPerk()

char * descStringFromPerk ( int p)

Takes a integer and returns the corresponding perk desc string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
perkClass
Perk
Parameters
pThe integer/perkClass.
Returns
String corresponding to the perk desc.

◆ descStringFromSkill()

char * descStringFromSkill ( skillType class)

Takes a fighterClass and a specialMove and returns the corresponding desc string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
fighterClass
skillType
Parameters
classThe skillType.
Returns
String corresponding to the skillType.

◆ descStringFromSpecial()

char * descStringFromSpecial ( fighterClass class,
specialMove move )

Takes a fighterClass and a specialMove and returns the corresponding desc string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
fighterClass
specialMove
Parameters
classThe fighterClass.
moveThe specialMove.
Returns
String corresponding to the special move.

◆ descStringFromTreasure()

char * descStringFromTreasure ( int t)

Takes a integer and returns the corresponding treasure desc string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
treasureClass
Parameters
tThe integer/treasureClass.
Returns
String corresponding to the treasure desc.

◆ display_colorpairs()

int display_colorpairs ( void )

Runs some shell commands to see all color pairs, then returns exitcode Prints the encoded value of the passed char to the window at the coordinates.

◆ dropArtifact()

int dropArtifact ( Fighter * player)

Takes a Fighter pointer value and adds a random Artifact to artifactsBag.

The Artifact is randomised according to ARTIFACTSMAX until one which was not found yet drops. Special Equip functions are also set up here.

See also
Fighter
Artifact
artifactClass
stringFromArtifacts()
Parameters
playerThe Fighter pointer at hand.
Returns
int Returns the enum value of the drop as an integer.

◆ dropConsumable()

int dropConsumable ( Fighter * player)

Takes a Fighter pointer value and adds a random Consumable to consumablesBag.

See also
Fighter
Consumable
consumableClass
CONSUMABLESMAX
stringFromConsumables()
Parameters
playerThe Fighter pointer at hand.
Returns
int Returns the enum value of the drop as an integer.

◆ dropEquip()

void dropEquip ( Fighter * player,
int beast,
Koliseo * kls,
RingaBuf * rb_notifications )

Takes a Fighter pointer value and an integer indicating if the drop was from a beast enemy, and adds a random Equip to the fighter's equipsBag.

Prints notifications to the passed RingaBuf pointer. The Equip dropped is initalised here, including stat variations for quality and level boosts (stat increase from base level by adding player level over EQUIPLVLBOOSTRATIO. The values of earliestBagSlot and equipsBagOccupiedSlots are managed. If equipsBag is full (EQUIPSBAGSIZE), user has to choose one Equip not currently equipped to be deleted and replaced by the new one. Special Equip functions are also set up here.

See also
Fighter
Equip
equipClass
quality
EQUIPLVLBOOSTRATIO
EQUIPSBAGSIZE
stringFromQuality()
stringFromEquips()
Parameters
playerThe Fighter pointer at hand.
beastThe integer for drops coming from a beast kill if true.
klsThe Koliseo used for allocations.
rb_notificationsThe RingaBuf used for notifications.

◆ e_death()

void e_death ( Enemy * e)

Takes a Enemy pointer and frees its allocated memory.

The counters field is freed before the enemy pointer.

See also
Enemy
Parameters
eThe Enemy pointer to free.

◆ emptyArtifacts()

void emptyArtifacts ( Fighter * f)

Takes a Fighter pointer and sets the qty value to 0 and the active flag to false for all Artifacts in the fighter's artifactsBag with positive qty.

See also
Artifact
artifactClass
ARTIFACTSMAX
Parameters
fThe Fighter pointer at hand.

◆ emptyConsumables()

void emptyConsumables ( Fighter * f)

Sets the qty value to 0 for all Consumable in f's consumablesBag with positive qty.

See also
Consumable
consumableClass
CONSUMABLESMAX
getConsumableQty()
Parameters
fThe Fighter pointer at hand.

◆ emptyEquips()

void emptyEquips ( Fighter * player)

Takes a Fighter pointer and, for all Equip in equipsBag field with positive qty, sets qty to 0 and frees the Equip pointer.

See also
Fighter
Equip
Parameters
playerThe fighter pointer whose equipsbag will be emptied.

◆ enemyTurnPick()

foeTurnOption enemyTurnPick ( Enemy * e,
Fighter * f )

Returns a randomised pick as foeTurnOption.

Parameters
ePointer to the enemy to pick for.
fPointer to the target fighter.
Returns
The chosen foeturnOption value representing turn action.

◆ enqueue_notification()

void enqueue_notification ( char * text,
int time,
int color,
RingaBuf * rb_notifications )

Takes a RingaBuf pointer and queues the passed text to it.

See also
handleRoom_Enemies()
handleRoom_Boss()
Parameters
textThe contents of the notification.
timeThe display time in milliseconds (unused, for now)
colorThe index of color to use for the notification drawing.
rb_notificationsThe Ringabuf to push the notification to.

◆ freeRoom()

void freeRoom ( Room * room)

Frees the memory allocated for the passed room pointer.

Parameters
roomThe Room pointer to free.
See also
Room

◆ gen_random_seed()

void gen_random_seed ( char buffer[PATH_SEED_BUFSIZE+1])

Sets the passed buffer up to be a random seed.

Only chars >= 0, <= Z; not including the symbols between digits and letters.

Parameters
bufferThe buffer to set.

◆ get_StatBoostCounter_FoeParty_Fun()

boost_fp_fun get_StatBoostCounter_FoeParty_Fun ( Stat s)

Takes a Stat and returns the corresponding boost_fp_fun pointer for the function relating to the stat.

See also
Stat
boost_fp_fun
Parameters
sThe Stat that the caller needs to match to a boost_fp_fun pointer.
Returns
The boost_fp_fun pointer related to the stat.

◆ get_StatusCounter_FoeParty_Fun()

effect_fp_fun get_StatusCounter_FoeParty_Fun ( fighterStatus status)

◆ getBoost()

int getBoost ( int lvl,
int luck )

Takes two integers for level to calc against and luck, and returns the boost relative to the level with luck variations, as an integer.

At level 1, returns 0.

Parameters
lvlThe level to check the boost against.
luckThe luck value to influence calcs.
Returns
int The boost for any given stat, at the level passed as argument.

◆ getBossBoost()

int getBossBoost ( int lvl,
bossClass bclass )

Takes one integer and a bossClass and returns the boost relative to the level delta with base boss stats, as an integer.

The EnemyBossStats pointer for the boss's bossClass is loaded. If the boost is negative, returns 0.

See also
Boss
bossClass
BossBaseStats
Parameters
lvlThe level to check the boost against.
bclassThe bossClass used to determine base level.
Returns
int The boost for any given stat, at the level passed as argument.

◆ getBossXpGain()

int getBossXpGain ( Boss * b)

Takes a Boss pointer and returns its xp gain as sum of xp field value and level.

See also
Boss
Parameters
bThe Boss pointer.
Returns
int The xp gain.

◆ getConsumableQty()

int getConsumableQty ( Fighter * f,
int n )

Takes a Fighter pointer and an integer denoting the consumableClass and returns the respective qty value from player's consumablesBag at the provided index.

See also
Fighter
Consumable
consumableClass
Parameters
fThe Fighter pointer.
nThe consumableClass value.
Returns
int The qty value in consumablesBag for selected consumableClass.

◆ getEnemyBoost()

int getEnemyBoost ( int lvl,
enemyClass eclass )

Takes one integer and an enemyClass and returns the boost relative to the level delta with base enemy stats, as an integer.

The EnemyBaseStats pointer for the enemy's enemyClass is loaded. If the boost is negative, returns 0.

See also
Enemy
enemyClass
EnemyBaseStats
Parameters
lvlThe level to check the boost against.
eclassThe enemyClass used to determine base level.
Returns
int The boost for any given stat, at the level passed as argument.

◆ getEnemyXpGain()

int getEnemyXpGain ( Enemy * e)

Takes a Enemy pointer and returns its xp gain as sum of xp field value and level.

See also
Enemy
Parameters
eThe Enemy pointer.
Returns
int The xp gain.

◆ getStatBoostCounterBossFun()

boost_b_fun getStatBoostCounterBossFun ( Stat s)

Takes a Stat and returns the corresponding boost_b_fun pointer for the function relating to the stat.

See also
Stat
boost_b_fun
Parameters
sThe Stat that the caller needs to match to a boost_b_fun pointer.
Returns
The boost_b_fun pointer related to the stat.

◆ getStatBoostCounterEnemyFun()

boost_e_fun getStatBoostCounterEnemyFun ( Stat s)

Takes a Stat and returns the corresponding boost_e_fun pointer for the function relating to the stat.

See also
Stat
boost_e_fun
Parameters
sThe Stat that the caller needs to match to a boost_e_fun pointer.
Returns
The boost_e_fun pointer related to the stat.

◆ getStatBoostCounterFun()

boost_fun getStatBoostCounterFun ( Stat s)

Takes a Stat and returns the corresponding boost_fun pointer for the function relating to the stat.

See also
Stat
boost_fun
Parameters
sThe Stat that the caller needs to match to a boost_fun pointer.
Returns
The boost_fun pointer related to the stat.

◆ getStatusCounterBossFun()

effect_b_fun getStatusCounterBossFun ( fighterStatus status)

Takes a fighterStatus and returns the corresponding effect_e_fun pointer for the function relating to the status.

See also
fighterStatus
effect_e_fun
Parameters
statusThe fighterStatus that the caller needs to match to a effect_e_fun pointer.
Returns
The effect_e_fun pointer related to the status.

◆ getStatusCounterEnemyFun()

effect_e_fun getStatusCounterEnemyFun ( fighterStatus status)

Takes a fighterStatus and returns the corresponding effect_e_fun pointer for the function relating to the status.

See also
fighterStatus
effect_e_fun
Parameters
statusThe fighterStatus that the caller needs to match to a effect_e_fun pointer.
Returns
The effect_e_fun pointer related to the status.

◆ getStatusCounterFun()

effect_fun getStatusCounterFun ( fighterStatus status)

Takes a fighterStatus and returns the corresponding effect_fun pointer for the function relating to the status.

See also
fighterStatus
effect_fun
Parameters
statusThe fighterStatus that the caller needs to match to a effect_fun pointer.
Returns
The effect_fun pointer related to the status.

◆ getTurnChoice()

turnOption getTurnChoice ( char * ch)

Returns the chosen option as a turnOption.

Parameters
chA string representing the turn choice.
Returns
The chosen turnOption value representing turn action.

◆ giveXp()

void giveXp ( Fighter * player,
Enemy * e )

Takes a Fighter and a Enemy pointers and handles xp gain by fighter.

See also
Fighter
Enemy
getEnemyXpGain()
checkremainder()
Parameters
playerThe Fighter pointer that gets xp.
eThe Enemy pointer that gives xp.

◆ giveXp_Boss()

void giveXp_Boss ( Fighter * player,
Boss * b )

Takes a Fighter and a Boss pointers and handles xp gain by fighter.

See also
Fighter
Boss
getBossXpGain()
checkremainder()
Parameters
playerThe Fighter pointer that gets xp.
bThe Boss pointer that gives xp.

◆ green()

void green ( void )

Prints an ASCII escape code that makes subsequent output a thick green color.

◆ hlpd_dbg_features()

void hlpd_dbg_features ( void )

Prints configuration info.

◆ hlpd_getopt()

int hlpd_getopt ( size_t argc,
char ** argv,
const char * whoami )

Parse options from CLI arguments.

Parameters
argcargc from main
argvargv from main
whoamiName used by the program
Returns
The value of "optind" at the end of the routine.

◆ hlpd_hash()

unsigned long hlpd_hash ( unsigned char * str)

djb2 by Dan Bernstein.

See: http://www.cse.yorku.ca/~oz/hash.html https://stackoverflow.com/questions/7666509/hash-function-for-string

Parameters
strThe string to hash.
Returns
The resulting hash.

◆ hlpd_rand()

int hlpd_rand ( void )

Wraps over hlpd_rand_docount() to update G_RNG_ADVANCEMENTS.

See also
G_RNG_ADVANCEMENTS
hlpd_rand_docount()
Returns
A random integer from hlpd_rand_docount().

◆ hlpd_rand_docount()

int hlpd_rand_docount ( bool count)

Wraps over rand() to update G_RNG_ADVANCEMENTS if passed flag is true.

See also
G_RNG_ADVANCEMENTS
rand()
Parameters
countWhen true, advance G_RNG_ADVANCEMENTS.
Returns
A random integer from rand().

◆ hlpd_reset_logfile()

void hlpd_reset_logfile ( void )

◆ hlpd_sigint_handler()

void hlpd_sigint_handler ( int signum)

Function to handle Ctrl+C signal.

See also
SIGINT
Parameters
signumThe signal number, expected to be SIGINT.

◆ hlpd_use_forced_flags()

void hlpd_use_forced_flags ( const char * whoami)

◆ init_game_color_pairs()

void init_game_color_pairs ( void )

◆ initWincon()

void initWincon ( Wincon * w,
Path * p,
winconClass class )

Takes a Wincon and a Path pointers and a winconClass and initialises the passed Wincon.

See also
Wincon
Path
winconClass
WINCON_CLASS_MAX
Parameters
wThe Wincon pointer to initialise.
pThe Path to use to initialise Wincon.
classThe winconClass to use to initialise.

◆ lightBlue()

void lightBlue ( void )

Prints an ASCII escape code that makes subsequent output a light blue color.

◆ lightCyan()

void lightCyan ( void )

Prints an ASCII escape code that makes subsequent output a light cyan color.

◆ lightGreen()

void lightGreen ( void )

Prints an ASCII escape code that makes subsequent output a light green color.

◆ lightPurple()

void lightPurple ( void )

Prints an ASCII escape code that makes subsequent output a light purple color.

◆ lightRed()

void lightRed ( void )

Prints an ASCII escape code that makes subsequent output a light red color.

◆ lightYellow()

void lightYellow ( void )

Prints an ASCII escape code that makes subsequent output a light yellow color.

◆ loadLore()

void loadLore ( char ** lore_strings,
int loreKind )

Loads the lore strings from the appropriate lore file.

Parameters
lore_stringsThe string array to copy to.
loreKindThe kind of lore, used to open the corresponding lore file.
See also
gameloop()

◆ log_OP()

void log_OP ( turnOption_OP op)

Logs a turnOption_OP to "$STATICDIR/OPS_log.txt".

Parameters
opThe turnOption_OP to log.

◆ log_tag()

void log_tag ( char * filename,
char * header,
const char * format,
... )

Takes a filename string, a string headear and a format string.

Tries logging the message to the passed file if global var G_DEBUG_ON is set.

Parameters
filenameThe filename to open.
headerThe string header for the message to log.
formatThe format string for message.

◆ nameStringFromPerk()

char * nameStringFromPerk ( int p)

Takes a integer and returns the corresponding perk name string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
perkClass
Perk
Parameters
pThe integer/perkClass.
Returns
String corresponding to the perk name.

◆ nameStringFromSkill()

char * nameStringFromSkill ( skillType class)

Takes a skillType and returns the corresponding name string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
fighterClass
specialMove
Parameters
classThe skillType.
Returns
String corresponding to the skillType.

◆ nameStringFromSpecial()

char * nameStringFromSpecial ( fighterClass class,
specialMove move )

Takes a fighterClass and a specialMove and returns the corresponding name string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
fighterClass
specialMove
Parameters
classThe fighterClass.
moveThe specialMove.
Returns
String corresponding to the special move.

◆ onLevelUp()

void onLevelUp ( Fighter * player)

Takes a Fighter pointer and updated its stats.

getBoost() is called to get the stat boost for current level, which is then applyed to atk, def and vel; while hp gets first multiplied by 1.13 and then gets the boost added. The totalenergy value is increased by player level over 5. Hp and energy are replenished. If the level is multiple of SPECIALLVLRATIO and the player still has at least one SpecialSlot not enabled, unlockSpecial() is called.

See also
Fighter
getBoost()
BaseStats
SpecialSlot
SPECIALSMAX
SPECIALLVLRATIO
unlockSpecial()
Parameters
playerThe Fighter pointer that levels up.

◆ pickClass()

void pickClass ( Fighter * player)

Takes a Fighter pointer and sets the class value after asking the user for input.

See also
fighterClass
scanClass()
Parameters
playerThe pointer whose class value will be set.

◆ pickName()

void pickName ( Fighter * player)

Takes a Fighter pointer and sets the name value after asking the user for input.

See also
fighterClass
scanName()
Parameters
playerThe pointer whose name value will be set.

◆ pickWincon()

void pickWincon ( Wincon * w)

Takes a Wincon pointer and sets its class after asking the user for input.

See also
winconClass
scanWincon()
Parameters
wThe wincon pointer whose class value will be set.

◆ printArtifactStats()

void printArtifactStats ( Artifact * a)

Takes a Artifact pointer and prints most of its values formatted.

See also
Artifact
Parameters
aThe Artifact pointer with stats to print.

◆ printClasses()

void printClasses ( void )

Prints all the fighterClass values as integers and as strings.

See also
fighterClass

◆ printConsumablesStats()

void printConsumablesStats ( Consumable * c)

Takes a Consumable pointer and prints most of its values formatted.

See also
Consumable
Parameters
cThe Consumable pointer with stats to print.

◆ printEStats()

void printEStats ( Enemy * e)

Takes a Enemy pointer and prints most of its values formatted.

See also
Enemy
stringFromEClass()
stringFromStatus()
Parameters
eThe Enemy pointer with stats to print.

◆ printFormattedVersion()

void printFormattedVersion ( const char * progname)

Prints formatted version string.

Parameters
prognameThe program name string.

◆ printGlobVars()

void printGlobVars ( void )

Prints global vars to stdout.

◆ printSpawnMessage()

void printSpawnMessage ( Enemy * e,
int roomIndex,
int enemyIndex )

Takes a Enemy pointer and two integers for current room index and current enemy index, and prints the spawn message formatted.

See also
Enemy
stringFromEClass()
Parameters
eThe Enemy pointer to print.
roomIndexThe index of current room.
enemyIndexThe index of current enemy.

◆ printStats()

void printStats ( Fighter * f)

Takes a Fighter pointer and prints most of its values formatted.

See also
Fighter
stringFromClass()
stringFromStatus()
Parameters
fThe Fighter pointer with stats to print.

◆ printStatusText()

void printStatusText ( fighterStatus status,
char * subject,
int color,
RingaBuf * rb_notifications )

Takes a RingaBuf pointer to queue notifications to, a fighterStatus value and a string of who's the entity to print the respective status message.

See also
fighterStatus
Parameters
statusThe fighterStatus at hand.
subjectA string with name of entity owning the fighterStatus.
colorThe color to use for the notification.
rb_notificationsThe RingaBuf used for notifications.

◆ printTitle()

void printTitle ( void )

Prints an hardcoded title screen.

See also
helapordo_title_string

◆ printVersion()

void printVersion ( void )

Prints version string.

◆ printWincons()

void printWincons ( void )

Prints all the winconClass values as integers and as strings.

See also
winconClass

◆ purple()

void purple ( void )

Prints an ASCII escape code that makes subsequent output a thick purple color.

◆ quit()

void quit ( Fighter * p,
Room * room,
loadInfo * load_info,
Koliseo_Temp * t_kls )

Takes a Fighter, a Room and a loadInfo pointers, and prints fighter stats and a quitting message, before quitting the program and freeing Room.

See also
Fighter
printStats()
death()
Parameters
pThe Fighter pointer at hand.
roomThe Room pointer at hand.
load_infoThe loadInfo pointer at hand.
t_klsThe Koliseo_Temp to end if possible.

◆ randomise_path()

Path * randomise_path ( char * seed,
Koliseo * kls,
const char * path_to_savefile )

Takes an integer seed and returns a Path pointer.

The seed provided is used to set the random seed and initialise the path values.

See also
Path
MAXLENGTH
MAXLUCK
Parameters
seedA string seed.
klsThe Koliseo used for allocation.
path_to_savefilePath to savefile.
Returns
A Path pointer with stats.

◆ red()

void red ( void )

Prints an ASCII escape code that makes subsequent output a thick red color.

◆ resetArtifactsState()

void resetArtifactsState ( Fighter * f)

Takes a Fighter pointer and Resets the active value for each Artifact in the fighter's artifactsBag array that doesn't have an always active trait.

At the moment, this only excludes CHAOSORB.

See also
Artifact
artifactClass
Fighter

◆ resetBossStatus()

void resetBossStatus ( Boss * b)

Takes a Boss pointer and resets its status value to Normal.

See also
Boss
fighterStatus
Parameters
bThe pointer whose status value will be reset.

◆ resetEnemyStatus()

void resetEnemyStatus ( Enemy * e)

Takes a Enemy pointer and resets its status value to Normal.

See also
Enemy
fighterStatus
Parameters
eThe pointer whose status value will be reset.

◆ resetFighterStatus()

void resetFighterStatus ( Fighter * f)

Takes a Fighter pointer and resets its status value to Normal.

See also
Fighter
fighterStatus
Parameters
fThe pointer whose status value will be reset.

◆ resetPermboosts()

void resetPermboosts ( Fighter * f)

Takes a Fighter pointer and resets all of its permboost_STAT values to 0, also correctly updating the current stat values.

See also
Fighter
Parameters
fThe fighter pointer whose permboosts will be reset.

◆ resolve_staticPath()

void resolve_staticPath ( char static_path[500])

Sets the passed char array to the expected path for /static/ folder.

Parameters
static_pathThe array that will hold path to static folder.

◆ s4c_gui_calloc()

void * s4c_gui_calloc ( size_t count,
size_t size )

◆ s4c_gui_malloc()

void * s4c_gui_malloc ( size_t size)

◆ saveTypeFrom_string()

saveType saveTypeFrom_string ( char * s)

Takes a string and returns the corresponding saveType.

Will return -1 if no match is found.

Parameters
sThe string to convert.

◆ scanClass()

int scanClass ( void )

Asks for an integer on stdin and returns it if it's a valid fighterClass index.

See also
fighterClass
CLASSESMAX
Returns
The selected integer, negative for unvalid choices.

◆ scanName()

void scanName ( Fighter * player)

Takes a Fighter pointer and sets its name value to the string provided on stdin.

Parameters
playerThe pointer whose name value will be set.

◆ scanWincon()

int scanWincon ( void )

Asks for an integer on stdin and returns it if it's a valid winconClass index.

See also
winconClass
WINCON_CLASS_MAX
Returns
The selected integer, negative for unvalid choices.

◆ sell_all_equips()

void sell_all_equips ( Fighter * f,
Koliseo_Temp * t_kls )

Takes a Fighter pointer and deleted all the equips not in use, granting a payment to the Fighter balance.

See also
Shop
handleRoom_Shop()
Fighter
Parameters
fThe Fighter pointer at hand.
t_klsThe Koliseo_Temp used for temp allocations.

◆ set_boss_turnboost_atk()

void set_boss_turnboost_atk ( Boss * b,
int boost )

Takes a Boss pointer and an integer, used to set the turnboost_atk value at the pointer.

See also
Boss
Turncounter
Parameters
bThe Boss pointer whose turnboost_atk value will be set.
boostThe value that will be set.

◆ set_boss_turnboost_def()

void set_boss_turnboost_def ( Boss * b,
int boost )

Takes a Boss pointer and an integer, used to set the turnboost_def value at the pointer.

See also
Boss
Turncounter
Parameters
bThe Boss pointer whose turnboost_def value will be set.
boostThe value that will be set.

◆ set_boss_turnboost_enr()

void set_boss_turnboost_enr ( Boss * b,
int boost )

Takes a Boss pointer and an integer, used to set the turnboost_enr value at the pointer.

See also
Boss
Turncounter
Parameters
bThe Boss pointer whose turnboost_enr value will be set.
boostThe value that will be set.

◆ set_boss_turnboost_vel()

void set_boss_turnboost_vel ( Boss * b,
int boost )

Takes a Boss pointer and an integer, used to set the turnboost_vel value at the pointer.

See also
Boss
Turncounter
Parameters
bThe Boss pointer whose turnboost_vel value will be set.
boostThe value that will be set.

◆ set_enemy_turnboost_atk()

void set_enemy_turnboost_atk ( Enemy * e,
int boost )

Takes a Enemy pointer and an integer, used to set the turnboost_atk value at the pointer.

See also
Enemy
Turncounter
Parameters
eThe Enemy pointer whose turnboost_atk value will be set.
boostThe value that will be set.

◆ set_enemy_turnboost_def()

void set_enemy_turnboost_def ( Enemy * e,
int boost )

Takes a Enemy pointer and an integer, used to set the turnboost_def value at the pointer.

See also
Enemy
Turncounter
Parameters
eThe Enemy pointer whose turnboost_def value will be set.
boostThe value that will be set.

◆ set_enemy_turnboost_enr()

void set_enemy_turnboost_enr ( Enemy * e,
int boost )

Takes a Enemy pointer and an integer, used to set the turnboost_enr value at the pointer.

See also
Enemy
Turncounter
Parameters
eThe Enemy pointer whose turnboost_enr value will be set.
boostThe value that will be set.

◆ set_enemy_turnboost_vel()

void set_enemy_turnboost_vel ( Enemy * e,
int boost )

Takes a Enemy pointer and an integer, used to set the turnboost_vel value at the pointer.

See also
Enemy
Turncounter
Parameters
eThe Enemy pointer whose turnboost_vel value will be set.
boostThe value that will be set.

◆ set_foeparty_turnboost_atk()

void set_foeparty_turnboost_atk ( FoeParty * fp,
int boost )

Takes a FoeParty pointer and an integer, used to set the turnboost_atk value at the pointer.

See also
FoeParty
Turncounter
Parameters
fpThe FoeParty pointer whose turnboost_atk value will be set.
boostThe value that will be set.

◆ set_foeparty_turnboost_def()

void set_foeparty_turnboost_def ( FoeParty * fp,
int boost )

Takes a FoeParty pointer and an integer, used to set the turnboost_def value at the pointer.

See also
FoeParty
Turncounter
Parameters
fpThe FoeParty pointer whose turnboost_def value will be set.
boostThe value that will be set.

◆ set_foeparty_turnboost_enr()

void set_foeparty_turnboost_enr ( FoeParty * fp,
int boost )

Takes a FoeParty pointer and an integer, used to set the turnboost_enr value at the pointer.

See also
FoeParty
Turncounter
Parameters
fpThe FoeParty pointer whose turnboost_enr value will be set.
boostThe value that will be set.

◆ set_foeparty_turnboost_vel()

void set_foeparty_turnboost_vel ( FoeParty * fp,
int boost )

Takes a FoeParty pointer and an integer, used to set the turnboost_vel value at the pointer.

See also
FoeParty
Turncounter
Parameters
fpThe FoeParty pointer whose turnboost_vel value will be set.
boostThe value that will be set.

◆ set_turnboost_atk()

void set_turnboost_atk ( Fighter * f,
int boost )

Takes a Fighter pointer and an integer, used to set the turnboost_atk value at the pointer.

See also
Fighter
Turncounter
Parameters
fThe Fighter pointer whose turnboost_atk value will be set.
boostThe value that will be set.

◆ set_turnboost_def()

void set_turnboost_def ( Fighter * f,
int boost )

Takes a Fighter pointer and an integer, used to set the turnboost_def value at the pointer.

See also
Fighter
Turncounter
Parameters
fThe Fighter pointer whose turnboost_def value will be set.
boostThe value that will be set.

◆ set_turnboost_enr()

void set_turnboost_enr ( Fighter * f,
int boost )

Takes a Fighter pointer and an integer, used to set the turnboost_enr value at the pointer.

See also
Fighter
Turncounter
Parameters
fThe Fighter pointer whose turnboost_enr value will be set.
boostThe value that will be set.

◆ set_turnboost_vel()

void set_turnboost_vel ( Fighter * f,
int boost )

Takes a Fighter pointer and an integer, used to set the turnboost_vel value at the pointer.

See also
Fighter
Turncounter
Parameters
fThe Fighter pointer whose turnboost_vel value will be set.
boostThe value that will be set.

◆ setConsumablePrices()

void setConsumablePrices ( int size,
int * consumablePrices,
Consumable ** consumables )

Takes a size int and a pointer to integer array, initialises all the prices.

See also
initShop()
Parameters
sizeSize of both arrays.
consumablePricesPointer to integer array for prices.
consumablesPointer to Consumable pointer to influence pricing.

◆ setCounter()

void setCounter ( Turncounter * c,
int turns )

Takes a Turncounter pointer and an integer.

If the count value at the pointer is 0 (counter is inactive), the turns valueis assigned.

See also
Turncounter
Parameters
cThe Turncounter whose count value will be set.
turnsThe value to be assigned.

◆ setEquipPrices()

void setEquipPrices ( int size,
int * equipPrices,
Equip * equips[] )

Takes a size int and a pointer to integer array, initialises all the prices, depending on stats from the Equips array pointer.

See also
initShop()
Equip
Parameters
sizeSize of both arrays.
equipPricesPointer to integer array for prices.
equipsPointer to Equip pointer to influence pricing.

◆ setRoomType()

void setRoomType ( Path * path,
int * roadFork_value,
roomClass * room_type,
int roomsDone )

Takes a path pointer, a roadFork value pointer, a room type pointer, and an integer.

Depending on GAMEMODE (and eventually roadFork value), sets the room type pointer to a roomClass value.

Parameters
pathPointer to Path.
roadFork_valueThe pointer value of the roadfork that we must use as result.
room_typeThe pointer value of the room type to set.
roomsDoneThe total of rooms completed.

◆ statReset()

void statReset ( Fighter * player,
int force )

Takes a Fighter pointer and an integer used to force execution.

If the force parameter is true, all checks are ignored. If enemy's hp value is at least 50% of total, and none of atk, def or vel is 0 or less, nothing happens with an early return. Otherwise, getBoost() is called to calc the level stat boost for each stat. The BaseStats pointer for the fighter's fighterClass is loaded and each one of atk, def and vel is checked accounting for level boost. If none of them is below the respective treshold of 35, 18 and 30 % of total, nothing happens. Otherwise, all of them are reset to full amount accounting for permboosts and level boost.

See also
Fighter
fighterClass
getBoost()
Parameters
playerThe Fighter pointer to check the stats for.
forceThe integer to bypass all checks if true.

◆ statResetBoss()

void statResetBoss ( Boss * b,
int force )

Takes a Boss pointer and an integer used to force execution.

If the force parameter is true, all checks are ignored. If boss's hp value is at least 40% of total, and none of atk, def or vel is 0 or less, nothing happens with an early return. Otherwise, getBossBoost() is called to calc the level stat boost for each stat. The BossBaseStats pointer for the boss's bossClass is loaded and each one of atk, def and vel is checked accounting for level boost. If none of them is below the respective treshold of 30, 30 and 20 % of total, nothing happens. Otherwise, all of them are reset to full amount accounting for beast boost and level boost.

See also
Boss
bossClass
getBossBoost()
BSTFACTOR
BossBaseStats
Parameters
bThe Boss pointer to check the stats for.
forceThe integer to bypass all checks if true.

◆ statResetEnemy()

void statResetEnemy ( Enemy * e,
int force )

Takes an Enemy pointer and an integer used to force execution.

If the force parameter is true, all checks are ignored. If enemy's hp value is at least 40% of total, and none of atk, def or vel is 0 or less, nothing happens with an early return. Otherwise, getEnemyBoost() is called to calc the level stat boost for each stat. The EnemyBaseStats pointer for the enemy's enemyClass is loaded and each one of atk, def and vel is checked accounting for level boost. If none of them is below the respective treshold of 30, 30 and 20 % of total, nothing happens. Otherwise, all of them are reset to full amount accounting for beast boost and level boost.

See also
Enemy
enemyClass
getEnemyBoost()
BSTFACTOR
EnemyBaseStats
Parameters
eThe Enemy pointer to check the stats for.
forceThe integer to bypass all checks if true.

◆ stringFrom_fightResult()

char * stringFrom_fightResult ( fightResult fr)

Takes a fightResult fr and returns the corresponding string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
fightResult
Parameters
frThe fight result value.
Returns
String corresponding to the fight result value.

◆ stringFrom_HLP_Region_Type()

char * stringFrom_HLP_Region_Type ( HLP_Region_Type t)

Takes a integer and returns the corresponding HLP_Region_Type string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
HLP_Region_Type
Parameters
tThe HLP type.
Returns
String corresponding to the HLP_Region_Type name.

◆ stringFrom_HLPD_DirectionalKeys_Schema()

const char * stringFrom_HLPD_DirectionalKeys_Schema ( int dks)

Takes a integer and returns the corresponding HLPD_DirectionalKeys_Schema string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
HLPD_DirectionalKeys_Schema
Parameters
dksThe integer/HLPD_DirectionalKeys_Schema.
Returns
String corresponding to the HLPD_DirectionalKeys_Schema.

◆ stringFrom_HLPD_KeyClass()

char * stringFrom_HLPD_KeyClass ( HLPD_KeyClass k)

Takes a integer and returns the corresponding HLPD_KeyClass string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
HLPD_KeyClass
Parameters
kThe integer/HLPD_KeyClass.
Returns
String corresponding to the HLPD_KeyClass.

◆ stringFrom_OP_res()

char * stringFrom_OP_res ( OP_res r)

Takes a OP_res and returns the corresponding string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
OP_res
Parameters
rThe OP_res.
Returns
String corresponding to the OP result.

◆ stringFrom_saveType()

char * stringFrom_saveType ( saveType s)

Takes a saveType and returns the corresponding string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
saveType
Parameters
sThe saveType value.
Returns
String corresponding to the save type.

◆ stringFromArtifacts()

char * stringFromArtifacts ( int a)

Takes a integer and returns the corresponding artifact string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
artifactClass
Parameters
aThe integer/artifactClass.
Returns
String corresponding to the artifact.

◆ stringFromBossClass()

char * stringFromBossClass ( bossClass b)

Takes a bossClass and returns the corresponding string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
bossClass
Parameters
bThe class.
Returns
String corresponding to the class.

◆ stringFromClass()

char * stringFromClass ( fighterClass f)

Takes a fighterClass and returns the corresponding string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
fighterClass
Parameters
fThe class.
Returns
String corresponding to the class.

◆ stringFromConsumables()

char * stringFromConsumables ( int c)

Takes a integer and returns the corresponding consumable string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
consumableClass
Parameters
cThe integer/consumableClass.
Returns
String corresponding to the consumable.

◆ stringFromEClass()

char * stringFromEClass ( enemyClass e)

Takes a enemyClass and returns the corresponding string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
enemyClass
Parameters
eThe class.
Returns
String corresponding to the class.

◆ stringFromEquips()

char * stringFromEquips ( int e)

Takes a integer and returns the corresponding equip string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
equipClass
Parameters
eThe integer/equipClass.
Returns
String corresponding to the equip.

◆ stringFromEquipzones()

char * stringFromEquipzones ( int z)

Takes a integer and returns the corresponding equipzone string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
Equipzone
Parameters
zThe integer/Equipzone.
Returns
String corresponding to the equipzone.

◆ stringFromFloorclass()

char * stringFromFloorclass ( floorClass fc)

Takes a integer and returns the corresponding floorClass string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
floorClass
Parameters
fcThe integer/floorClass.
Returns
String corresponding to the floorClass.

◆ stringFromFoePartyClass()

char * stringFromFoePartyClass ( foePartyClass fp)

Takes a integer and returns the corresponding FoeParty desc string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
foePartyClass
Parameters
fpThe integer/foePartyClass.
Returns
String corresponding to the FoeParty desc.

◆ stringFromFoeTurnOP()

char * stringFromFoeTurnOP ( foeTurnOption_OP ft)

Takes a foeTurnOption_OP and returns the corresponding string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
foeTurnOption_OP
Parameters
ftThe turn choice.
Returns
String corresponding to the turn choice.

◆ stringFromGamemode()

char * stringFromGamemode ( Gamemode g)

Takes a integer and returns the corresponding gamemode string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
Gamemode
Parameters
gThe integer/Gamemode.
Returns
String corresponding to the gamemode.

◆ stringFromQuality()

char * stringFromQuality ( int q)

Takes a integer and returns the corresponding quality string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
quality
Parameters
qThe integer/quality
Returns
String corresponding to the quality.

◆ stringFromRoom()

char * stringFromRoom ( roomClass r)

Takes a integer and returns the corresponding room name string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
roomClass
Parameters
rThe integer/roomClass.
Returns
String corresponding to the room name.

◆ stringFromStatus()

char * stringFromStatus ( fighterStatus s)

Takes a fighterStatus and returns the corresponding string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
fighterStatus
Parameters
sThe status.
Returns
String corresponding to the status.

◆ stringFromTurnOP()

char * stringFromTurnOP ( turnOption_OP t)

Takes a turnOption_OP and returns the corresponding string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
turnOption_OP
Parameters
tThe turn choice.
Returns
String corresponding to the turn choice.

◆ stringFromWinconClass()

char * stringFromWinconClass ( winconClass w)

Takes a winconClass and returns the corresponding string by the inner array position.

Correct result is only possible by having the enum values in a consistent order with the string array.

See also
winconClass
Parameters
wThe class.
Returns
String corresponding to the class.

◆ strongWhite()

void strongWhite ( void )

Prints an ASCII escape code that makes subsequent output a thick white color.

◆ update_Equipslots()

void update_Equipslots ( Fighter * f)

Updates the passed Fighter's Equipslots item fields, by reading the equipsBag field and setting the equipped ones.

Parameters
fThe Fighter to update.

◆ update_Gamestate()

void update_Gamestate ( Gamestate * gmst,
int current_fighters,
roomClass current_roomtype,
int current_room_index,
int current_enemy_index,
Floor * current_floor,
Room * current_room,
GameOptions * game_options )

Updates the passed (preallocated) Gamestate with the passed int values.

Parameters
gmstThe allocated Gamestate to update.
current_fightersNumber of current Fighters.
current_roomtyperoomClass for current Room.
current_room_indexIndex for current Room.
current_enemy_indexIndex for current Enemy.
current_floorPointer to current Floor, initialised if gmst->gamemode == Rogue.
current_roomPointer to current Room.
game_optionsPointer to current game options.

◆ updateCounters()

void updateCounters ( Turncounter * counters[],
int isEnemy,
Fighter * f,
Enemy * e )

Takes a Turncounter array, an integer, a Fighter pointer and an Enemy pointer.

For every Turncounter in the array count value is checked, and when it's equal to 1, the function pointer relevant to the type value of the Counter is called. Depending on the isEnemy input value, the function call will be for the Fighter or Enemy version (and the according pointer from the input will be passed to the called function). When the count value is 0, counters are considered inactive, so when the count value is not 1, it is lowered by 1 if it's positive.

See also
Fighter
Enemy
Turncounter
Countertype
COUNTERSMAX
counterIndexes
Parameters
countersThe Turncounter array to be updated.
isEnemyDictates if the check is done for an Enemy or a Fighter.
fThe Fighter pointer whose counters field will be updated if isEnemy is false.
eThe Enemy pointer whose counters field will be updated if isEnemy is true.

◆ updateCounters_Boss()

void updateCounters_Boss ( Turncounter * counters[],
int isBoss,
Fighter * f,
Boss * b )

Takes a Turncounter array, an integer, a Fighter pointer and a Boss pointer.

For every Turncounter in the array count value is checked, and when it's equal to 1, the function pointer relevant to the type value of the Counter is called. Depending on the isBoss input value, the function call will be for the Fighter or Boss version (and the according pointer from the input will be passed to the called function). When the count value is 0 Counters are considered inactive, so when the count value is not 1, it is lowered by 1 if it's positive.

See also
Fighter
Boss
Turncounter
Countertype
COUNTERSMAX
counterIndexes
Parameters
countersThe Turncounter array to be updated.
isBossDictates if the check is done for a Boss or a Fighter.
fThe Fighter pointer whose counters field will be updated if isBoss is false.
bThe Boss pointer whose counters field will be updated if isBoss is true.

◆ usage()

void usage ( const char * progname)

Prints correct argument syntax for command line invocation.

◆ useConsumable()

void useConsumable ( Fighter * f,
Enemy * e,
Boss * b,
char * string,
int isBoss )

Takes a Fighter, an Enemy and a Boss pointers, a string denoting the consumableClass and an int for use on enemy or boss.

If qty value for the Consumable is 0, we have an early return. Otherise effect is applied and qty is decreased.

See also
Fighter
Enemy
Boss
Consumable
consumableClass
Parameters
fThe Fighter pointer at hand.
eThe Enemy pointer at hand.
bThe Boss pointer at hand.
stringThe string value of consumable to use.
isBossThe mode of use (on boss if == 1)

◆ white()

void white ( void )

Prints an ASCII escape code that makes subsequent output a light white color.

◆ yellow()

void yellow ( void )

Prints an ASCII escape code that makes subsequent output a thick yellow color.