Question: Code in Python Please. 1. Import the random module to be used later. The random module allows use of the randrange method which will return
Code in Python Please.
1. Import the random module to be used later. The random module allows use of the randrange method which will return a random number based on a range you specify. Example: print(random.randrange(1,10))
2. Create a class named Hero. This class should have attributes name, level, weaponname, life, damage, and attack.
3. Add a method to the class called AttackPoints that assigns a random number to the attack attribute and returns that value.
4. Add a method to the class called imHit that receives a number as a parameter, then subtracts that number from life and prints out heroName screams - Im hit! where heroName is replaced with the actual name. It also prints out the value in life stating how much is left.
5. Create a new Hero object.
6. Assign values to the attributes name, level, , and weaponname by prompting the user. Damage and Attack should statically be set to zero, and Life should be statically set to 100 initially.
7. Create a child class called Villian that inherits everything from the hero class.
8. Add a new method to the Villian class called FinalForm that receives a name and prints out a message saying This isnt even my final form nameparameter! where nameparameter is replaced with the value passed (should be the hero name).
9. Create a new Villian object
10. Write a loop to allow the user to battle Hero vs Villian until one of their life values reaches reaches zero. If the hero reaches zero first print out an appropriate message and exit. If the villain reaches zero first call the FinalForm method.
- The AttackPoints method no longer has to return a value, unless you want it to.
- Modify the Villain and Hero classes to get assign a random number to the attack value every time AttackPoints is called.
- Create a loop that prompts the user to runs a battle simulation until one of the opponents reach a life value of zero. Make sure to keep track of the rounds and battle number.
- The user should be asked if they would like to battle the Hero/Villain again once one is defeated (life reaches zero).
- Keep track of the number of Hero and Villian wins, until the user would like to exit. Keep track of the total damage done during each round.
- After each battle create a scatterplot that plots the Hero and Villain values during the battle. The X axis should be the round number and the Y axis should be the attack value of the Hero/Villian during that round. Save this to a .png file with the name ResultofBattleX.png, where X is replaced with the battle number. Make sure to make the Hero and Villain points different colors.
- When the user has enough bloodshed and would like to exit, after the exit - create a pie graph with the distribution of Hero wins versus Villian wins.
- For the last battle that was run, make a histogram with Plotly that has the total damage for the Y axis and round number for the X axis. Save this in a html file with a name of your choosing.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
