Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

RPG textual game. c++ There is an abstract Monster class. Each monster has a name. Each monster has a health value. Each monster has an

RPG textual game. c++

There is an abstract Monster class. Each monster has a name. Each monster has a health value. Each monster has an attack strength that is used to inflict damage to the hero.

When the hero or a monster is hit, the corresponding health decreases.

There are derived classes from the Monster class named Vampire, Werewolf, Zombie.

The Hero class is defined in Hero.cpp and has a header file Hero.h

The Monster class is declared in Monster.h

The Vampire class is defined in Vampire.cpp and has a header file Vampire.h A vampire has an attack strength of 15.

The Werewolf class is defined in Werewolf.cpp and has a header file Werewolf.h A werewolf has an attack strength of 20.

The Zombie class is defined in Zombie.cpp and has a header file Zombie.h A zombie has an attack strength of 30.

When the game starts, all the monsters are in a vector and in particular, there are: A. 4 vampires B. 3 werewolves C. 2 zombies

At the start of the game, there is a single hero.

There is a file called Driver.cpp that contains the main() function.

The game consists of a loop that keeps going until either the hero dies or all the monsters die: 1. If the hero dies, the game prints "Game Over" 2. If all the monsters die, the game prints "Victory!" 3. If the hero and at least one monster are still alive, the game loop continues.

There is an abstract base class called Weapon.

The Pistol class defines a weapon with 8 bullets, each with a damage of 10. When there are no bullets left, the pistol cannot be used.

The Knife class is a weapon that can be used as many times as the player likes. The knife has a damage of 15.

The Bow class defines a weapon with 11 arrows. Each arrow has a damage of 20. When there are no arrows left, the bow cannot be used.

The Pistol class is defined in Pistol .cpp and has a header file Pistol .h

The Knife class is defined in Knife.cpp and has a header file Knife.h

The Bow class is defined in Bow.cpp and has a header file Bow.h

The game asks the player to choose a weapon at the start of each turn.

The chosen weapon will try to kill the currently active monster.

Monsters attach one at a time (like in Bruce Lee movies.)

The overall sequence of the game is:

1. A list of the monsters still alive is printed.

2. The strength of the hero is printed as well.

3. The active monster is highlighted and its strength is printed.

4. A menu appears asking which weapon the player wants to use: (1) Pistol (2) Knife (3) Bow&Arrows

5. Once the player selects a weapon, the active monster is hit with it.

6. The game prints how much health the active monster has left (if the monster is now dead, the game should say so.) A monster dies when its energy is zero or less.

7. If the active monster is still alive, it will fight back, damaging the hero, otherwise the game loop will go back to step 1.

8. If the active monster is now dead, and there are no more monsters, the game prints "Victory!"

9. If the health of the hero is zero or less, the game prints "Game Over" and exits.

10. If the hero and at least one monster are still alive, the game loop continues from 1.

IMPORTANT: the player can select a weapon with no bullets left (or arrows left) but it will NOT work. For instance, the game will print "The hero shoots the pistol, but it does not work!"

Example of the output of a game session: You are surrounded by 4 vampires, 3 werewolves, and 2 zombies. The hero's strength is 200. Vampire Alfredo (15) is attaching the hero. What weapon does the hero want to use: (1) Pistol(8) (2) Knife (3) Bow&Arrows(11) Choice: _1_ The hero shoots the vampire(5). The vampire attacks the hero(185) You are surrounded by 4 vampires, 3 werewolves, and 2 zombies. The hero's strength is 185. Vampire Alfredo (5) is attaching the hero. What weapon does the hero want to use: (1) Pistol(7) (2) Knife (3) Bow&Arrows(11) Choice: _2_ The hero stubs the vampire(-10). The vampire is dead. You are surrounded by 3 vampires, 3 werewolves, and 2 zombies. The hero's strength is 185. Vampire Mario (15) is attaching the hero.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books

Students also viewed these Databases questions