/* Use command */ void doUse() { char *sp; char *item; /* Command line should be like "U[SE] ITEM" Item name will be after after first space. */ sp = strchr(buffer, ' '); if (sp == NULL) { printf("Use what?\n"); return; } item = sp + 1; /* Make sure item is being carried or is in the current location */ if (!carryingItem(item) && !itemIsHere(item)) { printf("I don't see it here.\n"); return; } ++turnsPlayed; /* Use key */ if (!strcasecmp(item, "key") && (currentLocation == FrontEntrance)) { printf("You insert the key and unlock the door.\n"); Move[FrontEntrance][North] = Vestibule; return; } /* Default */ printf("Nothing happens\n"); }
/* Examine command */ void doExamine() { char *sp; char *item; /* Command line should be like "E[XAMINE] ITEM" Item name will be after after first space. */ sp = strchr(buffer, ' '); if (sp == NULL) { printf("Examine what?\n"); return; } item = sp + 1; ++turnsPlayed; /* Examine bookcase - not an object */ if (!strcasecmp(item, "bookcase")) { printf("You pull back a book and the bookcase\nopens up to reveal a secret room.\n"); Move[17][North] = 18; return; } /* Make sure item is being carried or is in the current location */ if (!carryingItem(item) && !itemIsHere(item)) { printf("I don't see it here.\n"); return; } /* Examine Book */ if (!strcasecmp(item, "book")) { printf("It is a very old book entitled\n\"Apple 1 operation manual\".\n"); return; } /* Examine Flashlight */ if (!strcasecmp(item, "flashlight")) { printf("It doesn't have any batteries.\n"); return; } /* Examine toy car */ if (!strcasecmp(item, "toy car")) { printf("It is a nice toy car.\nYour grandson Matthew would like it.\n"); return; } /* Examine old radio */ if (!strcasecmp(item, "old radio")) { printf("It is a 1940 Zenith 8-S-563 console\nwith an 8A02 chassis. You'd turn it on\nbut the electricity is off.\n"); return; } /* Nothing special about this item */ printf("You see nothing special about it.\n"); }
/* Examine command */ void doExamine() { char *sp; char *item; /* Command line should be like "E[XAMINE] ITEM" Item name will be after after first space. */ sp = strchr(buffer, ' '); if (sp == NULL) { printf("Examine what?\n"); return; } item = sp + 1; ++turnsPlayed; /* Examine fireplace - not an object */ if (!strcasecmp(item, "fireplace")) { printf("On either side of the fireplace are\nsecret panels, which now open and\nreveal staircases.\n"); Move[Study][Up] = Hallway11; Move[Study][Down] = Stairs3; return; } /* Make sure item is being carried or is in the current location */ if (!carryingItem(item) && !itemIsHere(item)) { printf("I don't see it here.\n"); return; } /* Examine Book */ if (!strcasecmp(item, "book")) { printf("It is a very old book entitled\n\"Apple 1 operation manual\".\n"); return; } /* Examine Flashlight */ if (!strcasecmp(item, "flashlight")) { printf("It doesn't have any batteries.\n"); return; } /* Examine toy car */ if (!strcasecmp(item, "toy car")) { printf("It is a nice toy car.\nYour grandson Matthew would like it.\n"); return; } /* Nothing special about this item */ printf("You see nothing special about it.\n"); }