In this assignment, you’ll use classes to create a simplified Pokémon Game. Using your interface, the players should be able to:
You will practice working with classes and object-oriented programming techniques by building a simiplified Pokémon-like game. You’ll have lots of freedom to determine the game mechanics. Because most of us are new to Object-Oriented Programming, this assignment is structured a little more like a lab to help you get started.
Challenge 1: Creating a class definitionRecall from lecture that classes function as blueprints for building objects in Python. They bundle together data (inside attributes) and actions (inside methods) in ways that are both logical and easy to maintain/extend. In this first challenge, we’ll create a generic Pokemon class.
Create a Pokemon class. The class definition should include:
name parameterattributes (don’t forget that all attributes/methods should be members of the Pokemon class – use the word self!):
name = the value contained in the name parameter passed to the constructorpokemon_type = "NORMAL"max_hp = a random integer (you decide the range)current_hp = max_hpattack_power = a random integer (greater than 0 but less than hp)defensive_power = a random integer (greater than 0 but less than hp)fainted = FalseprintStats() that prints the Pokémon’s stats to the screendefend() that decreases the value of current_hp by some amount (you determine by how much, but it should probably be related to defense in some way) and setting fainted = True if current_hp falls below 0attack(opponent) that takes in an opponent (another Pokemon instance) and decreases its current_hp by calling opponent.defend()revive() that if fainted = True sets current_hp = max_hp/2 and fainted = False and returns True, otherwise returns FalseTest out your class by creating an instance of the Pokemon class in your main() function, calling .printStats() once to see the starting stats, calling .defend() until the Pokemon faints, and then calling .revive() and .printStats() again.
Challenge 2: Creating a simple battle() functionWoohoo, you’ve got your Pokémon class working! Unfortunately, the game isn’t very much fun by yourself.
Create a battle() function that takes two Pokemon instances (one belonging to each player), and alternates between them.
On each player’s turn, their Pokemon will attack the other player’s Pokemon, and the defending Pokemon will then print its stats. You may want to print additional information to the screen to make gameplay more interesting.
Test your battle() function by creating a second Pokemon instance within your main() function, and calling battle() on the two instances.
Challenge 3: Extending the class definitionAdd three or more subclasses that extend the Pokemon class, modifying the pokemon_type if necessary and overriding the attack() method (which may do different kinds of damage depending on the opponent). For example:
class Pikachu(Pokemon):
self.type = "ELECTRIC"
def self.attack(opponent):
if (opponent.type == "GROUND"):
# super-effective
# do twice as much damage
elif (opponent.type == "ELECTRIC" or opponent.type = "FLYING"):
# not effective
# do half as much damage
Test out your subclasses by creating instances of them in your main() function, and then calling battle() repeatedly to see how they fare against one another.
Final Challenge: Coder’s Choice!Add some additional functionality to make the game more interesting: you might implement a more complex formula for .attack()/.defend(), add multiple kinds of .attack() and allow the player to choose between them, use ASCII art to make the game more visually appealing… how far you go is entirely up to you!
Recommendation: if you find yourself adding the same functionality to every subclass (e.g. if you want your Pokémon to have a nickname, etc.), consider changing the parent class instead!

The submission:
The program:
Recommended Submission: April 12, 2019 at 9:00PM (EST).
Last Submission: April 14, 2019 at 9:00PM (EST).
Go to our Moodle Page and submit your hmwk9.py file.