Added a second scroll object closes #60
This commit is contained in:
parent
5736c2300b
commit
bde33e9232
|
@ -35,6 +35,7 @@ class TexturePack:
|
|||
RING_OF_CRITICAL_DAMAGE: str
|
||||
RING_OF_MORE_EXPERIENCE: str
|
||||
SCROLL_OF_DAMAGE: str
|
||||
SCROLL_OF_WEAKENING: str
|
||||
SHIELD: str
|
||||
SUNFLOWER: str
|
||||
SWORD: str
|
||||
|
@ -97,6 +98,7 @@ TexturePack.ASCII_PACK = TexturePack(
|
|||
TRUMPET='/',
|
||||
WALL='#',
|
||||
SCROLL_OF_DAMAGE=']',
|
||||
SCROLL_OF_WEAKENING=']',
|
||||
)
|
||||
|
||||
TexturePack.SQUIRREL_PACK = TexturePack(
|
||||
|
@ -134,4 +136,5 @@ TexturePack.SQUIRREL_PACK = TexturePack(
|
|||
TRUMPET='🎺',
|
||||
WALL='🧱',
|
||||
SCROLL_OF_DAMAGE='📜',
|
||||
SCROLL_OF_WEAKENING='📜',
|
||||
)
|
||||
|
|
|
@ -80,7 +80,8 @@ class Item(Entity):
|
|||
Returns the list of all item classes.
|
||||
"""
|
||||
return [BodySnatchPotion, Bomb, Heart, Shield, Sword,\
|
||||
Chestplate, Helmet, RingCritical, RingXP]
|
||||
Chestplate, Helmet, RingCritical, RingXP, \
|
||||
ScrollofDamage, ScrollofWeakening]
|
||||
|
||||
def be_sold(self, buyer: InventoryHolder, seller: InventoryHolder) -> bool:
|
||||
"""
|
||||
|
@ -443,3 +444,25 @@ class ScrollofDamage(Item):
|
|||
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.
|
||||
"""
|
||||
|
||||
def __init__(self, name: str = "scroll_of_weakening", price: int = 13,
|
||||
*args, **kwargs):
|
||||
super().__init__(name=name, price=price, *args, **kwargs)
|
||||
|
||||
def use(self) -> None:
|
||||
"""
|
||||
Find all entities and reduce their damage.
|
||||
"""
|
||||
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"))
|
||||
self.held_by.inventory.remove(self)
|
||||
|
|
|
@ -31,6 +31,7 @@ class Monster(FightingEntity):
|
|||
By default, a monster will move randomly where it is possible
|
||||
If the player is closeby, the monster runs to the player.
|
||||
"""
|
||||
super().act(m)
|
||||
target = None
|
||||
for entity in m.entities:
|
||||
if self.distance_squared(entity) <= 25 and \
|
||||
|
|
|
@ -630,7 +630,7 @@ class Entity:
|
|||
Trumpet
|
||||
from squirrelbattle.entities.items import BodySnatchPotion, Bomb, \
|
||||
Heart, Sword, Shield, Chestplate, Helmet, RingCritical, RingXP, \
|
||||
ScrollofDamage
|
||||
ScrollofDamage, ScrollofWeakening
|
||||
return {
|
||||
"Tiger": Tiger,
|
||||
"Bomb": Bomb,
|
||||
|
@ -651,6 +651,7 @@ class Entity:
|
|||
"RingCritical": RingCritical,
|
||||
"RingXP": RingXP,
|
||||
"ScrollofDamage": ScrollofDamage,
|
||||
"ScrollofWeakening": ScrollofWeakening,
|
||||
}
|
||||
|
||||
def save_state(self) -> dict:
|
||||
|
@ -693,6 +694,7 @@ class FightingEntity(Entity):
|
|||
self.constitution = constitution
|
||||
self.level = level
|
||||
self.critical = critical
|
||||
self.effects = [] #effects are temporary buff or weakening of the stats.
|
||||
|
||||
@property
|
||||
def dead(self) -> bool:
|
||||
|
@ -701,13 +703,26 @@ class FightingEntity(Entity):
|
|||
"""
|
||||
return self.health <= 0
|
||||
|
||||
def act(self, m: Map) -> None:
|
||||
"""
|
||||
Refreshes all current effects.
|
||||
"""
|
||||
for i in range(len(self.effects)):
|
||||
self.effects[i][2] -= 1
|
||||
|
||||
l = self.effects[:]
|
||||
for i in range(len(l)):
|
||||
if l[i][2] <= 0:
|
||||
setattr(self, l[i][0], getattr(self, l[i][0])-l[i][1])
|
||||
self.effects.remove(l[i])
|
||||
|
||||
def hit(self, opponent: "FightingEntity") -> str:
|
||||
"""
|
||||
The entity deals damage to the opponent
|
||||
based on their respective stats.
|
||||
"""
|
||||
diceroll = randint(1, 100)
|
||||
damage = self.strength
|
||||
damage = max(0, self.strength)
|
||||
string = " "
|
||||
if diceroll <= self.critical: # It is a critical hit
|
||||
damage *= 4
|
||||
|
|
Loading…
Reference in New Issue