2. You use your code from the first part to release your game, Super Happy Fun Cute Creatures World Traveler, to widespr
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
2. You use your code from the first part to release your game, Super Happy Fun Cute Creatures World Traveler, to widespr
where A is the attacking creature's attack rating and D is the target creature's defense rating: - If the target creature is of the same type as the attacking creature, the special attack deals no damage, regardless of A and D. If the target creature's type resists the attacking creature's type, the special attack deals A - 5D damage, with a minimum possible damage of 0. If the target creature's type is vulnerable to the attacking creature's type, the special attack deals 5A - D damage, with a minimum possible damage of 10. - In all other situations, the special attack deals A-D damage, with a minimum possible damage of 1. This includes situations in which an evolved creature performs a special attack vs. a creature with no type (which could be an EvolvableCuteCreature who hasn't evolved yet, or just a regular CuteCreature). Here are some examples of how the special attack works: Attacker's Type Nature Nature Nature Nature Nature Attacker's Attack Rating 15 15 15 15 15 Target's Target's Type Defense Rating Tech Dark Nature Light None 25 25 25 25 25 Damage Dealt to Target 50 0 0 1 1 Within a file named evolvable_cute_creature.py, write a subclass EvolvableCuteCreature that extends your existing CuteCreature class with the functionality described above. The subclass should contain the following parts: (a) (3 points) EvolvableCuteCreatures need extra instance attributes to indicate at which level the evolution process should take place, the evolved species, and which type the creature is attuned to once it evolves. Write a constructor for EvolvableCuteCreature. This constructor should take the same parameters as the one from CuteCreature, plus extra parameters for the level at which evolution should occur and the evolved species. Since the creature doesn't evolve until reaching a certain level, the constructor should also initialize the type instance attribute to some kind of "hasn't evolved yet" value. Call the parent constructor to save yourself some coding! (b) (3 points) Override the_str__ method from CuteCreature to include which type the crea- ture is attuned to. If the creature hasn't evolved yet, indicate that it has no type. Be sure to use the correct species if the creature has evolved! (c) (3 points) Override the level up method from CuteCreature to handle the evolution pro- cess at the appropriate level. This method should display some text when called, to indicate that the evolution process is happening.
(d) (9 points) Add the new method special attack(self, target), which performs one special attack against a target CuteCreature using the rules explained earlier. If an Evolv- able CuteCreature tries to call this method without having evolved yet, display an appropri- ate error message. Be sure to check for the target creature being defeated; if this happens, the attacking creature should gain some experience just as with a regular attack. (e) (4 points) Below your EvolvableCuteCreature class definition, test your class by doing this: • Create several EvolvableCuteCreature objects. Call gain xp to give them enough experience to evolve, and verify that the evolution process happens successfully. • Thoroughly test the special attack method. You should include at least the follow- ing scenarios: An evolved creature attacking an evolved creature of the same type An evolved creature attacking an evolved creature of a resistant type An evolved creature attacking an evolved creature of a vulnerable type An evolved creature attacking an EvolvableCuteCreature that hasn't evolved yet An evolved creature attacking a regular CuteCreature - An EvolvableCuteCreature that hasn't evolved yet trying to perform a special attack - Congrats! Your code is now the very best, like no code ever was.