Blob


1 /*
2 * Copyright (c) 2021 Matthias Schmidt <xhr@giessen.ccc.de>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
17 #ifndef _ISSCROLLS_H
18 #define _ISSCROLLS_H
20 #include <sys/queue.h>
22 #include <stdio.h>
24 #define VERSION "2021.a"
25 #define _PATH_SHARE_DIR "/usr/local/share/isscrolls"
27 #define MAX_NAME_LEN 12
28 #define MAX_RANK_LEN 13
29 #define MAX_PLOT_LEN 63
30 #define MAX_MYSTIC_LEN 127
31 #define MAX_PLACES_LEN 18
32 #define MAX_PROMPT_LEN 255
33 #define MAX_PTP_LEN 201
34 #define MAX_CHAR_LEN 100
35 #define MAX_PROGRESS 10
36 #define MAX_STAT_LEN 20
38 #define ANSI_COLOR_RED "\x1b[31m"
39 #define ANSI_COLOR_GREEN "\x1b[32m"
40 #define ANSI_COLOR_YELLOW "\x1b[33m"
41 #define ANSI_COLOR_BLUE "\x1b[34m"
42 #define ANSI_COLOR_MAGENTA "\x1b[35m"
43 #define ANSI_COLOR_CYAN "\x1b[36m"
44 #define ANSI_COLOR_RESET "\x1b[0m"
46 /* oracle.c */
47 void cmd_show_iron_name(char *);
48 void cmd_show_elf_name(char *);
49 void cmd_show_giant_name(char *);
50 void cmd_show_varou_name(char *);
51 void cmd_show_troll_name(char *);
52 void cmd_show_action(char *);
53 void cmd_show_theme(char *);
54 void cmd_show_rank(char *);
55 void cmd_show_combat_action(char *);
56 void cmd_show_plot_twist(char *);
57 void cmd_show_mystic_backshlash(char *);
58 void cmd_show_region(char *);
59 void cmd_show_location_description(char *);
60 void cmd_show_location(char *);
61 void cmd_show_coastal_location(char *);
62 void cmd_show_pay_the_price(char *);
63 void show_info_from_oracle(int, int);
65 /* readline.c */
66 char ** my_completion(const char *, int, int);
67 char* command_generator(const char *, int);
68 void initialize_readline(const char *);
69 void execute_command(char *);
70 char* stripwhite (char *);
71 struct command* find_command(char *);
72 void cmd_cd(char *);
74 /* rolls.c */
75 void cmd_roll_action_dice(char *);
76 void cmd_roll_challenge_die(char *);
77 void cmd_roll_oracle_die(char *);
78 void cmd_yes_or_no(char *);
79 void cmd_usage(char *);
80 void cmd_create_character(char *);
81 void cmd_resupply(char *);
82 void cmd_face_danger(char *);
83 void cmd_secure_an_advantage(char *);
84 void cmd_make_camp(char *);
85 void cmd_compel(char *);
86 void cmd_sojourn(char *);
87 void cmd_draw_the_circle(char *);
88 void cmd_forge_a_bond(char *);
89 void cmd_test_your_bond(char *);
90 void cmd_swear_an_iron_vow(char *);
91 void cmd_face_death(char *);
92 void cmd_endure_stress(char *);
93 long roll_action_die(void);
94 long roll_challenge_die(void);
95 long roll_oracle_die(void);
96 void yes_or_no(int);
97 int action_roll(int[]);
98 int progress_roll(double[]);
99 void ask_for_journey_difficulty(void);
100 int get_int_from_cmd(const char *);
101 int get_args_from_cmd(char *, char *, int*);
103 /* isscrolls.c */
104 void cmd_quit(char *);
105 void show_banner(char *);
106 void log_debug(const char *, ...);
107 void log_errx(int, const char *, ...);
108 void pm(int, const char *, ...);
109 void setup_base_dir(void);
110 void shutdown(void);
111 void sandbox(const char *);
112 void set_prompt(const char *);
113 const char * get_isscrolls_dir(void);
115 /* character.c */
116 struct character* init_character_struct(void);
117 void print_character(void);
118 struct character* create_character(const char *);
119 void free_character(void);
120 int validate_range(int, int);
121 int ask_for_value(const char *, int);
122 void cmd_print_current_character(char *);
123 void cmd_delete_character(char *);
124 void save_character(void);
125 void delete_saved_character(int);
126 int load_character(int);
127 struct character * get_current_character(void);
128 int return_character_id(const char *);
129 void load_characters_list(void);
130 void save_current_character(void);
131 void cmd_increase_value(char *);
132 void cmd_decrease_value(char *);
133 void cmd_toogle(char *);
134 void cmd_ls(char *);
135 void cmd_gather_information(char *);
136 void cmd_heal(char *);
137 void change_char_value(const char *, int, int);
138 void increase_value(const char *, int *, int);
139 void decrease_value(const char *, int *, int);
140 void modify_value(const char *, int *, int, int, int, int);
141 void toggle_value(const char *, int *);
142 void change_momentum_reset(int);
143 void set_max_momentum(void);
144 int character_exists(const char *);
145 void update_prompt(void);
147 /* journey.c */
148 void mark_journey_progress(void);
149 void save_journey(void);
150 void load_journey(int);
151 void delete_journey(int);
152 void reach_your_destination_failed(void);
153 void cmd_undertake_a_journey(char *);
154 void cmd_reach_your_destination(char *);
156 /* fight.c */
157 void load_fight(int);
158 void save_fight(void);
159 void delete_fight(int);
160 void cmd_enter_the_fray(char *);
161 void cmd_strike(char *);
162 void cmd_clash(char *);
163 void cmd_battle(char *);
164 void cmd_endure_harm(char *);
165 void mark_fight_progress(void);
166 void ask_for_fight_difficulty(void);
167 void cmd_end_the_fight(char *);
168 void set_initiative(int);
170 enum how_to_change_values {
171 INCREASE,
172 DECREASE,
173 };
175 enum color_codes {
176 RED,
177 YELLOW,
178 GREEN,
179 DEFAULT,
180 };
182 struct command {
183 const char *name;
184 void (*cmd)(char *);
185 const char *doc;
186 int alias;
187 };
189 struct journey {
190 int id;
191 int difficulty;
192 double progress;
193 };
195 struct fight {
196 int id;
197 int difficulty;
198 int initiative;
199 double progress;
200 };
202 struct character {
203 struct journey *j;
204 struct fight *fight;
205 char *name;
206 double bonds;
207 int dead;
208 int journey_active;
209 int fight_active;
210 int id;
211 int edge;
212 int heart;
213 int iron;
214 int shadow;
215 int wits;
216 int exp;
217 int exp_used;
218 int momentum;
219 int max_momentum;
220 int momentum_reset;
221 int health;
222 int spirit;
223 int supply;
224 int wounded;
225 int unprepared;
226 int shaken;
227 int encumbered;
228 int maimed;
229 int cursed;
230 int corrupted;
231 int tormented;
232 };
234 struct entry {
235 LIST_ENTRY(entry) entries;
236 char name[255];
237 int id;
238 };
240 #endif