Question: 1. Problem Statement: Before computers and network speeds were fast enough for online multiplayer games to have high-quality graphics, text-based multi-user dungeons (text MUDs) were

1. Problem Statement: Before computers and network speeds were fast enough for online multiplayer games to have high-quality graphics, text-based multi-user dungeons (text MUDs) were common. In these games, players can explore the map, fight enemies, and perform other actions, given only textual descriptions of the world around them. While rudimentary, they are relatively simple to program, and the creative possibilities are endless. In fact, some MUDs have been active for decades and are still thriving. The goal of project 6 and project 7 is to create a small text-based dungeons and dragons inspired game. In project 6, we will focus on designing and implementing a Monster class with a simple combat system. In project 7, we will create a Room class, where each room will contain one or more monsters. Students will be provided with a Dungeon class that combines Monsters and Rooms to implements a simple game engine. Detailed requirements for this project are described below.

2. Design: When working on large software projects, its important to spend plenty of time in the design phase before actually writing code. Because the purpose of this game is for the player to explore a dungeon, we can think of a dungeon as a series of rooms that are connected in some way. We might therefore write a Dungeon class that contains an array of Room objects. Furthermore, since each room might contain one or more Monsters, we can design our Room class to hold an array of Monster objects. To implement this idea, we will start with the simplest class Monster and then move outward.

The Monster class will have the following attributes:

Access| Type| Name |Value

Private| string | name | tba

Private int health tba

Private int strength tba

Private int defense tba

Private int speed tba

Private static const int MAX_HEALTH 100

Private static const int MAX_STRENGTH 50

Private static const int MAX_DEFENSE 100

Private static const int MAX_SPEED 20

The first five Monster attributes do not have a specific value. They will depend on the Monster. The last four attributes are static constants, meaning no Monster can ever have a health exceeding 100, strength exceeding 50, defense exceeding 100, or speed exceeding 20.

The Monster class will have the following methods/functions:

Access | Return type | Name Inputs | Purpose

Public | none | Monster | none | Default constructor

Public none Monster Five Monster attributes Non-default constructor

Public none Monster One monster Copy constructor

Public none ~Monster none Destructor

Public string getName none Accessor

Public int getHealth none Accessor

Public int getStrength none Accessor

Public int getDefense none Accessor

Public int getSpeed none Accessor

Public void setName string Mutator

Public void setHealth int Mutator

Public void setStrength int Mutator

Public void setDefense int Mutator

Public void setSpeed int Mutator

Public void attack One monster Simulate one Monster attacking another Monster

Public void print none Print all five Monster attributes

Most of the method descriptions are straightforward, but special rules apply when monster1 attacks monster2. To make the battle interesting, we will use randomness to determine if monster2 can dodge monster1 attack, and if not, how much damage is done to monster 2. To do so, you must implement the following logic:

The attack speed of monster1 is a random value between 1 and monster1.speed.

The dodge speed of monster2 is a random value between 1 and monster2.speed.

The attack power of monster 1 is a random value between 1 and monster1.strength

When monster2 dodge speed > monster1 attack speed, then monster2 successfully dodges the monster1 attack and no damage occurs.

If monster2 does not dodge monster1, then monster2.defense tells us the percentage of the monster1 attack power that is deflected from monster2

. If monster2.defense = 0 then monster2 has no protection, and monster2.health is reduced by the monster1 attack power.

If monster2.defense = 100 then monster2 is invincible to the attack, and monster2.health is not reduced.

If the health of monster2 goes to zero, the monster dies.

3. Implementation: Your first task is to implement the Monster class interface in monster.h. Then, you should create skeleton implementations of all Monster class methods in monster.cpp that simply print out the names of each method. Next, you should create main.cpp that simply calls each of the monster methods to verify they are working as expected. Once this is working, you can add implementations of monster methods one at a time and run your main program to verify their correctness. Your second task is to extend your program in main.cpp to declare an array of N Monster objects and read monster information from an input file monster.txt to initialize this array objects. The format of this file is very simple. The first line contains an integer N that specifies how many monsters are in the file. After this, there are N*5 lines in the file that contain the attributes of each monster. The order of these attributes matches the order of attributes in the class specifications above. To verify that you have successfully created your array of monsters, you should loop over the array to print out the attributes of each monster. Your final task is to test the attack method by asking the user to select two numbers A and B between 0 and N-1 and then write a loop that has monster[A] and monster[B] take turns attacking each other until one of the monsters die. Your program should print the results of each attack move, showing the damage done to the defense and health of each monster at each step.

4. Testing: Test your program to check that it operates correctly for all of the requirements listed above. Also check for the error handling capabilities of the code. Try your program with several input values, and save your testing output for inclusion in your project report

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!