thrive/01_text_adventure/predicate.c

20 lines
452 B
C
Raw Normal View History

2025-01-13 19:56:15 -05:00
#include <stdio.h>
#include <string.h>
#include "game.h"
#include "flag.h"
#include "predicate.h"
bool predicate_fulfilled(Game *g, Predicate *p) {
switch (p->type) {
case PREDICATE_TRUE:
return true;
case PREDICATE_IN_ROOM:
return strcmp(g->current_room->name, p->argument) == 0;
case PREDICATE_FLAG_ENABLED:
return flag_value(g->flags, p->argument) > 0;
default:
printf("Invalid predicate type\n");
return false;
}
}