def __init__(self, name, power):
     """
     @param name: The name of this weapon
     @param power: Amount of hitpoints this weapon will damage
     @summary: Initializes a balloon launcher
     """
     Weapon.__init__(self, name, power)
Example #2
0
    def __init__(self, name, power):
        """
        @param name: The name of this cannon
        @param power: Amount of hitpoints this weapon will damage
        @summary: Initializes a cannon
        """
        Weapon.__init__(self, name, power)

        # Set the aiming direction
        self.weaponAngle = 45
        self.ammo = 6 * 5

        self.image = load_image('crosshair.png')
        self.rect = self.image.get_rect()
Example #3
0
class TestWeaponMethods(unittest.TestCase):
    def setUp(self):
        self.weapon = Weapon()

    def test_get_name(self):
        self.assertEqual(self.weapon.name, 'Stick')

    def test_get_damage(self):
        with self.assertRaises(NotRealizedMethodError):
            self.weapon.damage

    def test_attack(self):
        with self.assertRaises(NotRealizedMethodError):
            self.weapon.attack()
Example #4
0
    def update(self, input, terrain):
        """
        @param input: The user input
        @param terrain: The terrain which should be used for collission detection
        @summary: updates the cannon based on user input
        """
        if self.snail:
            if self.snail.hasTurn:
                self.updateAngle(input)

            x_margin = 0
            y_margin = 0

            x_margin = math.cos(math.radians(self.weaponAngle)) * (self.snail.rect.width * 2)
            y_margin = math.sin(math.radians(self.weaponAngle)) * (self.snail.rect.height * 2)

            self.rect.centerx = self.snail.rect.centerx + x_margin
            self.rect.centery = self.snail.rect.centery + y_margin
        Weapon.update(self, input, terrain)
Example #5
0
 def __init__(self,
              name,
              hp,
              maxHealth,
              strength,
              weapon=Weapon("Short Sword"),
              armor=Armor("Cloth Armor"),
              bonuses=[],
              inventory={},
              statuses=[],
              gold=0):
     self.name = name
     self.health = hp
     self.maxHealth = maxHealth
     self.strength = strength
     self.weapon = weapon
     self.armor = armor
     self.bonuses = bonuses  # all types of bonuses, they handle their own action based on state code
     self.inventory = inventory
     self.statuses = statuses
     self.gold = gold
Example #6
0
 def __init__(self, effects=None, name='Sword', damage=10):
     Weapon.__init__(self, name, damage, [effects])
     self._durability = 1
Example #7
0
 def __init__(self, name='Bow', damage=2, accuracy=10, effects=None):
     Weapon.__init__(self, name, damage, [effects])
     self.__accuracy = accuracy
Example #8
0
 def setUp(self):
     self.weapon = Weapon()