For this project, you will be given several code files, but you will only run or add code to one of them. Besides that, you will create several code files of your own. When you actually run the program, it will run a simulation of a game involving fighting monsters with various weapons. You are given these files:
- monster_wars.py:
- This is the file that you actually run, as it provides the command line interface to the program.
- This file will:
- Reads and executes the code from the other files, to incorporate those new types (i.e., classes) into the program.
- Declares several constants and local methods
- Creates different threads of execution for the game simulation
- Randomly generates monsters and weapons according to pre-established probabilities.
- Runs until time runs out OR the player is defeated.
- There will be several places in this code file, indicated in the comments with the words "PROJECT WORK", where you will need to add code in order to incorporate your new classes into the main program.
- zombie.py and werewolf.py:
- These files define two of our monster classes: Zombie and Werewolf.
- Each class will have certain features:
- Life points
- ID numbers
- An is_down property that tells us whether the monster is still active
- A damage function that determines whether or not a monster takes damage (avoids it) during an attack. Each monster type has a specific chance to take or avoid damage.
- You will create one or two similar monster classes and incorporate into monster_wars.py
- Study these carefully in order to determine how to proceed with your own design.
- stick.py, bag_of_rocks.py, and laser.py:
- These files define three of our weapon classes: Stick, BagOfRocks,and Laser.
- Each class will have certain features:
- Some attribute (such as "durability" for sticks, which influences how much damage the weapon can do)
- Various class-level constants used to randomly generate values
- An attack function that is responsible for attacking the current monster until it "runs out", however that is defined for that particular weapon type
- __min_damage and __max_damage functions that are used to generate random amounts of damage to apply to the current monster
- You will create one or two similar weapon classes and incorporate into monster_wars.py
- Study these carefully in order to determine how to proceed with your own design.
To reiterate, your work on this project will involve the following:
- Create three new classes to go with this program. Either two new monster types and one new weapon type OR one new monster type and two new weapon types. (For a possible 5% extra credit, you may create a fourth class, so that you have both two new monster types AND two new weapon types.)
- Each new class should have its own code file, named after the class whose code it contains.
- You will need to make some changes to monster_wars.py in the areas indicated.
Some additional points of consideration:
- You will probably find it helpful to run the main program a few times -- and study the code for a while-- in order to get a better idea of how it works.
- Try starting with one new class first and incorporating that one, and then see how it works before creating the other new ones.
- If you cannot finish all three or four new classes on time, it is better that you have fewer that work well -- rather than more that work poorly.
- Whether you are creating a new monster type or a new weapon type, use one of the pre-existing classes to get an idea of how to proceed.
- Do not delay starting on this, and do not hesitate to ask for help.
- NOTE: In the checklist at the end, you will see four file names that look like this: ________.py
You may be adding three or four new files. Those blanks would be replaced with whatever names you chose for those Python code files.