Add an integer data member to the Player class that describes the number of magic points the player currently has. Additionally, add a “max magic points” data member that describes the maximum number of magic points the player can have at his/her current level. Be sure to also modify the Player: : viewStats () method to display the current amount of magic points the player has. Also, be sure to increase the amount of magic points when the character levels up-and a “wizard” should gain more hit points than a “fighter.”
After you have added magic points to the system, create a Spell structure and then instantiate a few types of spell objects, such as “magic missile,” “fireball,” and “shield.” You may want to implement the Spell structure like so:
Â·mName: The name of the spell (e.g., â€œFireballâ€).
Â·mDamageRange: The range of damage the spell inflicts.
Â·mMagicPointsRequired: The number of magic points required to cast the spell.
Finally, add a “cast spell” option to the combat menu, which allows the player to select and cast a spell from a list of spells in his/her spell book. Be sure to verify that the player has enough magic points to cast the spell. And also be sure to deduct the magic points required to cast the spell from the player’s magic point count, after a spell is cast.