Beispiel #1
0
void create() {
    ::create();
    SetProperty("light", 2);
    SetProperty("night light", 1);
    SetProperty("no castle", 1);
    SetShort( "An open courtyard in the orc fortress");
    SetLong(
            "The courtyard around you is surrounded by ancient stone walls "
            "that gives this fortress the feeling of impregnability.  An "
            "impressive archway south opens out into Orc Valley.  "
            "There are passages east and west.");
    SetItems(
            (["courtyard" : "An open yard walled in by stone walls on every side.",
             "yard" : "It has no roof, but the walls are so high you "
             "can see only sky.",
             "stone" : "A grey stone of unknown origin.  There are "
             "writings on it.",
             "walls" : "You cannot get beyond them unnaturally.",
             "fortress" : "It looks extremely old.",
             "arch" : "A huge, heavily guarded entrance to the fortress.",
             "archway" : "It forms the huge, heavily guarded entrance to "
             "the fortress.",
             "valley" : "You cannot see any of it from inside the courtyard.",
             "passages" : "They lead to the inner parts of the fortress.",
             "passage" : "You have no idea where it might lead."]) );
    SetExits( 
            (["east" : "/domains/Praxis/orc_valley/passage1",
             "west" : "/domains/Praxis/orc_valley/passage2",
             "north" : "/domains/Praxis/orc_valley/shaman",
             "south" : "/domains/Praxis/orc_valley/guard"]) );
    SetSearch( 0, "Search what?");
    SetSearch( "walls", "You notice a secret passage in the north wall.");
    SetSearch("wall", "Which wall?");
    SetSearch("north wall", "You notice a secret passage.");
}
int main() {
    stringset strset;
    SetNew(&strset, StringCompare, NULL);

    assert(SetAdd(&strset, "lion"));
    assert(SetAdd(&strset, "tiger"));
    assert(SetAdd(&strset, "bear"));

    SetAdd(&strset, "dorothy");
    SetAdd(&strset, "scarecrow");
    SetAdd(&strset, "witch");
    SetAdd(&strset, "tin man");
    SetAdd(&strset, "wizard");

    assert(!SetAdd(&strset, "lion"));
    assert(!SetAdd(&strset, "tiger"));
    assert(!SetAdd(&strset, "bear"));

    SetPrint(&strset);

    printf("\nSet contains %d elements\n", SetSize(&strset));

    char *dorothy = SetSearch(&strset, "dorothy");
    char *elphaba = SetSearch(&strset, "elphaba");

    printf("\n");
    printf("Found dorothy: %s\n", dorothy == NULL ? "no" : "yes");
    printf("Found elphaba: %s\n", elphaba == NULL ? "no" : "yes");

    SetDestroy(&strset);

    return 0;
}