// Project identifier: 9504853406CBAC39EE89AA3AD238AA12CA198043 #include #include #include #include #include #include #include #include #include #include #include #include #include #include "battle.h" using namespace std; int main(int argc, char** argv){ // PROCESS COMMAND LINE Line_args line_args; Game game; process_cmd_line(argc, argv, line_args); initialize(game); //for cin string junk = ""; //init round info game.current_round = 1; uint32_t quiver = 0; bool game_over = false; string last_killed = ""; while(!game_over){ cin >> junk; // read round info int round_num = 0; uint32_t rand_zomb = 0; uint32_t named_zomb = 0; cin.ignore(256, ' '); // read round cin >> round_num; //cout << current_round << "\n"; while(game.current_round < round_num){ if(line_args.verbose){ cout << "Round: " << game.current_round << "\n"; } //run round //refill quiver quiver = game.quiver_cap; if(!game.zombies.empty()){ advance_zombies(game, line_args, game_over); } load_zombies(game); shoot_zombies(quiver, game, line_args, last_killed); //median //cout << last_killed << "\n"; //If the --median flag is enabled, AND any zombies have been destroyed so far, display a message about the median time that zombies have been active. If there are an even number, take the average of the “middle two”, with integer division. For example: //If there are no more zombies and none will be generated in a future round, then you have won the battle. cin >> std::ws; if(cin.eof() && game.zombie_queue.empty()){ if(line_args.median && game.get_median){ print_median(game); } if(line_args.verbose){ print_victory(game.current_round, last_killed); } game_over = true; exit(0); } // MEDIAN if(line_args.median && game.get_median){ print_median(game); } game.current_round++; inc_rounds_active(game); } //else if(round_num == game.current_round){ // VERBOSE if(line_args.verbose){ cout << "Round: " << game.current_round << "\n"; } cin >> junk; cin >> rand_zomb; cin >> junk; cin >> named_zomb; //refill quiver quiver = game.quiver_cap; if(!game.zombies.empty()){ advance_zombies(game, line_args, game_over); } create_zombies(rand_zomb, named_zomb, game.zombies, line_args, junk); load_zombies(game); shoot_zombies(quiver, game, line_args, last_killed); //median //cout << last_killed << "\n"; //If the --median flag is enabled, AND any zombies have been destroyed so far, display a message about the median time that zombies have been active. If there are an even number, take the average of the “middle two”, with integer division. For example: //If there are no more zombies and none will be generated in a future round, then you have won the battle. cin >> std::ws; if(cin.eof() && game.zombie_queue.empty()){ // MEDIAN if(line_args.median && game.get_median){ print_median(game); } print_victory(game.current_round, last_killed); //Print any required messages and statistics. The battle ends. // STATS if(line_args.stats){ print_stats(game, line_args); } game_over = true; exit(0); } // MEDIAN if(line_args.median && game.get_median){ print_median(game); } game.current_round++; inc_rounds_active(game); } // } return 0; }