Пример #1
0
static void
generate_map(struct rnd *rnd, FILE *out)
{
    struct treasure_map treasure_map;
    treasure_map_initialize(&treasure_map);
    treasure_map_generate(&treasure_map, rnd);
    fprintf(out, "%s\n", treasure_map.true_description);
    enumerate_treasure_items(&treasure_map.treasure, out);
    treasure_map_finalize(&treasure_map);
}
Пример #2
0
void
treasure_map_initialize_from_json_object(struct treasure_map *treasure_map,
                                         struct cJSON *json_object)
{
    treasure_map_initialize(treasure_map);

    if ( ! cJSON_IsObject(json_object)) return;
    if ( ! json_object_has_struct_member(json_object, "treasure_map")) return;

    treasure_map->is_false = json_object_get_bool_value(json_object, "is_false", false);

    struct cJSON *treasure = cJSON_GetObjectItemCaseSensitive(json_object, "treasure");
    treasure_initialize_from_json_object(&treasure_map->treasure, treasure);

    treasure_map->true_description = json_object_alloc_string_value(json_object, "true_description", NULL);
}