Fight other entities while bumping them, without any weapon
This commit is contained in:
		@@ -34,16 +34,18 @@ class Player(FightingEntity):
 | 
			
		||||
        self.current_xp += xp
 | 
			
		||||
        self.level_up()
 | 
			
		||||
 | 
			
		||||
    def fight(self) -> bool:
 | 
			
		||||
    def check_move(self, y: int, x: int, move_if_possible: bool = False) \
 | 
			
		||||
            -> bool:
 | 
			
		||||
        """
 | 
			
		||||
        Fight all f
 | 
			
		||||
        If the player tries to move but a fighting entity is there,
 | 
			
		||||
        the player fights this entity.
 | 
			
		||||
        It rewards some XP if it is dead.
 | 
			
		||||
        """
 | 
			
		||||
        one_fight = False
 | 
			
		||||
        for entity in self.map.entities:
 | 
			
		||||
            if entity != self and isinstance(entity, FightingEntity) and\
 | 
			
		||||
                    self.distance_squared(entity) <= 1:
 | 
			
		||||
            if entity.y == y and entity.x == x and \
 | 
			
		||||
                    isinstance(entity, FightingEntity):
 | 
			
		||||
                self.hit(entity)
 | 
			
		||||
                one_fight = True
 | 
			
		||||
                if entity.dead:
 | 
			
		||||
                    self.add_xp(randint(3, 7))
 | 
			
		||||
        return one_fight
 | 
			
		||||
                return True
 | 
			
		||||
        return super().check_move(y, x, move_if_possible)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user