Linting and tests...
This commit is contained in:
		@@ -84,8 +84,8 @@ class Item(Entity):
 | 
			
		||||
        """
 | 
			
		||||
        Returns the list of all item classes.
 | 
			
		||||
        """
 | 
			
		||||
        return [BodySnatchPotion, Bomb, Heart, Shield, Sword,\
 | 
			
		||||
                Chestplate, Helmet, RingCritical, RingXP, \
 | 
			
		||||
        return [BodySnatchPotion, Bomb, Heart, Shield, Sword,
 | 
			
		||||
                Chestplate, Helmet, RingCritical, RingXP,
 | 
			
		||||
                ScrollofDamage, ScrollofWeakening, Ruler, Bow, FireBallStaff]
 | 
			
		||||
 | 
			
		||||
    def be_sold(self, buyer: InventoryHolder, seller: InventoryHolder) -> bool:
 | 
			
		||||
@@ -256,13 +256,15 @@ class Sword(Weapon):
 | 
			
		||||
                 *args, **kwargs):
 | 
			
		||||
        super().__init__(name=name, price=price, *args, **kwargs)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Ruler(Weapon):
 | 
			
		||||
    """
 | 
			
		||||
    A basic weapon
 | 
			
		||||
    """
 | 
			
		||||
    def __init__(self, name: str = "ruler", price: int = 2,
 | 
			
		||||
                 damage: int = 1, *args, **kwargs):
 | 
			
		||||
        super().__init__(name=name, price=price, damage=damage, *args, **kwargs) 
 | 
			
		||||
        super().__init__(name=name, price=price, damage=damage, *args, **kwargs)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Armor(Item):
 | 
			
		||||
    """
 | 
			
		||||
@@ -297,6 +299,7 @@ class Shield(Armor):
 | 
			
		||||
        super().__init__(name=name, constitution=constitution, price=price,
 | 
			
		||||
                         *args, **kwargs)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Helmet(Armor):
 | 
			
		||||
    """
 | 
			
		||||
    Class of helmet items, they can be equipped on the head.
 | 
			
		||||
@@ -312,6 +315,7 @@ class Helmet(Armor):
 | 
			
		||||
        self.held_by.remove_from_inventory(self)
 | 
			
		||||
        self.held_by.equipped_helmet = self
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Chestplate(Armor):
 | 
			
		||||
    """
 | 
			
		||||
    Class of chestplate items, they can be equipped on the body.
 | 
			
		||||
@@ -327,6 +331,7 @@ class Chestplate(Armor):
 | 
			
		||||
        self.held_by.remove_from_inventory(self)
 | 
			
		||||
        self.held_by.equipped_armor = self
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class BodySnatchPotion(Item):
 | 
			
		||||
    """
 | 
			
		||||
    The body-snatch potion allows to exchange all characteristics with a random
 | 
			
		||||
@@ -436,6 +441,7 @@ class RingXP(Ring):
 | 
			
		||||
        super().__init__(name=name, price=price, experience=experience,
 | 
			
		||||
                         *args, **kwargs)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ScrollofDamage(Item):
 | 
			
		||||
    """
 | 
			
		||||
    A scroll that, when used, deals damage to all entities in a certain radius.
 | 
			
		||||
@@ -451,11 +457,12 @@ class ScrollofDamage(Item):
 | 
			
		||||
        """
 | 
			
		||||
        for entity in self.held_by.map.entities:
 | 
			
		||||
            if entity.is_fighting_entity() and not entity == self.held_by:
 | 
			
		||||
                if entity.distance(self.held_by)<=5:
 | 
			
		||||
                    self.held_by.map.logs.add_message(entity.take_damage(\
 | 
			
		||||
                if entity.distance(self.held_by) <= 5:
 | 
			
		||||
                    self.held_by.map.logs.add_message(entity.take_damage(
 | 
			
		||||
                        self.held_by, self.held_by.intelligence))
 | 
			
		||||
        self.held_by.inventory.remove(self)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ScrollofWeakening(Item):
 | 
			
		||||
    """
 | 
			
		||||
    A scroll that, when used, reduces the damage of the ennemies for 3 turn.
 | 
			
		||||
@@ -470,13 +477,17 @@ class ScrollofWeakening(Item):
 | 
			
		||||
        """
 | 
			
		||||
        for entity in self.held_by.map.entities:
 | 
			
		||||
            if entity.is_fighting_entity() and not entity == self.held_by:
 | 
			
		||||
                entity.strength = entity.strength - max(1, self.held_by.intelligence//2)
 | 
			
		||||
                entity.effects.append(["strength", \
 | 
			
		||||
                                       -max(1, self.held_by.intelligence//2), 3])
 | 
			
		||||
        self.held_by.map.logs.add_message(\
 | 
			
		||||
                _(f"The ennemies have -{max(1, self.held_by.intelligence//2)} strength for 3 turns"))    
 | 
			
		||||
                entity.strength = entity.strength - \
 | 
			
		||||
                    max(1, self.held_by.intelligence // 2)
 | 
			
		||||
                entity.effects.append(["strength",
 | 
			
		||||
                                       -max(1, self.held_by.intelligence // 2),
 | 
			
		||||
                                       3])
 | 
			
		||||
        self.held_by.map.logs.add_message(
 | 
			
		||||
            _(f"The ennemies have -{max(1, self.held_by.intelligence // 2)}"
 | 
			
		||||
              + "strength for 3 turns"))
 | 
			
		||||
        self.held_by.inventory.remove(self)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class LongRangeWeapon(Item):
 | 
			
		||||
    def __init__(self, damage: int = 4,
 | 
			
		||||
                 rang: int = 3, *args, **kwargs):
 | 
			
		||||
@@ -489,26 +500,28 @@ class LongRangeWeapon(Item):
 | 
			
		||||
        for entity in self.held_by.map.entities:
 | 
			
		||||
            if entity.is_fighting_entity():
 | 
			
		||||
                if direction == 0 and self.held_by.x == entity.x \
 | 
			
		||||
                   and self.held_by.y-entity.y>0 and \
 | 
			
		||||
                   self.held_by.y-entity.y<=self.range:
 | 
			
		||||
                    and self.held_by.y - entity.y > 0 and \
 | 
			
		||||
                        self.held_by.y - entity.y <= self.range:
 | 
			
		||||
                    to_kill = entity
 | 
			
		||||
                elif direction == 2 and self.held_by.x == entity.x \
 | 
			
		||||
                   and entity.y-self.held_by.y>0 and \
 | 
			
		||||
                   entity.y-self.held_by.y<=self.range:
 | 
			
		||||
                    and entity.y - self.held_by.y > 0 and \
 | 
			
		||||
                        entity.y - self.held_by.y <= self.range:
 | 
			
		||||
                    to_kill = entity
 | 
			
		||||
                elif direction == 1 and self.held_by.y == entity.y \
 | 
			
		||||
                   and entity.x-self.held_by.x>0 and \
 | 
			
		||||
                   entity.x-self.held_by.x<=self.range:
 | 
			
		||||
                    and entity.x - self.held_by.x > 0 and \
 | 
			
		||||
                        entity.x - self.held_by.x <= self.range:
 | 
			
		||||
                    to_kill = entity
 | 
			
		||||
                elif direction == 3 and self.held_by.y == entity.y \
 | 
			
		||||
                   and self.held_by.x-entity.x>0 and \
 | 
			
		||||
                   self.held_by.x-entity.x<=self.range:
 | 
			
		||||
                    and self.held_by.x - entity.x > 0 and \
 | 
			
		||||
                        self.held_by.x - entity.x <= self.range:
 | 
			
		||||
                    to_kill = entity
 | 
			
		||||
        if to_kill:
 | 
			
		||||
            self.held_by.map.logs.add_message(_("{name}")\
 | 
			
		||||
                                              .format(name=to_kill.translated_name.capitalize())+ self.string + " " \
 | 
			
		||||
                                              + to_kill.take_damage(self.held_by, self.damage + \
 | 
			
		||||
                                                                    getattr(self.held_by, self.stat)))
 | 
			
		||||
            line = _("{name}").format(name=to_kill.translated_name.capitalize()
 | 
			
		||||
                                      ) + self.string + " "\
 | 
			
		||||
                                        + to_kill.take_damage(
 | 
			
		||||
                                            self.held_by, self.damage
 | 
			
		||||
                                            + getattr(self.held_by, self.stat))
 | 
			
		||||
            self.held_by.map.logs.add_message(line)
 | 
			
		||||
        return (to_kill.x, to_kill.y) if to_kill else None
 | 
			
		||||
 | 
			
		||||
    def equip(self) -> None:
 | 
			
		||||
@@ -531,13 +544,15 @@ class LongRangeWeapon(Item):
 | 
			
		||||
        The string that is printed when we hit an ennemy.
 | 
			
		||||
        """
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Bow(LongRangeWeapon):
 | 
			
		||||
    """
 | 
			
		||||
    A type of long range weapon that deals damage based on the player's dexterity
 | 
			
		||||
    A type of long range weapon that deals damage
 | 
			
		||||
    based on the player's dexterity
 | 
			
		||||
    """
 | 
			
		||||
    def __init__(self, name: str = "bow", price: int = 22, damage: int = 4,
 | 
			
		||||
                 rang: int = 3, *args, **kwargs):
 | 
			
		||||
        super().__init__(name=name, price=price, damage=damage, \
 | 
			
		||||
        super().__init__(name=name, price=price, damage=damage,
 | 
			
		||||
                         rang=rang, *args, **kwargs)
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
@@ -551,13 +566,15 @@ class Bow(LongRangeWeapon):
 | 
			
		||||
    def string(self) -> str:
 | 
			
		||||
        return " is shot by an arrow."
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class FireBallStaff(LongRangeWeapon):
 | 
			
		||||
    """
 | 
			
		||||
    A type of long range weapon that deals damage based on the player's dexterity
 | 
			
		||||
    A type of powerful long range weapon that deals damage
 | 
			
		||||
    based on the player's intelligence
 | 
			
		||||
    """
 | 
			
		||||
    def __init__(self, name: str = "fire_ball_staff", price: int = 36,\
 | 
			
		||||
    def __init__(self, name: str = "fire_ball_staff", price: int = 36,
 | 
			
		||||
                 damage: int = 6, rang: int = 4, *args, **kwargs):
 | 
			
		||||
        super().__init__(name=name, price=price, damage=damage, \
 | 
			
		||||
        super().__init__(name=name, price=price, damage=damage,
 | 
			
		||||
                         rang=rang, *args, **kwargs)
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
@@ -575,10 +592,10 @@ class FireBallStaff(LongRangeWeapon):
 | 
			
		||||
        """
 | 
			
		||||
        Adds an explosion animation when killing something.
 | 
			
		||||
        """
 | 
			
		||||
        A = super().throw(direction)
 | 
			
		||||
        if A:
 | 
			
		||||
            x=A[0]
 | 
			
		||||
            y=A[1]
 | 
			
		||||
        coord = super().throw(direction)
 | 
			
		||||
        if coord:
 | 
			
		||||
            x = coord[0]
 | 
			
		||||
            y = coord[1]
 | 
			
		||||
 | 
			
		||||
            explosion = Explosion(y=y, x=x)
 | 
			
		||||
            self.held_by.map.add_entity(explosion)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user