1. Let's make the game more playable! Currently, the player wins every other round and each game consists of a single turn. We want to change this! Create a new global variable named computerHealth and initialize it to 100. Inside the loop that represents a single game being played, place another loop. This loop will represent a single round of a game. In each iteration of the inner loop: • The computer will attack the player for a value between 0 and 50. • The player will choose an action (heal, block, special, or regular) • Make the calculated adjustments to computerHealth and playerHealth · If the player health goes below 0, count it as a player loss and break out of the inner loop. • If the computer health goes below 0, count it as a player win and break out of the inner loop. · Otherwise, the inner loop will iterate again (i.e. the computer will attack and the player will pick another action). • You can remove the previous logic of determining a winner based on if it's an even or odd round. 2. Update the block function to "return" two values. It should have one value parameter (computerDamage from before) and two reference parameters (named blockAmount and hitAmount). The function should calculate how much of the attack the user blocks. To do this, select a random number between O and computerDamage and assign it to blockAmount. After determining how much of computerDamage is blocked, assign the rest to hitAmount. In main, print the value of each (we will have access to both since the arguments will be passed by reference). 3. Update your program so that when the user decides to quit, it saves the number of wins and losses to a file. When the program starts, load the data (if it exists). When the program ends, overwrite the previous data with the updated data. You can simply put the number of wins in the first line of the file and the number of losses in the second line.
1. Let's make the game more playable! Currently, the player wins every other round and each game consists of a single turn. We want to change this! Create a new global variable named computerHealth and initialize it to 100. Inside the loop that represents a single game being played, place another loop. This loop will represent a single round of a game. In each iteration of the inner loop: • The computer will attack the player for a value between 0 and 50. • The player will choose an action (heal, block, special, or regular) • Make the calculated adjustments to computerHealth and playerHealth · If the player health goes below 0, count it as a player loss and break out of the inner loop. • If the computer health goes below 0, count it as a player win and break out of the inner loop. · Otherwise, the inner loop will iterate again (i.e. the computer will attack and the player will pick another action). • You can remove the previous logic of determining a winner based on if it's an even or odd round. 2. Update the block function to "return" two values. It should have one value parameter (computerDamage from before) and two reference parameters (named blockAmount and hitAmount). The function should calculate how much of the attack the user blocks. To do this, select a random number between O and computerDamage and assign it to blockAmount. After determining how much of computerDamage is blocked, assign the rest to hitAmount. In main, print the value of each (we will have access to both since the arguments will be passed by reference). 3. Update your program so that when the user decides to quit, it saves the number of wins and losses to a file. When the program starts, load the data (if it exists). When the program ends, overwrite the previous data with the updated data. You can simply put the number of wins in the first line of the file and the number of losses in the second line.
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
C++ Question:
Hello based on the attached code picture, please update that code so it can follow the instructions given in the other picture. Thank you.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 3 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY