commit 26419756f3b2d085780fdeef7275f9973119261f Author: Seoxi Ryouko Date: Wed May 28 09:31:58 2025 -0500 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fda8714 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/game diff --git a/game.c b/game.c new file mode 100644 index 0000000..9b5a0f2 --- /dev/null +++ b/game.c @@ -0,0 +1,59 @@ +#include +#include +#include + +bool check_str_is_int(char *s) { + while (*s != '\0') { + char a = *s - '0'; + if (a < 0 || a > 9) return false; + s++; + } + return true; +} + +void usage(char *arg0, int ret) { + printf("USAGE:\n%s [starting life total]\nruns through games of ragavan vs bolt\n", arg0); + exit(ret); +} + +typedef enum { + Ragavan, + Bolt +} SpellType; + +typedef struct { + int life_total; + int deck_mountains; + int deck_spells; + int hand_mountains; + int hand_spells; + SpellType spell_type; +} Player; + +Player *new_player(int life_total, SpellType spell_type) { + Player *p = malloc(sizeof(Player)); + *p = (Player) { + .life_total = life_total, + .deck_mountains = 20, + .deck_spells = 40, + .hand_mountains = 0, + .hand_spells = 0, + .spell_type = spell_type + }; + return p; +} + +int main(int argc, char **argv) { + int max_life; + if (argc < 2) { + max_life = 20; + } else { + if(!check_str_is_int(argv[1])) usage(*argv, 1); + max_life = atoi(*argv); + } + printf("%d\n", max_life); + Player *stupid_fucking_monkey = new_player(max_life, Ragavan); + Player *sparky = new_player(max_life, Bolt); + + return 0; +}