fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3. int main_menu();
  4. bool rules();
  5. int difficulty();
  6. int combat_main();
  7. int combat_hero(int,int,int,int);
  8. int combat_nemesis(int,int,int,int);
  9. int combat_resolve(int,int,int&,int&,int&,int&);
  10. int combat_end(int,int);
  11. int main_menu();
  12. bool rules();
  13. int combat_main()
  14. {
  15. int play_again=0;
  16. do
  17. {
  18. bool active_battle=1;
  19. cout << "Let the battle begin! Show no mercy!\n" << '\n';
  20. int round_number=0;
  21. int hero_health=5;
  22. int hero_energy=2;
  23. int nemesis_health=5;
  24. int nemesis_energy=2;
  25. do
  26. {
  27. if((hero_health<1)||(nemesis_health<1))
  28. {
  29. active_battle=0;
  30. }
  31. //recognizes that battle has ended
  32. else
  33. {
  34. ++round_number;
  35. cout << "Round " << round_number << '\n' << '\n';
  36. int hero_action= combat_hero(hero_health,hero_energy,nemesis_health,nemesis_energy);
  37. //receives player's choice of action
  38. int nemesis_action= combat_nemesis(hero_health,hero_energy,nemesis_health,nemesis_energy);
  39. //decides AI's choice of action
  40. combat_resolve(hero_action,nemesis_action,hero_health,hero_energy,nemesis_health,nemesis_energy);
  41. //decides round outcome from hero_action and nemesis_action
  42. if(hero_action==0)
  43. {
  44. hero_health=0;
  45. //automatically ends battle if player opts to concede defeat
  46. }
  47. }
  48. }
  49. while(active_battle==1);
  50. //cycles combat rounds until one opponent loses
  51. play_again=combat_end(hero_health,nemesis_health);
  52. //prompts player with option to play again at end of battle
  53. }
  54. while(play_again==1);
  55. //repeats if "play again" selected after battle ends
  56. return play_again;
  57. }
  58. int main()
  59. {
  60. }
  61. int combat_hero(int hero_health,int hero_energy,int nemesis_health,int nemesis_energy) { return 42; }
  62. int combat_nemesis(int hero_health,int hero_energy,int nemesis_health,int nemesis_energy) { return 42; }
  63. int combat_resolve(int hero_action,int nemesis_action,int &hero_health,int &hero_energy,int &nemesis_health,int &nemesis_energy) { return 42; }
  64. int combat_end(int hero_health,int nemesis_health) { return 42; }
  65.  
Success #stdin #stdout 0s 3292KB
stdin
Standard input is empty
stdout

Standard output is empty