helapordo 1.4.12
Loading...
Searching...
No Matches
game_utils.h
Go to the documentation of this file.
1// jgabaut @ github.com/jgabaut
2// SPDX-License-Identifier: GPL-3.0-only
3/*
4 Copyright (C) 2022-2024 jgabaut
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, version 3 of the License.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>.
17*/
18
19#ifndef GAME_UTILS_H
20#define GAME_UTILS_H
21
22#ifndef _WIN32
23#define _POSIX_C_SOURCE 200809L // Needed for getopt
24#endif // _WIN32
25
26#ifdef HELAPORDO_CURSES_BUILD
27#include "../core/sprites.h"
28#ifdef _WIN32
29#include <ncursesw/panel.h>
30#include <ncursesw/menu.h>
31#else
32#include <menu.h>
33#include <panel.h>
34#endif // _WIN32
35#else
36#ifndef HELAPORDO_RAYLIB_BUILD
37#error "HELAPORDO_CURSES_BUILD and HELAPORDO_RAYLIB_BUILD are both undefined."
38#else
39
40#endif // HELAPORDO_RAYLIB_BUILD
41
42#endif // HELAPORDO_CURSES_BUILD
43
44#include <stdio.h>
45#include <stdlib.h>
46#include <unistd.h>
47
48
49#ifdef _WIN32 // From https://stackoverflow.com/a/230068
50#include <io.h>
51#define F_OK 0
52#define access _access
53#endif
54
55#include <string.h>
56#include <sys/stat.h>
57#include <time.h>
58#include <inttypes.h>
59#include <signal.h>
60#include "../core/game_core.h"
61#ifdef HELAPORDO_CURSES_BUILD
62#endif // HELAPORDO_CURSES_BUILD
63#ifdef ANVIL_BUILD
64#include "../anvil__helapordo.h"
65#endif // ANVIL_BUILD
66
67#include "../release_data/release_data.h"
68
69void* s4c_gui_malloc(size_t size);
70void* s4c_gui_calloc(size_t count, size_t size);
71void hlpd_sigint_handler(int signum);
72void initWincon(Wincon * w, Path * p, winconClass class);
73void printGlobVars(void);
74
75#ifdef _WIN32
76void printWin_EnvVars(void);
77void log_Win_EnvVars(void);
78#endif
79
80void red(void);
81void lightRed(void);
82void strongWhite(void);
83void white(void);
84void green(void);
85void lightGreen(void);
86void yellow(void);
87void lightYellow(void);
88void blue(void);
89void lightBlue(void);
90void purple(void);
91void lightPurple(void);
92void cyan(void);
93void lightCyan(void);
94
96void resolve_staticPath(char static_path[500]);
97
98void dbg_print_floor_layout(Floor * floor);
101void dbg_Gamestate(Gamestate * gmst);
102void dbg_GameScreen(GameScreen * scr);
103void dbg_GameOptions(GameOptions * options);
104void dbg_Fighter(Fighter * fighter);
105void dbg_countStats(countStats * stats);
106void dbg_Wincon(Wincon * wc);
107void dbg_Path(Path * path);
108void dbg_Saveslot(Saveslot * saveslot);
109
110void update_Gamestate(Gamestate * gmst, int current_fighters,
111 roomClass current_roomtype, int current_room_index,
112 int current_enemy_index, Floor * current_floor, Room* current_room, GameOptions* game_options);
113
115
116void loadLore(char **lore_strings, int loreKind);
117
118void setRoomType(Path * path, int *roadFork_value, roomClass * room_type,
119 int roomsDone);
120void freeRoom(Room * room);
121
122void printTitle(void);
123
124void printVersion(void);
125void printFormattedVersion(const char *progname);
126void hlpd_dbg_features(void);
127
128void usage(const char *progname);
129void log_tag(char *filename, char *header, const char *format, ...);
130void log_OP(turnOption_OP op);
131
133const char *stringFrom_HLPD_DirectionalKeys_Schema(int dks);
145char *stringFromConsumables(int c);
146char *stringFromEquips(int e);
147char *stringFromEquipzones(int z);
148char *stringFromQuality(int q);
149char *stringFromArtifacts(int a);
151
155
156char *descStringFromSkill(skillType class);
157char *nameStringFromSkill(skillType class);
158int costFromSkill(skillType class);
159
160char *nameStringFromPerk(int p);
161char *descStringFromPerk(int p);
162
163char *descStringFromTreasure(int t);
164char *descStringFromChest(int c);
165
167
171
172void scanName(Fighter * player);
173
174void printClasses(void);
175int scanClass(void);
176void pickClass(Fighter * player);
177
178void printWincons(void);
179int scanWincon(void);
180void pickWincon(Wincon * w);
181
182void pickName(Fighter * player);
183
184void copy_fighter(Fighter * source, Fighter * dest);
185
187
189
191
193
198
199void set_turnboost_atk(Fighter * f, int boost);
200void set_turnboost_def(Fighter * f, int boost);
201void set_turnboost_vel(Fighter * f, int boost);
202void set_turnboost_enr(Fighter * f, int boost);
203
204void set_enemy_turnboost_atk(Enemy * e, int boost);
205void set_enemy_turnboost_def(Enemy * e, int boost);
206void set_enemy_turnboost_vel(Enemy * e, int boost);
207void set_enemy_turnboost_enr(Enemy * e, int boost);
208
209void set_boss_turnboost_atk(Boss * b, int boost);
210void set_boss_turnboost_def(Boss * b, int boost);
211void set_boss_turnboost_vel(Boss * b, int boost);
212void set_boss_turnboost_enr(Boss * b, int boost);
213
214void set_foeparty_turnboost_atk(FoeParty * fp, int boost);
215void set_foeparty_turnboost_def(FoeParty * fp, int boost);
216void set_foeparty_turnboost_vel(FoeParty * fp, int boost);
217void set_foeparty_turnboost_enr(FoeParty * fp, int boost);
218
220
221void resetEnemyStatus(Enemy * e);
222
223void resetBossStatus(Boss * b);
224
225void setEquipPrices(int size, int *equipPrices, Equip * equips[]);
226void setConsumablePrices(int size, int *consumablePrices,
227 Consumable ** consumables);
228
229void statReset(Fighter * player, int force);
230void statResetBoss(Boss * b, int force);
231void statResetEnemy(Enemy * e, int force);
232int getBossBoost(int lvl, bossClass bclass);
233int getEnemyBoost(int lvl, enemyClass eclass);
234
235void resetPermboosts(Fighter * f);
236void applyPermboosts(Fighter * f);
237
239
240void printSpawnMessage(Enemy * e, int roomIndex, int enemyIndex);
241int dropConsumable(Fighter * player);
242int dropArtifact(Fighter * player);
243
244int getConsumableQty(Fighter * f, int n);
245void emptyConsumables(Fighter * player);
246void emptyArtifacts(Fighter * player);
247void emptyEquips(Fighter * player);
248Path *randomise_path(char* seed, Koliseo * kls, const char *path_to_savefile);
249void printStats(Fighter * f);
250void printEStats(Enemy * e);
253void enqueue_notification(char *text, int time, int color, RingaBuf* rb_notifications);
254void applyStatus(Fighter * f, RingaBuf* rb_notifications);
255void applyEStatus(Enemy * e, RingaBuf* rb_notifications);
256void applyBStatus(Boss * b, RingaBuf* rb_notifications);
257void printStatusText(fighterStatus status, char *subject, int color, RingaBuf* rb_notifications);
258void dropEquip(Fighter * player, int beast, Koliseo * kls, RingaBuf* rb_notifications);
259
260#ifdef HELAPORDO_CURSES_BUILD
261void test_game_color_pairs(WINDOW * win, int colors_per_row);
262void init_Gamestate(Gamestate * gmst, clock_t start_time, countStats * stats, Wincon * wincon,
263 Path * path, Fighter * player, Gamemode gamemode, GameScreen* screen, GameOptions* options, bool is_seeded);
264turnOP_args *init_turnOP_args(Gamestate * gmst, Fighter * actor, Path * path,
265 Room * room, loadInfo * load_info, Enemy * enemy,
266 Boss * boss, FILE * save_file,
267 WINDOW * notify_win, Koliseo_Temp * t_kls,
268 foeTurnOption_OP foe_op, skillType picked_skill, RingaBuf* rb_notifications);
269void print_label(WINDOW * win, int starty, int startx, int width, char *string,
270 chtype color);
271void setEquipSprite(Equip * e);
274void printEquipStats(Equip * e);
275void printQualityColor(quality q);
276void unlockSpecial(Fighter * f);
277void printCounters(Turncounter * counters[]);
278void printActivePerks(Fighter * f);
279int retry(char* seed);
280void getParams(int argc, char **argv, Fighter * player, Path * path, int optTot,
281 Koliseo * kls);
282#else
283#ifndef HELAPORDO_RAYLIB_BUILD
284#error "HELAPORDO_CURSES_BUILD and HELAPORDO_RAYLIB_BUILD are both undefined.\n"
285#else
286void test_game_color_pairs(Rectangle * win, int colors_per_row);
287void init_Gamestate(Gamestate * gmst, clock_t start_time, countStats * stats, Wincon * wincon,
288 Path * path, Fighter * player, Gamemode gamemode);
289turnOP_args *init_turnOP_args(Gamestate * gmst, Fighter * actor, Path * path,
290 Room * room, loadInfo * load_info, Enemy * enemy,
291 Boss * boss, FILE * save_file,
292 Rectangle * notification_area, Koliseo_Temp * t_kls,
293 foeTurnOption_OP foe_op, skillType picked_skill);
294void unlockSpecial(Fighter * f);
295#endif // HELAPORDO_RAYLIB_BUILD
296#endif // HELAPORDO_CURSES_BUILD
297
298void death(Fighter * player, loadInfo * load_info);
299void e_death(Enemy * e);
300void b_death(Boss * b);
301
302void updateCounters(Turncounter * counters[], int isEnemy, Fighter * f,
303 Enemy * e);
304void updateCounters_Boss(Turncounter * counters[], int isBoss, Fighter * f,
305 Boss * b);
306
307void checkremainder(Fighter * player, int xp);
308void giveXp(Fighter * player, Enemy * e);
309void giveXp_Boss(Fighter * player, Boss * b);
310int getEnemyXpGain(Enemy * e);
311int getBossXpGain(Boss * b);
312void onLevelUp(Fighter * player);
313int getBoost(int lvl, int luck);
314void sell_all_equips(Fighter * f, Koliseo_Temp * t_kls);
315
316turnOption getTurnChoice(char *ch);
319void quit(Fighter * p, Room * room, loadInfo * load_info, Koliseo_Temp * t_kls);
320void setCounter(Turncounter * c, int turns);
321void useConsumable(Fighter * f, Enemy * e, Boss * b, char *string, int isBoss);
322
323int hlpd_rand_docount(bool count);
324int hlpd_rand(void);
325unsigned long hlpd_hash(unsigned char *str);
326void gen_random_seed(char buffer[PATH_SEED_BUFSIZE+1]);
327bool check_seed(char buffer[PATH_SEED_BUFSIZE]);
328
329#define hlpd_d_keyval(key) ((((key) >= 0) && ((key) <= HLPD_KEYCLASS_MAX)) ? (hlpd_default_keybinds[(key)].val) : -1 )
330void hlpd_reset_logfile(void);
331void hlpd_use_forced_flags(const char* whoami);
332int display_colorpairs(void);
333int hlpd_getopt(size_t argc, char** argv, const char* whoami);
334#endif
Equip equips[EQUIPSMAX+1]
Array containing all Equip instances.
Definition game_core.c:547
void(* effect_fp_fun)(struct FoeParty *)
Defines a function pointer returning void and taking a FoeParty pointer.
Definition game_core.h:1244
enemyClass
The different kinds of Enemy.
Definition game_core.h:654
turnOption
The different kinds of turnOption.
Definition game_core.h:1935
void(* boost_fp_fun)(struct FoeParty *, int boost)
Defines a function pointer returning void and taking a FoeParty pointer and an integer.
Definition game_core.h:1269
Gamemode
The different kinds of Gamemode.
Definition game_core.h:438
saveType
The different kinds of saveType.
Definition game_core.h:1838
foeTurnOption
The different kinds of foeTurnOption.
Definition game_core.h:2005
quality
The different grades of Equip.
Definition game_core.h:1379
floorClass
The different kinds of Floor.
Definition game_core.h:1778
#define PATH_SEED_BUFSIZE
Definition game_core.h:1336
Stat
The different kinds of Stat.
Definition game_core.h:605
void(* boost_b_fun)(Boss *, int boost)
Defines a function pointer returning void and taking a Boss pointer and an integer.
Definition game_core.h:1263
void(* effect_e_fun)(Enemy *)
Defines a function pointer returning void and taking a Enemy pointer.
Definition game_core.h:1232
fighterClass
The different kinds of Fighter.
Definition game_core.h:584
HLPD_KeyClass
The different kinds of HLPD_Key.
Definition game_core.h:110
void(* effect_b_fun)(Boss *)
Defines a function pointer returning void and taking a Boss pointer.
Definition game_core.h:1238
specialMove
The different kinds of special moves.
Definition game_core.h:790
fighterStatus
The different kinds of fighterStatus.
Definition game_core.h:564
foeTurnOption_OP
The different kinds of foeTurnOption_OP.
Definition game_core.h:2016
turnOption_OP
The different kinds of turnOption_OP.
Definition game_core.h:1960
foePartyClass
The different kinds of FoeParty.
Definition game_core.h:1688
void(* boost_e_fun)(Enemy *, int boost)
Defines a function pointer returning void and taking a Enemy pointer and an integer.
Definition game_core.h:1257
bossClass
The different kinds of Boss.
Definition game_core.h:713
roomClass
The different kinds of Room.
Definition game_core.h:1647
skillType
Definition game_core.h:845
HLP_Region_Type
Defines indexes for all types that are allocated with Koliseo.
Definition game_core.h:202
winconClass
The different kinds of Wincon.
Definition game_core.h:1310
void(* effect_fun)(Fighter *)
Defines a function pointer returning void and taking a Fighter pointer.
Definition game_core.h:1226
void(* boost_fun)(Fighter *, int boost)
Defines a function pointer returning void and taking a Fighter pointer and an integer.
Definition game_core.h:1251
fightResult
The different kinds of fightResult.
Definition game_core.h:2159
OP_res
The different kinds of OP_res.
Definition game_core.h:2055
char * lore_strings[6]
Declares lore array for the game.
Definition game_lore.c:20
void setConsumableSprite(Consumable *c)
Takes a Consumable pointer and prepares its sprite field by copying it line by line from consumables_...
Definition game_rl.c:110
void setEquipSprite(Equip *e)
Takes a Equip pointer and prepares its sprite field by copying it line by line from equips_sprites,...
Definition game_rl.c:91
void setArtifactSprite(Artifact *a)
Takes a Artifact pointer and prepares its sprite field by copying it line by line from artifacts_spri...
Definition game_rl.c:130
void * s4c_gui_calloc(size_t count, size_t size)
Definition game_utils.c:30
char * stringFromFloorclass(floorClass fc)
Takes a integer and returns the corresponding floorClass string by the inner array position.
Definition game_utils.c:1751
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.
Definition game_utils.c:2486
void pickWincon(Wincon *w)
Takes a Wincon pointer and sets its class after asking the user for input.
Definition game_utils.c:2005
char * descStringFromPerk(int p)
Takes a integer and returns the corresponding perk desc string by the inner array position.
Definition game_utils.c:1665
char * stringFromStatus(fighterStatus s)
Takes a fighterStatus and returns the corresponding string by the inner array position.
Definition game_utils.c:1431
void * s4c_gui_malloc(size_t size)
Definition game_utils.c:21
void purple(void)
Prints an ASCII escape code that makes subsequent output a thick purple color.
Definition game_utils.c:814
int scanClass(void)
Asks for an integer on stdin and returns it if it's a valid fighterClass index.
Definition game_utils.c:1817
void hlpd_sigint_handler(int signum)
Function to handle Ctrl+C signal.
Definition game_utils.c:45
void dbg_Fighter(Fighter *fighter)
Debugs the passed (preallocated) Fighter with log_tag().
Definition game_utils.c:222
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.
Definition game_utils.c:2447
void yellow(void)
Prints an ASCII escape code that makes subsequent output a thick yellow color.
Definition game_utils.c:782
char * stringFromTurnOP(turnOption_OP t)
Takes a turnOption_OP and returns the corresponding string by the inner array position.
Definition game_utils.c:1393
void resolve_staticPath(char static_path[500])
Sets the passed char array to the expected path for /static/ folder.
Definition game_utils.c:879
char * stringFromFoePartyClass(foePartyClass fp)
Takes a integer and returns the corresponding FoeParty desc string by the inner array position.
Definition game_utils.c:1703
void dbg_GameOptions(GameOptions *options)
Definition game_utils.c:207
void printEStats(Enemy *e)
Takes a Enemy pointer and prints most of its values formatted.
Definition game_utils.c:3126
void white(void)
Prints an ASCII escape code that makes subsequent output a light white color.
Definition game_utils.c:758
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 u...
Definition game_utils.c:5464
effect_fun getStatusCounterFun(fighterStatus status)
Takes a fighterStatus and returns the corresponding effect_fun pointer for the function relating to t...
Definition game_utils.c:2102
foeTurnOption enemyTurnPick(Enemy *e, Fighter *f)
Returns a randomised pick as foeTurnOption.
Definition game_utils.c:5297
char * nameStringFromSkill(skillType class)
Takes a skillType and returns the corresponding name string by the inner array position.
Definition game_utils.c:1612
char * stringFromArtifacts(int a)
Takes a integer and returns the corresponding artifact string by the inner array position.
Definition game_utils.c:1556
void giveXp(Fighter *player, Enemy *e)
Takes a Fighter and a Enemy pointers and handles xp gain by fighter.
Definition game_utils.c:5009
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.
Definition game_utils.c:2499
void onLevelUp(Fighter *player)
Takes a Fighter pointer and updated its stats.
Definition game_utils.c:5075
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...
Definition game_utils.c:2266
foeTurnOption bossTurnPick(Boss *b, Fighter *f)
Returns a randomised pick as foeTurnOption.
Definition game_utils.c:5346
void printGlobVars(void)
Prints global vars to stdout.
Definition game_utils.c:145
effect_e_fun getStatusCounterEnemyFun(fighterStatus status)
Takes a fighterStatus and returns the corresponding effect_e_fun pointer for the function relating to...
Definition game_utils.c:2120
void hlpd_reset_logfile(void)
Definition game_utils.c:5629
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 ...
Definition game_utils.c:2548
const char * stringFrom_HLPD_DirectionalKeys_Schema(int dks)
Takes a integer and returns the corresponding HLPD_DirectionalKeys_Schema string by the inner array p...
Definition game_utils.c:1775
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.
Definition game_utils.c:2369
void applyBStatus(Boss *b, RingaBuf *rb_notifications)
Takes a RingaBuf pointer to queue notifications to, a Boss pointer value and applies the effect perta...
Definition game_utils.c:3360
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 e...
Definition game_utils.c:3418
char * descStringFromSpecial(fighterClass class, specialMove move)
Takes a fighterClass and a specialMove and returns the corresponding desc string by the inner array p...
Definition game_utils.c:1585
void lightYellow(void)
Prints an ASCII escape code that makes subsequent output a light yellow color.
Definition game_utils.c:790
void strongWhite(void)
Prints an ASCII escape code that makes subsequent output a thick white color.
Definition game_utils.c:750
void applyPermboosts(Fighter *f)
Takes a Fighter pointer and applies all of its permboost_STAT values by adding them to the current st...
Definition game_utils.c:2836
void usage(const char *progname)
Prints correct argument syntax for command line invocation.
Definition game_utils.c:1273
void printSpawnMessage(Enemy *e, int roomIndex, int enemyIndex)
Takes a Enemy pointer and two integers for current room index and current enemy index,...
Definition game_utils.c:2890
char * descStringFromTreasure(int t)
Takes a integer and returns the corresponding treasure desc string by the inner array position.
Definition game_utils.c:1678
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.
Definition game_utils.c:2382
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.
Definition game_utils.c:2395
char * stringFrom_fightResult(fightResult fr)
Takes a fightResult fr and returns the corresponding string by the inner array position.
Definition game_utils.c:1418
void blue(void)
Prints an ASCII escape code that makes subsequent output a thick blue color.
Definition game_utils.c:798
void update_Equipslots(Fighter *f)
Updates the passed Fighter's Equipslots item fields, by reading the equipsBag field and setting the e...
Definition game_utils.c:682
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.
Definition game_utils.c:2473
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,...
Definition game_utils.c:5398
void e_death(Enemy *e)
Takes a Enemy pointer and frees its allocated memory.
Definition game_utils.c:4760
char * stringFromQuality(int q)
Takes a integer and returns the corresponding quality string by the inner array position.
Definition game_utils.c:1543
void lightCyan(void)
Prints an ASCII escape code that makes subsequent output a light cyan color.
Definition game_utils.c:838
void printArtifactStats(Artifact *a)
Takes a Artifact pointer and prints most of its values formatted.
Definition game_utils.c:3160
void updateCounters(Turncounter *counters[], int isEnemy, Fighter *f, Enemy *e)
Takes a Turncounter array, an integer, a Fighter pointer and an Enemy pointer.
Definition game_utils.c:4840
void giveXp_Boss(Fighter *player, Boss *b)
Takes a Fighter and a Boss pointers and handles xp gain by fighter.
Definition game_utils.c:5026
int getEnemyBoost(int lvl, enemyClass eclass)
Takes one integer and an enemyClass and returns the boost relative to the level delta with base enemy...
Definition game_utils.c:2772
unsigned long hlpd_hash(unsigned char *str)
djb2 by Dan Bernstein.
Definition game_utils.c:5572
int scanWincon(void)
Asks for an integer on stdin and returns it if it's a valid winconClass index.
Definition game_utils.c:1926
bool check_seed(char buffer[PATH_SEED_BUFSIZE])
Checks the passed buffer as a seed.
Definition game_utils.c:5610
void statResetBoss(Boss *b, int force)
Takes a Boss pointer and an integer used to force execution.
Definition game_utils.c:2643
void statReset(Fighter *player, int force)
Takes a Fighter pointer and an integer used to force execution.
Definition game_utils.c:2600
void pickClass(Fighter *player)
Takes a Fighter pointer and sets the class value after asking the user for input.
Definition game_utils.c:1839
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.
Definition game_utils.c:2356
char * nameStringFromSpecial(fighterClass class, specialMove move)
Takes a fighterClass and a specialMove and returns the corresponding name string by the inner array p...
Definition game_utils.c:1571
char * nameStringFromPerk(int p)
Takes a integer and returns the corresponding perk name string by the inner array position.
Definition game_utils.c:1651
void dbg_Path(Path *path)
Debugs the passed (preallocated) Path with log_tag().
Definition game_utils.c:340
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,...
Definition game_utils.c:3468
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.
Definition game_utils.c:1715
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.
Definition game_utils.c:2330
void printVersion(void)
Prints version string.
Definition game_utils.c:1136
int dropConsumable(Fighter *player)
Takes a Fighter pointer value and adds a random Consumable to consumablesBag.
Definition game_utils.c:2919
char * stringFromRoom(roomClass r)
Takes a integer and returns the corresponding room name string by the inner array position.
Definition game_utils.c:1727
void red(void)
Prints an ASCII escape code that makes subsequent output a thick red color.
Definition game_utils.c:734
char * stringFromGamemode(Gamemode g)
Takes a integer and returns the corresponding gamemode string by the inner array position.
Definition game_utils.c:1739
void dbg_countStats(countStats *stats)
Debugs the passed (preallocated) countStats with log_tag().
Definition game_utils.c:377
void resetEnemyStatus(Enemy *e)
Takes a Enemy pointer and resets its status value to Normal.
Definition game_utils.c:2524
void freeRoom(Room *room)
Frees the memory allocated for the passed room pointer.
Definition game_utils.c:1017
char * stringFromWinconClass(winconClass w)
Takes a winconClass and returns the corresponding string by the inner array position.
Definition game_utils.c:1452
char * stringFromFoeTurnOP(foeTurnOption_OP ft)
Takes a foeTurnOption_OP and returns the corresponding string by the inner array position.
Definition game_utils.c:1406
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 bala...
Definition game_utils.c:5136
char * stringFromEquipzones(int z)
Takes a integer and returns the corresponding equipzone string by the inner array position.
Definition game_utils.c:1530
int hlpd_getopt(size_t argc, char **argv, const char *whoami)
Parse options from CLI arguments.
Definition game_utils.c:5830
void statResetEnemy(Enemy *e, int force)
Takes an Enemy pointer and an integer used to force execution.
Definition game_utils.c:2697
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.
Definition game_utils.c:2343
void lightPurple(void)
Prints an ASCII escape code that makes subsequent output a light purple color.
Definition game_utils.c:822
char * stringFrom_HLPD_KeyClass(HLPD_KeyClass k)
Takes a integer and returns the corresponding HLPD_KeyClass string by the inner array position.
Definition game_utils.c:1763
void hlpd_dbg_features(void)
Prints configuration info.
Definition game_utils.c:1153
void dbg_print_explored_layout(Floor *floor)
Logs explored layout for passed Floor.
Definition game_utils.c:442
int dropArtifact(Fighter *player)
Takes a Fighter pointer value and adds a random Artifact to artifactsBag.
Definition game_utils.c:2951
void updateCounters_Boss(Turncounter *counters[], int isBoss, Fighter *f, Boss *b)
Takes a Turncounter array, an integer, a Fighter pointer and a Boss pointer.
Definition game_utils.c:4910
void pickName(Fighter *player)
Takes a Fighter pointer and sets the name value after asking the user for input.
Definition game_utils.c:1948
int display_colorpairs(void)
Runs some shell commands to see all color pairs, then returns exitcode Prints the encoded value of th...
Definition game_utils.c:5810
void gen_random_seed(char buffer[PATH_SEED_BUFSIZE+1])
Sets the passed buffer up to be a random seed.
Definition game_utils.c:5590
char * descStringFromSkill(skillType class)
Takes a fighterClass and a specialMove and returns the corresponding desc string by the inner array p...
Definition game_utils.c:1625
saveType saveTypeFrom_string(char *s)
Takes a string and returns the corresponding saveType.
Definition game_utils.c:702
void initWincon(Wincon *w, Path *p, winconClass class)
Takes a Wincon and a Path pointers and a winconClass and initialises the passed Wincon.
Definition game_utils.c:110
int getEnemyXpGain(Enemy *e)
Takes a Enemy pointer and returns its xp gain as sum of xp field value and level.
Definition game_utils.c:5040
void hlpd_use_forced_flags(const char *whoami)
Definition game_utils.c:5720
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.
Definition game_utils.c:2460
void resetPermboosts(Fighter *f)
Takes a Fighter pointer and resets all of its permboost_STAT values to 0, also correctly updating the...
Definition game_utils.c:2790
char * stringFromBossClass(bossClass b)
Takes a bossClass and returns the corresponding string by the inner array position.
Definition game_utils.c:1491
void dbg_print_roomclass_layout(Floor *floor)
Logs roomclass layout for passed Floor.
Definition game_utils.c:466
void setCounter(Turncounter *c, int turns)
Takes a Turncounter pointer and an integer.
Definition game_utils.c:5440
Path * randomise_path(char *seed, Koliseo *kls, const char *path_to_savefile)
Takes an integer seed and returns a Path pointer.
Definition game_utils.c:3051
void loadLore(char **lore_strings, int loreKind)
Loads the lore strings from the appropriate lore file.
Definition game_utils.c:948
void dbg_Wincon(Wincon *wc)
Debugs the passed (preallocated) Wincon with log_tag().
Definition game_utils.c:359
void lightRed(void)
Prints an ASCII escape code that makes subsequent output a light red color.
Definition game_utils.c:742
int getBossBoost(int lvl, bossClass bclass)
Takes one integer and a bossClass and returns the boost relative to the level delta with base boss st...
Definition game_utils.c:2748
void dbg_GameScreen(GameScreen *scr)
Debugs the passed (preallocated) GameScreen with log_tag().
Definition game_utils.c:607
boost_fun getStatBoostCounterFun(Stat s)
Takes a Stat and returns the corresponding boost_fun pointer for the function relating to the stat.
Definition game_utils.c:2158
void printClasses(void)
Prints all the fighterClass values as integers and as strings.
Definition game_utils.c:1799
void resetArtifactsState(Fighter *f)
Takes a Fighter pointer and Resets the active value for each Artifact in the fighter's artifactsBag a...
Definition game_utils.c:2868
boost_e_fun getStatBoostCounterEnemyFun(Stat s)
Takes a Stat and returns the corresponding boost_e_fun pointer for the function relating to the stat.
Definition game_utils.c:2194
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.
Definition game_utils.c:2317
void enqueue_notification(char *text, int time, int color, RingaBuf *rb_notifications)
Takes a RingaBuf pointer and queues the passed text to it.
Definition game_utils.c:3179
char * stringFromEquips(int e)
Takes a integer and returns the corresponding equip string by the inner array position.
Definition game_utils.c:1517
char * stringFrom_saveType(saveType s)
Takes a saveType and returns the corresponding string by the inner array position.
Definition game_utils.c:1380
void copy_fighter(Fighter *source, Fighter *dest)
Takes two Fighter pointers, with all their fields already allocated, and copies all valaues from sour...
Definition game_utils.c:2029
void log_tag(char *filename, char *header, const char *format,...)
Takes a filename string, a string headear and a format string.
Definition game_utils.c:1310
void resetFighterStatus(Fighter *f)
Takes a Fighter pointer and resets its status value to Normal.
Definition game_utils.c:2513
int costFromSkill(skillType class)
Takes a skillType and returns the corresponding cost by the inner array position, as an integer.
Definition game_utils.c:1638
char * descStringFromChest(int c)
Takes a integer and returns the corresponding chest desc string by the inner array position.
Definition game_utils.c:1691
void green(void)
Prints an ASCII escape code that makes subsequent output a thick green color.
Definition game_utils.c:766
void lightBlue(void)
Prints an ASCII escape code that makes subsequent output a light blue color.
Definition game_utils.c:806
int getConsumableQty(Fighter *f, int n)
Takes a Fighter pointer and an integer denoting the consumableClass and returns the respective qty va...
Definition game_utils.c:2975
int hlpd_rand_docount(bool count)
Wraps over rand() to update G_RNG_ADVANCEMENTS if passed flag is true.
Definition game_utils.c:5546
void resetBossStatus(Boss *b)
Takes a Boss pointer and resets its status value to Normal.
Definition game_utils.c:2535
void printWincons(void)
Prints all the winconClass values as integers and as strings.
Definition game_utils.c:1908
void applyEStatus(Enemy *e, RingaBuf *rb_notifications)
Takes a RingaBuf pointer to queue notifications to, a Enemy pointer value and applies the effect pert...
Definition game_utils.c:3301
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.
Definition game_utils.c:2408
void b_death(Boss *b)
Takes a Boss pointer and frees its allocated memory.
Definition game_utils.c:4799
void printConsumablesStats(Consumable *c)
Takes a Consumable pointer and prints most of its values formatted.
Definition game_utils.c:3150
boost_b_fun getStatBoostCounterBossFun(Stat s)
Takes a Stat and returns the corresponding boost_b_fun pointer for the function relating to the stat.
Definition game_utils.c:2230
void emptyConsumables(Fighter *player)
Sets the qty value to 0 for all Consumable in f's consumablesBag with positive qty.
Definition game_utils.c:2989
void checkremainder(Fighter *player, int xp)
Takes a Fighter pointer and the amount of xp to add.
Definition game_utils.c:4967
int getBoost(int lvl, int luck)
Takes two integers for level to calc against and luck, and returns the boost relative to the level wi...
Definition game_utils.c:5116
void dbg_Gamestate(Gamestate *gmst)
Debugs the passed (preallocated) Gamestate with log_tag().
Definition game_utils.c:526
void cyan(void)
Prints an ASCII escape code that makes subsequent output a thick cyan color.
Definition game_utils.c:830
void lightGreen(void)
Prints an ASCII escape code that makes subsequent output a light green color.
Definition game_utils.c:774
void dbg_print_floor_layout(Floor *floor)
Logs floor layout for passed Floor.
Definition game_utils.c:418
int costFromSpecial(fighterClass class, specialMove move)
Takes a fighterClass and a specialMove and returns the corresponding cost by the inner array position...
Definition game_utils.c:1599
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.
Definition game_utils.c:653
void printFormattedVersion(const char *progname)
Prints formatted version string.
Definition game_utils.c:1145
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.
Definition game_utils.c:994
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...
Definition game_utils.c:3006
void printTitle(void)
Prints an hardcoded title screen.
Definition game_utils.c:1121
void log_OP(turnOption_OP op)
Logs a turnOption_OP to "$STATICDIR/OPS_log.txt".
Definition game_utils.c:723
void setConsumablePrices(int size, int *consumablePrices, Consumable **consumables)
Takes a size int and a pointer to integer array, initialises all the prices.
Definition game_utils.c:2570
turnOption getTurnChoice(char *ch)
Returns the chosen option as a turnOption.
Definition game_utils.c:5235
char * stringFromConsumables(int c)
Takes a integer and returns the corresponding consumable string by the inner array position.
Definition game_utils.c:1504
void init_game_color_pairs(void)
effect_b_fun getStatusCounterBossFun(fighterStatus status)
Takes a fighterStatus and returns the corresponding effect_e_fun pointer for the function relating to...
Definition game_utils.c:2138
void death(Fighter *player, loadInfo *load_info)
Takes a Fighter and loadInfo pointers and prints fighter stats and a game over message.
Definition game_utils.c:4625
void emptyEquips(Fighter *player)
Takes a Fighter pointer and, for all Equip in equipsBag field with positive qty, sets qty to 0 and fr...
Definition game_utils.c:3022
void scanName(Fighter *player)
Takes a Fighter pointer and sets its name value to the string provided on stdin.
Definition game_utils.c:1784
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.
Definition game_utils.c:2304
char * stringFrom_OP_res(OP_res r)
Takes a OP_res and returns the corresponding string by the inner array position.
Definition game_utils.c:1367
void printStats(Fighter *f)
Takes a Fighter pointer and prints most of its values formatted.
Definition game_utils.c:3102
effect_fp_fun get_StatusCounter_FoeParty_Fun(fighterStatus status)
void dbg_Saveslot(Saveslot *saveslot)
Debugs the passed (preallocated) Saveslot with log_tag().
Definition game_utils.c:323
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.
Definition game_utils.c:2434
char * stringFromClass(fighterClass f)
Takes a fighterClass and returns the corresponding string by the inner array position.
Definition game_utils.c:1465
char * stringFromEClass(enemyClass e)
Takes a enemyClass and returns the corresponding string by the inner array position.
Definition game_utils.c:1478
int getBossXpGain(Boss *b)
Takes a Boss pointer and returns its xp gain as sum of xp field value and level.
Definition game_utils.c:5053
int hlpd_rand(void)
Wraps over hlpd_rand_docount() to update G_RNG_ADVANCEMENTS.
Definition game_utils.c:5559
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.
Definition game_utils.c:2421
void applyStatus(Fighter *f, RingaBuf *rb_notifications)
Takes a RingaBuf pointer to queue notifications to, a Fighter pointer value and applies the effect pe...
Definition game_utils.c:3249
Represents the entity initialised from a artifactClass.
Definition game_core.h:537
Represents the entity initialised from a bossClass.
Definition game_core.h:1190
Holds a certain qty of a consumableClass.
Definition game_core.h:488
Represents the entity initialised from a enemyClass.
Definition game_core.h:1149
Represents the entity initialised from a equipClass.
Definition game_core.h:1402
Represents the entity initialised from a fighterClass.
Definition game_core.h:1079
Represents the entity initialised from a floorClass.
Definition game_core.h:1811
Represents the entity initialised from a foePartyClass.
Definition game_core.h:1711
Holds options useful for user runtime preferences.
Definition game_core.h:191
Holds arguments for a game.
Definition game_core.h:1885
Holds the state of game progression.
Definition game_core.h:1343
Represents the entity initialised from a roomClass.
Definition game_core.h:1756
Holds arguments for a saveslot.
Definition game_core.h:396
Represents the entity initialised from a CounterType.
Definition game_core.h:1289
Defines the entity initialised from a winconClass.
Definition game_core.h:1324
Holds the lifetime stats of the player.
Definition game_core.h:767
Contains loaded values to pass to initRoom().
Definition game_core.h:1864
Holds arguments for a turnOption_OP.
Definition game_core.h:2090