Player can now dance! Closes #69.
This commit is contained in:
		@@ -498,7 +498,7 @@ class ScrollofDamage(Item):
 | 
			
		||||
 | 
			
		||||
class ScrollofWeakening(Item):
 | 
			
		||||
    """
 | 
			
		||||
    A scroll that, when used, reduces the damage of the ennemies for 3 turn.
 | 
			
		||||
    A scroll that, when used, reduces the damage of the ennemies for 3 turns.
 | 
			
		||||
    """
 | 
			
		||||
    def __init__(self, name: str = "scroll_of_weakening", price: int = 13,
 | 
			
		||||
                 *args, **kwargs):
 | 
			
		||||
 
 | 
			
		||||
@@ -7,6 +7,7 @@ from math import log
 | 
			
		||||
 | 
			
		||||
from .items import Item
 | 
			
		||||
from ..interfaces import FightingEntity, InventoryHolder
 | 
			
		||||
from ..translations import gettext as _, Translator
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Player(InventoryHolder, FightingEntity):
 | 
			
		||||
@@ -62,6 +63,32 @@ class Player(InventoryHolder, FightingEntity):
 | 
			
		||||
        self.recalculate_paths()
 | 
			
		||||
        self.map.compute_visibility(self.y, self.x, self.vision)
 | 
			
		||||
 | 
			
		||||
    def dance(self) -> None:
 | 
			
		||||
        """
 | 
			
		||||
        Dancing has a certain probability or making ennemies unable
 | 
			
		||||
        to fight for 2 turns. That probability depends on the player's
 | 
			
		||||
        charisma.
 | 
			
		||||
        """
 | 
			
		||||
        diceroll = randint(1, 10)
 | 
			
		||||
        found = False
 | 
			
		||||
        if diceroll <= self.charisma:
 | 
			
		||||
            for entity in self.map.entities:
 | 
			
		||||
                if entity.is_fighting_entity() and not entity == self \
 | 
			
		||||
                    and entity.distance(self)<=3:
 | 
			
		||||
                        found = True
 | 
			
		||||
                        entity.confused = 1
 | 
			
		||||
                        entity.effects.append(["confused", 1, 3])
 | 
			
		||||
            if found:
 | 
			
		||||
                self.map.logs.add_message(_(
 | 
			
		||||
                    "It worked! Nearby ennemies will be confused for 3 turns."))
 | 
			
		||||
            else:
 | 
			
		||||
                self.map.logs.add_message(_(
 | 
			
		||||
                    "It worked, but there is no one nearby..."))
 | 
			
		||||
        else:
 | 
			
		||||
            self.map.logs.add_message(
 | 
			
		||||
                _("The dance was not effective..."))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    def level_up(self) -> None:
 | 
			
		||||
        """
 | 
			
		||||
        Add as many levels as possible to the player.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user