For this quest, you are going to start with the Attribute and Monster structs from the previous quest and write several functions (NOTE: I've renamed the Monster struct to Object). You will have to decide the return type and parameters! 1. printType(); a. will use a switch to print to the console an object's type. 2. loadGame() a, this function will load a saved game from a file. b. The file is structured such that the first item in the file is the number of objects. c. Each object in the file starts with the integer value for the Object::Type enum followed by values for all the attributes. 3. saveGame() a. This function is called when a player quits the game in the middle of a battle. b. The number of monsters +1 is first output to the file

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

For this quest, you are going to start with the Attribute and Monster structs from the previous quest and write several functions (NOTE: I've renamed the Monster struct to Object). You will have to

decide the return type and parameters!

1. printType();

a. will use a switch to print to the console an object's type.

2. loadGame()

a, this function will load a saved game from a file.

b. The file is structured such that the first item in the file is the number of objects.

c. Each object in the file starts with the integer value for the Object::Type enum followed by values for all the attributes.

3. saveGame()

a. This function is called when a player quits the game in the middle of a battle.

b. The number of monsters +1 is first output to the file

c. Each object (starting with the player) has the integer value of their name output followed by all the object's attributes.

4. displayBattle();

a. outputs to the console the player's information and a numbered list of monsters along with their health.

5. monsterAttack();

a loops over all monsters in the vector of monsters and, if they are not dead, has them attack the player by calling the defend and attack methods (as mentioned below).

b. returns true if all monsters are dead.

6. playerAttack();

a. Asks the user for an integer between 1 and monsters.size() and has the player attack that monster using the defend and attack methods (as mentioned below).

7. attack().

a. Output the attacking object's type and the string deals" to the console

b. uses a normal distribution with the mean being the attacker's strength and the standard deviation being 1 divided by the attacker's accuracy to calculate the damage done and return it..

8. defend():

a. outputs the passed-in damage integer and the string" damage to", along with the

defending object's type to the console. b. Uses the defending object's AC as the mean for a uniform distribution and the defender's level as the standard deviation to calculate the object's defense. This amount is subtracted from the incoming damage (ensuring it does not go below 0) c. subtracts the calculated damage amount from the defending object's HP.

d. Usage:: defend(monsters.at(0), attack(player)); 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education