Question: C++ need help getting code for this everyone i asked wasn't able to figure it out Create a Game! SKILL SET: Using abstract base classes,
C++ need help getting code for this everyone i asked wasn't able to figure it out
Create a Game! SKILL SET: Using abstract base classes, polymorphism and virtual functions Write a program that uses class, inheritance, and polymorphism to have three different kinds of characters battle in a simple game. There are three different types of characters but they have some common characteristic that will be in an abstract base class called Character: Character has the following data: ? Name ? Health points (HP) ? Experience points (XP) everyone starts at 0. ? Points to next level ? MaxHP (same as starting HP) You will derive three new classes from this base class: ? Novice: has the additional attribute of luck (int). ? Knight: has the additional attribute of weapon name, weapon power(int), armor(int). ? Wizard: has the additional attribute of magic poiwer source (divine or arcane) (int) Attribute Values (feel free to modify the actual numbers, the idea is that they all have different values) Novice Knight Wizard HP starts at 80 XP starts at 0 Points to next level starts at 10 Luck starts at (0 or 1) HP starts at 120 XP starts at 0 Points to next level starts at 10 Armor starts at 1 HP starts at 100 XP starts at 0 Points to next level starts at 10 I am suggesting a very simple system in terms of fighting. When fighting during the game, a character generates attack (damage) points as described below. Compare the attack points to the strength (AC) of the monster. ? If players attack is greater than AC then you win. You gain experience points. UpdateXP based on the monsters level points. When XP reaches a certain amount (points to next level) you level up and gain some increase in all stats. ? Otherwise you lose. You lose hit/health points. UpdateHP with the monsters AC. This way you are not keeping up with the HP of the monster. But if you want to make different rules thats fine, just write it up in your lab report. [If you want to do separate attack and damage points, feel free. Just describe your system in your lab report] NOTE: feel free to adjust any of these numbers. The idea is that the three classes have DIFFERENT behaviors. Novice Knight Wizard Attack points A random number from 1 10 + luck value A random number from 10 20 + weapon power A random number from 5 15 + magic bonus (2 points if arcane, 5 points if divine) XP Plus monster level points Plus (monster level 1) Plus (monster level 2) Game Lab Page 2 HP Loses enemy damage Loses (enemy damage armor) Loses (enemy damage magic/enemy damage) Points to level up Every 10 points Every 15 points Every 12 points HP increases by 10. Luck increases by a random number from (3 5) HP increases by 15. Armor increases by 1 HP increases by 8. Magic increases by 3 Behaviors print() Prints all the data specific to that character getAttack() Generates and returns attack points as specified above updateHP(int) Takes damage as a parameter. Reduce HP as indicated above updateXP(int) Takes monsters level points as a parameter. Adjust XP as indicated above. Then check for level up. If there is level up then adjust stats, and increment next level points by 10 (or by different amounts for each class?) heal() Restores HP to maxHP value. Create abstract methods shown above that will be defined in each of the classes to implement the correct behavior. Then derive the three classes from that base class. Create and test each of these 3 classes one at a time! Each derived class MUST have a parameterized constructor, and definitions for all virtual functions specific to that class. NOTE THAT YOU MUST USE PARAMETERIZED CONSTRUCTORS in order to create and initialize your objects. You will create a vector of base class pointers. As players are created, use your parameterized constructor to create the appropriate object. This vector will store all the data. Polymorphism and your abstract functions will process the data correctly for each type of player. Any questions, ask me before you go too far in your coding! Your game will need monsters to fight. You can randomly selects one of 3 preset monsters to fight, here are some ideas: *AC = armor class points 1 - Troglodyte, AC = 10, HP = 10, level = 2 2 - Orc Warrior, AC = 15, HP = 15, level = 3 3 - Black Dragon, AC = 20, HP = 20, level = 4 Or make a Monster class if you want and then create a vector of monsters to select from You will need to adjust points to make this all work in a fun way. Once your classes are created and tested, you can create a game! If you have these building blocks and they are all tested you can create whatever you want! The game will allow you to create a vector of various characters (using base class pointers). I have two suggestions, or you can create your own. Option 1: During the game, the player can: 1 Create a character (USING parameterized constructors) 2 Print all character stats Game Lab Page 3 3 Select a character 4 - Quit Option 3: once you select a character, a new menu appears: 1 search for battle 2 rest 3 quit If you search for battle, a monster is randomly selected and is displayed. Your options are 1 Fight 2 Flee You should display results of battle each time there is a fight. OR Starts with a text block premise: "The [Final Boss] is [1000] miles away from the kingdom. Create a team and build up strength to defeat him before it's too late!" The distance will gradually decrease after each round until the Boss is either defeated or it reaches the kingdom in which case, it's Game-over. From there, go into a Menu system: - 1. Explore the wilderness 2. Rest 3. Character Stats 4. Confront the [Final Boss] 5. Quit So this means that we can actually fight the Final Boss at any moment, but the idea is that Its going to be a monster difficult enough that we cant beat it immediately and have to build of levels and power. So it then becomes a trade off of how long can we fight and grow without risking the Boss reaching its destination. For the fighting system (option 1 in Menu) you can choose either to Fight or Flee. And when you choose Fight, each party member will attack and at the end of those 3 hits, the enemy will randomly attack a member. You will have the option of Fight or Flee each round of the battle if it takes more than 1 round. For Resting (Menu option 2), all are restored to full health, but the tradeoff will be that the Final Boss moves closer. **Generating Random Numbers The function rand() returns a random number, i. e. y = rand(); //assigns a value in the range 0 to 32767 To limit the range of the random number, use the following formula lower + rand() % (upper lower + 1) For example, to generate numbers between 1=lower and 10=upper: 1 + rand() % (10 1 + 1) or simplify as Game Lab Page 4 1 + rand() % 10 For numbers between 10=lower and 100=upper 10 + rand() % (100 10 + 1) or simplify as 10 + rand() % 91 To get different numbers with each run of the program, you need to seed the random number generator using the srand function. You essentially give the random number generator a starting value. A good way to get different numbers every time is to use the built-in time function as the seed value in srand, as follows: Requires #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
