Added a fire ball staff, closes #64

This commit is contained in:
eichhornchen 2021-01-08 19:05:02 +01:00
parent 903a06c36c
commit 591630b8a7
4 changed files with 41 additions and 6 deletions

View File

@ -25,6 +25,7 @@ class TexturePack:
CHESTPLATE: str CHESTPLATE: str
EAGLE: str EAGLE: str
EMPTY: str EMPTY: str
FIRE_BALL_STAFF: str
FLOOR: str FLOOR: str
HAZELNUT: str HAZELNUT: str
HEART: str HEART: str
@ -82,6 +83,7 @@ TexturePack.ASCII_PACK = TexturePack(
EAGLE='µ', EAGLE='µ',
EMPTY=' ', EMPTY=' ',
EXPLOSION='%', EXPLOSION='%',
FIRE_BALL_STAFF=':',
FLOOR='.', FLOOR='.',
LADDER='H', LADDER='H',
HAZELNUT='¤', HAZELNUT='¤',
@ -121,6 +123,7 @@ TexturePack.SQUIRREL_PACK = TexturePack(
EAGLE='🦅', EAGLE='🦅',
EMPTY=' ', EMPTY=' ',
EXPLOSION='💥', EXPLOSION='💥',
FIRE_BALL_STAFF='🪄',
FLOOR='██', FLOOR='██',
LADDER=('🪜', curses.COLOR_WHITE, (1000, 1000, 1000), LADDER=('🪜', curses.COLOR_WHITE, (1000, 1000, 1000),
curses.COLOR_WHITE, (1000, 1000, 1000)), curses.COLOR_WHITE, (1000, 1000, 1000)),

View File

@ -86,7 +86,7 @@ class Item(Entity):
""" """
return [BodySnatchPotion, Bomb, Heart, Shield, Sword,\ return [BodySnatchPotion, Bomb, Heart, Shield, Sword,\
Chestplate, Helmet, RingCritical, RingXP, \ Chestplate, Helmet, RingCritical, RingXP, \
ScrollofDamage, ScrollofWeakening, Ruler, Bow] ScrollofDamage, ScrollofWeakening, Ruler, Bow, FireBallStaff]
def be_sold(self, buyer: InventoryHolder, seller: InventoryHolder) -> bool: def be_sold(self, buyer: InventoryHolder, seller: InventoryHolder) -> bool:
""" """
@ -505,9 +505,10 @@ class LongRangeWeapon(Item):
self.held_by.x-entity.x<=self.range: self.held_by.x-entity.x<=self.range:
to_kill = entity to_kill = entity
if to_kill: if to_kill:
self.held_by.map.logs.add_message(_("{name} is shot by an arrow.")\ self.held_by.map.logs.add_message(_("{name}")\
.format(name=to_kill.translated_name.capitalize())+ " " \ .format(name=to_kill.translated_name.capitalize())+ self.string + " " \
+ to_kill.take_damage(self.held_by, self.damage + getattr(self.held_by, self.stat))) + to_kill.take_damage(self.held_by, self.damage + \
getattr(self.held_by, self.stat)))
def equip(self) -> None: def equip(self) -> None:
""" """
@ -523,6 +524,12 @@ class LongRangeWeapon(Item):
or intelligence for a magic staff. or intelligence for a magic staff.
""" """
@property
def string(self) -> str:
"""
The string that is printed when we hit an ennemy.
"""
class Bow(LongRangeWeapon): 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
@ -538,3 +545,27 @@ class Bow(LongRangeWeapon):
Here it is dexterity Here it is dexterity
""" """
return "dexterity" return "dexterity"
@property
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
"""
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, \
rang=rang, *args, **kwargs)
@property
def stat(self) -> str:
"""
Here it is dexterity
"""
return "intelligence"
@property
def string(self) -> str:
return " is shot by a fire ball."

View File

@ -4,7 +4,7 @@
from random import randint from random import randint
from typing import Dict, Optional, Tuple from typing import Dict, Optional, Tuple
from .items import Item, Bow from .items import Item
from ..interfaces import FightingEntity, InventoryHolder from ..interfaces import FightingEntity, InventoryHolder

View File

@ -630,7 +630,7 @@ class Entity:
Trumpet Trumpet
from squirrelbattle.entities.items import BodySnatchPotion, Bomb, \ from squirrelbattle.entities.items import BodySnatchPotion, Bomb, \
Heart, Sword, Shield, Chestplate, Helmet, RingCritical, RingXP, \ Heart, Sword, Shield, Chestplate, Helmet, RingCritical, RingXP, \
ScrollofDamage, ScrollofWeakening, Ruler, Bow ScrollofDamage, ScrollofWeakening, Ruler, Bow, FireBallStaff
return { return {
"Tiger": Tiger, "Tiger": Tiger,
"Bomb": Bomb, "Bomb": Bomb,
@ -654,6 +654,7 @@ class Entity:
"ScrollofDamage": ScrollofDamage, "ScrollofDamage": ScrollofDamage,
"ScrollofWeakening": ScrollofWeakening, "ScrollofWeakening": ScrollofWeakening,
"Bow": Bow, "Bow": Bow,
"FireBallStaff": FireBallStaff,
} }
def save_state(self) -> dict: def save_state(self) -> dict: