|
helapordo 1.4.20
|
#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"

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. | |
| Path * | randomise_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. | |
| #define _POSIX_C_SOURCE 200809L |
| #define hlpd_d_keyval | ( | key | ) |
| void applyPermboosts | ( | Fighter * | f | ) |
| void b_death | ( | Boss * | b | ) |
| void blue | ( | void | ) |
Prints an ASCII escape code that makes subsequent output a thick blue color.
| 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.
| player | The Fighter pointer that gets xp. |
| xp | The amount of xp. |
| void cyan | ( | void | ) |
Prints an ASCII escape code that makes subsequent output a thick cyan color.
| void dbg_countStats | ( | countStats * | stats | ) |
Debugs the passed (preallocated) countStats with log_tag().
| stats | The allocated countStats to debug. |
| void dbg_Fighter | ( | Fighter * | fighter | ) |
| void dbg_GameOptions | ( | GameOptions * | options | ) |
| void dbg_GameScreen | ( | GameScreen * | scr | ) |
Debugs the passed (preallocated) GameScreen with log_tag().
| scr | The allocated GameScreen to debug. |
| void dbg_Gamestate | ( | Gamestate * | gmst | ) |
| void dbg_Path | ( | Path * | path | ) |
| void dbg_Saveslot | ( | Saveslot * | saveslot | ) |
| void dbg_Wincon | ( | Wincon * | wc | ) |
Debugs the passed (preallocated) Wincon with log_tag().
| wc | The allocated countStats to debug. |
| 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 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.
| player | The Fighter pointer at hand. |
| int dropConsumable | ( | Fighter * | player | ) |
Takes a Fighter pointer value and adds a random Consumable to consumablesBag.
| player | The Fighter pointer at hand. |
| 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.
| player | The Fighter pointer at hand. |
| beast | The integer for drops coming from a beast kill if true. |
| kls | The Koliseo used for allocations. |
| rb_notifications | The RingaBuf used for notifications. |
| void e_death | ( | Enemy * | e | ) |
| 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.
| f | The Fighter pointer at hand. |
| void emptyConsumables | ( | Fighter * | f | ) |
Sets the qty value to 0 for all Consumable in f's consumablesBag with positive qty.
| f | The Fighter pointer at hand. |
| void emptyEquips | ( | Fighter * | player | ) |
| void freeRoom | ( | Room * | room | ) |
| int getBossXpGain | ( | Boss * | b | ) |
| 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.
| f | The Fighter pointer. |
| n | The consumableClass value. |
| int getEnemyXpGain | ( | Enemy * | e | ) |
| turnOption getTurnChoice | ( | char * | ch | ) |
Returns the chosen option as a turnOption.
| ch | A string representing the turn choice. |
Takes a Fighter and a Enemy pointers and handles xp gain by fighter.
Takes a Fighter and a Boss pointers and handles xp gain by fighter.
| void green | ( | void | ) |
Prints an ASCII escape code that makes subsequent output a thick green color.
| void hlpd_dbg_features | ( | void | ) |
Prints configuration info.
| int hlpd_getopt | ( | size_t | argc, |
| char ** | argv, | ||
| const char * | whoami ) |
Parse options from CLI arguments.
| argc | argc from main |
| argv | argv from main |
| whoami | Name used by the program |
| void hlpd_sigint_handler | ( | int | signum | ) |
Function to handle Ctrl+C signal.
| signum | The signal number, expected to be SIGINT. |
| void hlpd_use_forced_flags | ( | const char * | whoami | ) |
| void init_game_color_pairs | ( | void | ) |
| void initWincon | ( | Wincon * | w, |
| Path * | p, | ||
| winconClass | class ) |
Takes a Wincon and a Path pointers and a winconClass and initialises the passed Wincon.
| w | The Wincon pointer to initialise. |
| p | The Path to use to initialise Wincon. |
| class | The winconClass to use to initialise. |
| void lightBlue | ( | void | ) |
Prints an ASCII escape code that makes subsequent output a light blue color.
| void lightCyan | ( | void | ) |
Prints an ASCII escape code that makes subsequent output a light cyan color.
| void lightGreen | ( | void | ) |
Prints an ASCII escape code that makes subsequent output a light green color.
| void lightPurple | ( | void | ) |
Prints an ASCII escape code that makes subsequent output a light purple color.
| void lightRed | ( | void | ) |
Prints an ASCII escape code that makes subsequent output a light red color.
| void lightYellow | ( | void | ) |
Prints an ASCII escape code that makes subsequent output a light yellow color.
| void loadLore | ( | char ** | lore_strings, |
| int | loreKind ) |
Loads the lore strings from the appropriate lore file.
| lore_strings | The string array to copy to. |
| loreKind | The kind of lore, used to open the corresponding lore file. |
| 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.
| player | The Fighter pointer that levels up. |
| void pickClass | ( | Fighter * | player | ) |
Takes a Fighter pointer and sets the class value after asking the user for input.
| player | The pointer whose class value will be set. |
| void pickName | ( | Fighter * | player | ) |
Takes a Fighter pointer and sets the name value after asking the user for input.
| player | The pointer whose name value will be set. |
| void pickWincon | ( | Wincon * | w | ) |
Takes a Wincon pointer and sets its class after asking the user for input.
| w | The wincon pointer whose class value will be set. |
| void printArtifactStats | ( | Artifact * | a | ) |
| void printClasses | ( | void | ) |
Prints all the fighterClass values as integers and as strings.
| void printConsumablesStats | ( | Consumable * | c | ) |
Takes a Consumable pointer and prints most of its values formatted.
| c | The Consumable pointer with stats to print. |
| void printEStats | ( | Enemy * | e | ) |
| void printFormattedVersion | ( | const char * | progname | ) |
Prints formatted version string.
| progname | The program name string. |
| void printGlobVars | ( | void | ) |
Prints global vars to stdout.
| 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.
| e | The Enemy pointer to print. |
| roomIndex | The index of current room. |
| enemyIndex | The index of current enemy. |
| void printStats | ( | Fighter * | f | ) |
| void printTitle | ( | void | ) |
Prints an hardcoded title screen.
| void printVersion | ( | void | ) |
Prints version string.
| void printWincons | ( | void | ) |
Prints all the winconClass values as integers and as strings.
| void purple | ( | void | ) |
Prints an ASCII escape code that makes subsequent output a thick purple color.
| Path * randomise_path | ( | char * | seed, |
| Koliseo * | kls, | ||
| const char * | path_to_savefile ) |
| void red | ( | void | ) |
Prints an ASCII escape code that makes subsequent output a thick red color.
| 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.
| void resetPermboosts | ( | Fighter * | f | ) |
| void * s4c_gui_calloc | ( | size_t | count, |
| size_t | size ) |
| void * s4c_gui_malloc | ( | size_t | size | ) |
| saveType saveTypeFrom_string | ( | char * | s | ) |
Takes a string and returns the corresponding saveType.
Will return -1 if no match is found.
| s | The string to convert. |
| int scanClass | ( | void | ) |
Asks for an integer on stdin and returns it if it's a valid fighterClass index.
| void scanName | ( | Fighter * | player | ) |
Takes a Fighter pointer and sets its name value to the string provided on stdin.
| player | The pointer whose name value will be set. |
| int scanWincon | ( | void | ) |
Asks for an integer on stdin and returns it if it's a valid winconClass index.
| void sell_all_equips | ( | Fighter * | f | ) |
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.
| path | Pointer to Path. |
| roadFork_value | The pointer value of the roadfork that we must use as result. |
| room_type | The pointer value of the room type to set. |
| roomsDone | The total of rooms completed. |
| void strongWhite | ( | void | ) |
Prints an ASCII escape code that makes subsequent output a thick white color.
| void update_Equipslots | ( | Fighter * | f | ) |
| 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.
| gmst | The allocated Gamestate to update. |
| current_fighters | Number of current Fighters. |
| current_roomtype | roomClass for current Room. |
| current_room_index | Index for current Room. |
| current_enemy_index | Index for current Enemy. |
| current_floor | Pointer to current Floor, initialised if gmst->gamemode == Rogue. |
| current_room | Pointer to current Room. |
| game_options | Pointer to current game options. |
| 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.
| counters | The Turncounter array to be updated. |
| isEnemy | Dictates if the check is done for an Enemy or a Fighter. |
| f | The Fighter pointer whose counters field will be updated if isEnemy is false. |
| e | The Enemy pointer whose counters field will be updated if isEnemy is true. |
| 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.
| counters | The Turncounter array to be updated. |
| isBoss | Dictates if the check is done for a Boss or a Fighter. |
| f | The Fighter pointer whose counters field will be updated if isBoss is false. |
| b | The Boss pointer whose counters field will be updated if isBoss is true. |
| void usage | ( | const char * | progname | ) |
Prints correct argument syntax for command line invocation.
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.
| void white | ( | void | ) |
Prints an ASCII escape code that makes subsequent output a light white color.
| void yellow | ( | void | ) |
Prints an ASCII escape code that makes subsequent output a thick yellow color.