Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include <stdbool.h>
- typedef struct {
- int id;
- char *type;
- int delta[4];
- int price, tome_index, tax_count;
- bool castable, repeatable;
- } ACTION;
- typedef struct {
- int inv[4];
- int score;
- } INVENTORY;
- int main() {
- INVENTORY myInv;
- ACTION firstAction;
- ACTION lastAction;
- // game loop
- while (1) {
- // the number of spells and recipes in play
- int action_count;
- scanf("%d", &action_count);
- fprintf(stderr, "%d\n", action_count);
- ACTION *actions = (ACTION *) malloc(action_count * sizeof(ACTION));
- INVENTORY *invs = (INVENTORY *) malloc(action_count * sizeof(INVENTORY));
- for (int i = 0; i < action_count; i++) {
- // the unique ID of this spell or recipe
- int action_id;
- // in the first league: BREW; later: CAST, OPPONENT_CAST, LEARN, BREW
- char action_type[21];
- // tier-0 ingredient change
- int delta_0;
- // tier-1 ingredient change
- int delta_1;
- // tier-2 ingredient change
- int delta_2;
- // tier-3 ingredient change
- int delta_3;
- // the price in rupees if this is a potion
- int price;
- // in the first two leagues: always 0; later: the index in the tome if this is a tome spell, equal to the read-ahead tax; For brews, this is the value of the current urgency bonus
- int tome_index;
- // in the first two leagues: always 0; later: the amount of taxed tier-0 ingredients you gain from learning this spell; For brews, this is how many times you can still gain an urgency bonus
- int tax_count;
- // in the first league: always 0; later: 1 if this is a castable player spell
- bool castable;
- // for the first two leagues: always 0; later: 1 if this is a repeatable player spell
- bool repeatable;
- int _castable;
- int _repeatable;
- scanf("%d%s%d%d%d%d%d%d%d%d%d", &action_id, action_type, &delta_0, &delta_1, &delta_2, &delta_3, &price,
- &tome_index, &tax_count, &_castable, &_repeatable);
- fprintf(stderr, "%d %s %d %d %d %d %d %d %d %d %d\n", action_id, action_type, delta_0, delta_1, delta_2, delta_3, price,
- tome_index, tax_count, _castable, _repeatable);
- ACTION action = {
- .id = action_id,
- .type = action_type,
- .delta = {delta_0, delta_1, delta_2, delta_3},
- .price = price,
- .tome_index = tome_index,
- .tax_count = tax_count,
- .repeatable = repeatable
- };
- //*(actions + i) = action;
- actions[i] = action;
- }
- for (int i = 0; i < 2; i++) {
- // tier-0 ingredients in inventory
- int inv_0;
- int inv_1;
- int inv_2;
- int inv_3;
- // amount of rupees
- int score;
- scanf("%d%d%d%d%d", &inv_0, &inv_1, &inv_2, &inv_3, &score);
- fprintf(stderr, "%d %d %d %d %d\n", inv_0, inv_1, inv_2, inv_3, score);
- INVENTORY inv = {
- .inv = {inv_0, inv_1, inv_2, inv_3},
- .score = score
- };
- //*(invs + i) = inv;
- invs[i] = inv;
- }
- myInv = invs[0];
- firstAction = actions[0];
- lastAction = actions[action_count - 1];
- // Write an action using printf(). DON'T FORGET THE TRAILING \n
- // To debug: fprintf(stderr, "Debug messages...\n");
- // in the first league: BREW <id> | WAIT; later: BREW <id> | CAST <id> [<times>] | LEARN <id> | REST | WAIT
- printf("BREW 0\n");
- free(actions);
- free(invs);
- exit(0);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment