CAN I PLEASE GET SOME HELP WITH THIS CODE IN PYTHON!!! I ATTACHED A COPY OF MY ASSIGNMENT WITH SOME CODE THAT I HAVE ALR

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

CAN I PLEASE GET SOME HELP WITH THIS CODE IN PYTHON!!! I ATTACHED A COPY OF MY ASSIGNMENT WITH SOME CODE THAT I HAVE ALR

Post by answerhappygod »

CAN I PLEASE GET SOME HELP WITH THIS CODE IN PYTHON!!! IATTACHED A COPY OF MY ASSIGNMENT WITH SOME CODE THAT I HAVE ALREADYDONE.
Can I Please Get Some Help With This Code In Python I Attached A Copy Of My Assignment With Some Code That I Have Alr 1
Can I Please Get Some Help With This Code In Python I Attached A Copy Of My Assignment With Some Code That I Have Alr 1 (567.16 KiB) Viewed 34 times
1. Suppose you're designing a video game where the objective is to travel around the world collect- ing cute cartoonish creatures that become stronger over time by fighting other cute cartoonish creatures. (This is totally the best idea ever! Why hasn't anyone thought of this before?!) WAVECHANTU Within a file named cute_creature.py, write a class CuteCreature that includes the following instance methods. 1
(a) (3 points) Each CuteCreature object has the following instance attributes: • Species a string indicating the type of creature (such as 'Bowlbasore,' 'Squaretell,' or 'Peekashoe') • Level - a positive integer indicating how powerful the creature is • Current hit points - a non-negative integer indicating how much damage the creature can take before being incapacitated • Maximum hit points - a positive integer indicating the highest possible value of current hit points • Attack rating a non-negative integer indicating how effective this creature is at attacking another creature • Defense rating - a non-negative integer indicating how effective this creature is at resisting an attack from another creature • Experience points - a non-negative integer indicating the creature's cumulative expe- rience. Creatures use experience points to determine when to "level up" and become more powerful. • Experience value - a non-negative integer indicating how many experience points this creature is worth when defeated by another creature • is special a Boolean variable that determines whether this creature is considered "special." Internally, special creatures are exactly the same as non-special creatures. However, they have a slightly different appearance and are somehow very highly prized by the players of your game. Write a constructor that takes parameters for species, maximum hit points, attack rating, defense rating, experience value, and "special" status. A newly created CuteCreature should have a level of 1, current hit points equal to the maximum hit points, and zero experience points. (b) (3 points)_str__(self) Returns a string summarizing all the instance attributes of the CuteCreature. For example, the code c = CuteCreature ('Eckanz', 40, 5, 3, 70, True) print (c) might result in output that looks something like this: Level 1 Eckanz *** Special! *** HP: ATK: DEF: XP: XP Val: 70 ¹Feel free to include extra instance attribute(s) if needed or desired! 40/40 5 3 0/200
(c) (3 points) level_up (self) Makes the CuteCreature "level up." The method should display some text when called, to indicate that the creature is leveling up. Leveling up increases the creature's level by 1, in addition to the following changes: • If the new level is between 2-9 (inclusive): Maximum hit points increase by 7, attack and defense ratings increase by 3 • If the new level is 10 or over: Maximum hit points increase by 2, attack and defense ratings increase by 1 • For all level ups: Experience value increases by 25 • For all level ups: The creature is fully healed (i.e., the current hit points is set to the maximum hit points) Note that level up is meant to be called only from this class's gain xp method below. (d) (3 points) gain xp (self, amount) Makes the CuteCreature gain the specified amount of experience points, leveling up if necessary. The method should display some text when called, to indicate that the creature is gaining a certain amount of experience. Call the previously written level up method to handle the process of leveling up. The gain xp method should work for any positive value of amount, which means that multiple level ups can occur from a single call if the argument is large enough. CuteCreatures require 200 experience points to advance from level 1 to level 2, and the experience required per level increases by 75 for each level thereafter. To illustrate how this works, here's a table of the experience needed for the first five levels: Current Level 1 2 3 4 5 Experience Needed for Next Level 200 275 350 425 500 Cumulative Experience at Next Level 200 475 825 1250 1750 (e) (3 points) take_damage (self, amount) Makes the CuteCreature take the specified amount of damage to its current hit points. Negative hit points are not allowed, so this method should also ensure that the current hit points cannot go below zero. The method should display some text when called, to indicate the amount of damage taken. If the damage is enough to bring the current hit points to zero, display some text to indicate that the CuteCreature has been incapacitated.
(f) (9 points) attack(self, target) Makes the CuteCreature perform one attack against a target CuteCreature. The method should display some text when called, to indicate which creature is attacking which and the results of that attack. If the target creature is defeated (i.e, has current hit points brought down to zero) by the attack, the method should also make the attacking creature gain the appropriate amount of experience. Call the previously written take damage and gain xp methods as needed. The rules governing attack mechanics are as follows: • The attacking creature has a 70% chance to score a regular hit with the attack, a 10% chance to score a "critical hit," and a 20% chance of missing altogether. On a regular hit, the damage to the target creature is the difference between the attacking creature's attack rating and the target creature's defense rating. A minimum of 1 damage is always dealt on a hit, even if this difference is zero or negative. . On a critical hit ("crit"), the regular damage is doubled. Minimum damage from a crit is 2. ● On a miss, no damage is dealt. Here are some examples of how this works: Attack Rating of Attacking Creature 14 14 14 14 14 14 14 14 14 Defense Rating of Target Creature Attack Result 11 11 11 -2 -2 -2 19 19 19 Hit Crit Miss Hit Crit Miss Hit Crit Miss Damage Dealt to Target Creature 3 6 0 16 32 0 1 2 0 (g) (4 points) Below your CuteCreature class definition, test your class by creating two Cute- Creature objects, then having them attack each other until only one of them is left stand- ing.2 The next pages have some sample output from such a test.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ៣១ខជន៩៥ដ 17 18 19 20 21 22 23 24 25 26 27 28 29 30 12343536劲8 39 ♀ = 234 37 40 41 44 class CuteCreature: def __init__(self, species, max_hp, atk, Def, xp_val, is_special): self.species = species self.level 1 self.hp = max_hp self.max_hp = max_hp self.atk atk self.Def= Def self.xp = 0 self.xp_val= xp_val self.is_special is_special def _str_(self): return f'CuteCreature object: level = {self.level}, species = {self.species}, max_hp = {self.hp}/{self.max_hp}, atk = {self.atk}, Def = {s def _level_up_(self): self.level = self.level+1 if self.level = >1 and self.level <10 self.max_hp = self.max_hp + 7 self.atk = self.atk + 3 self.Def= self.Def + 3 else self.max_hp = self.max_hp + 2 self.atk = self.atk + 1 self.Def= self.Def + 1 self.xp_val= self.xp_val + 25 self.hp = max_hp def _gain_xp_(self, amount) xp = {self.xp }/{(200 + 75 * ((self.level) -1))} xp_val= {self.xp_val} c = CuteCreature('Eckanz', 40, 5, 3, 70, True) print(c)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply