helapordo 1.4.20
Loading...
Searching...
No Matches
game_utils.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <inttypes.h>
#include <signal.h>
#include "../core/game_core.h"
#include "../core/game_log.h"
#include "../core/game_strings.h"
#include "../core/game_rng.h"
#include "../core/game_fight.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 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.
saveType saveTypeFrom_string (char *s)
 Takes a string and returns the corresponding saveType.
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.
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 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.
int checkremainder (Fighter *player, int xp)
 Takes a Fighter pointer and the amount of xp to add.
int giveXp (Fighter *player, Enemy *e)
 Takes a Fighter and a Enemy pointers and handles xp gain by fighter.
int 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.
int onLevelUp (Fighter *player)
 Takes a Fighter pointer and updated its stats.
void sell_all_equips (Fighter *f)
 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.
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 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.
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:58
#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:135

Function Documentation

◆ 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.

◆ 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.

◆ checkremainder()

int 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.
Returns
1 when player unlocked a new Special

◆ 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.

◆ 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.

◆ 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.

◆ freeRoom()

void freeRoom ( Room * room)

Frees the memory allocated for the passed room pointer.

Parameters
roomThe Room pointer to free.
See also
Room

◆ 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.

◆ 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.

◆ 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()

int 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()

int 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_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()

◆ onLevelUp()

int 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.
Returns
1 when player unlocked a new Special

◆ 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.

◆ 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

◆ 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.

◆ 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)

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.

◆ 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.

◆ 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.