void wumpus_loop() { in an infinite loop do { // init cave // Use default constructor to create a (empty) cave cout << "\nMade a cave!"; in an infinite sub-loop { cout << "\n"; // get hazard warnings for your position in the cave // get the room description // get player's turn: shoot or move? cout << "Shoot or move (S-M)?\n"; while (cin>>ch && !(ch=='m' || ch=='s')) { // clear the buffer cin.ignore(numeric_limits::max(),'\n'); cout << "Shoot or move (S-M)?\n"; } cin.ignore(numeric_limits::max(),'\n'); if move { // get label of room to move to, move player while (true) { cout << "Where to?\n"; int lbl = get_int(); if (c.move_player(lbl)) break; } // check for Wumpus if player's location is wumpus location { cout << "...oops! Bumped a Wumpus!\n"; wake the wumpus; if player location is wumpus location { cout << "Tsk tsk tsk - Wumpus got you!\n"; cout << "Ha ha ha - you lose!\n"; break; } } // check for bat while player location has bat { cout << "Zap - super bat snatch! Elsewhereville for you!\n"; call bat flight; } // check for pit if player location has pit cout << "Yyyiiiieeee... fell in pit!\n" << "Ha ha ha - you lose!\n"; break; } } else { Game_state gs = c.shoot_arrow(); switch (gs) { case plr_shot: cout << "Ouch! Arrow got you!\n" << "Ha ha ha - you lose!\n"; break; case no_arrows: cout << "You have run out of arrows!\n" << "Ha ha ha - you lose!\n"; break; case wmp_dead: cout << "Aha! You got the Wumpus!\n" << "Hee hee hee - the Wumpus'll getcha next time!\n"; break; default: // everybody is alive, wake up Wumpus c.wake_wumpus(); break; } if (gs!=running) break; } // check if at end of round Wumpus is in the same room if (c.get_player_loc() == c.get_wumpus_loc()) { cout << "Tsk tsk tsk - Wumpus got you!\n"; cout << "Ha ha ha - you lose!\n"; break; } } cout << "Play again?\n"; char ch; cin >> ch; if (ch!='y') break; cin.ignore(numeric_limits::max(),'\n'); } }