Python - Weapon class assignment

From WLCS

Objective

  • You will learn to create a basic class that encapsulates several attributes and methods

Purpose

  • The purpose of the Weapon class is to encapsulate the necessary attributes and methods that represent a weapon in the game

Attributes

The Weapon class should use variables to represent the following attributes:

  • String name: the name of the weapon (e.g., "sword" or "magic wand").
    • Default: "bare hands"
  • int damageModifier: an integer added to the damage inflicted when the creature scores a hit.
    • Default: 0
  • String hitVerb: a verb to describe the action of the weapon when it scores a hit (e.g., "slashes" or "zaps").
    • Default: "strikes"
  • String missVerb: a verb to describe the action of the weapon when it misses (e.g., "whiffs" or "misses").
    • Default: "misses"

Methods

The Weapon class should have the following methods:

  • __init__(self, name="bare hands", damageModifier=0, hitVerb="strikes", missVerb="misses") - initializes all the internal attributes to the method's parameters
    • self.name = name
    • self.damageModifier = damageModifier
    • self.hitVerb = hitVerb
    • self.missVerb = missVerb
  • We are going to add a text description to the name of a weapon to let the user know how powerful it is. For example, if you have a katana and you find a pair of nunchucks, how do you know which is better? Note that for this game, all weapons do the same amount of damage (yes, this is not the most realistic, but much simpler for you to code). Thus, we will be adding a modifier to help the player determine how powerful of a weapon it is. The modifiers are: cursed, normal, shiny, high quality, elite, and magical. Define the getFullName() method as follows:
    • if the damageModifier is less than 0, then return "cursed" + the weapon's name
    • elif the damageModifier is less than 3, then return "normal" + the weapon's name
    • elif the damageModifier is less than 6, then return "shiny" + the weapon's name
    • elif the damageModifier is less than 9, then return "high quality" + the weapon's name
    • elif the damageModifier is less than 12, then return "elite" + the weapon's name
    • else return "magical" + the weapon's name