From 591630b8a7c9290db35f29ec6302fee276f5d8b6 Mon Sep 17 00:00:00 2001 From: eichhornchen Date: Fri, 8 Jan 2021 19:05:02 +0100 Subject: [PATCH] Added a fire ball staff, closes #64 --- squirrelbattle/display/texturepack.py | 3 +++ squirrelbattle/entities/items.py | 39 ++++++++++++++++++++++++--- squirrelbattle/entities/player.py | 2 +- squirrelbattle/interfaces.py | 3 ++- 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/squirrelbattle/display/texturepack.py b/squirrelbattle/display/texturepack.py index 0ced27f..3ba64f5 100644 --- a/squirrelbattle/display/texturepack.py +++ b/squirrelbattle/display/texturepack.py @@ -25,6 +25,7 @@ class TexturePack: CHESTPLATE: str EAGLE: str EMPTY: str + FIRE_BALL_STAFF: str FLOOR: str HAZELNUT: str HEART: str @@ -82,6 +83,7 @@ TexturePack.ASCII_PACK = TexturePack( EAGLE='ยต', EMPTY=' ', EXPLOSION='%', + FIRE_BALL_STAFF=':', FLOOR='.', LADDER='H', HAZELNUT='ยค', @@ -121,6 +123,7 @@ TexturePack.SQUIRREL_PACK = TexturePack( EAGLE='๐Ÿฆ…', EMPTY=' ', EXPLOSION='๐Ÿ’ฅ', + FIRE_BALL_STAFF='๐Ÿช„', FLOOR='โ–ˆโ–ˆ', LADDER=('๐Ÿชœ', curses.COLOR_WHITE, (1000, 1000, 1000), curses.COLOR_WHITE, (1000, 1000, 1000)), diff --git a/squirrelbattle/entities/items.py b/squirrelbattle/entities/items.py index 8310b81..9abcfc3 100644 --- a/squirrelbattle/entities/items.py +++ b/squirrelbattle/entities/items.py @@ -86,7 +86,7 @@ class Item(Entity): """ return [BodySnatchPotion, Bomb, Heart, Shield, Sword,\ Chestplate, Helmet, RingCritical, RingXP, \ - ScrollofDamage, ScrollofWeakening, Ruler, Bow] + ScrollofDamage, ScrollofWeakening, Ruler, Bow, FireBallStaff] def be_sold(self, buyer: InventoryHolder, seller: InventoryHolder) -> bool: """ @@ -505,9 +505,10 @@ class LongRangeWeapon(Item): self.held_by.x-entity.x<=self.range: to_kill = entity if to_kill: - self.held_by.map.logs.add_message(_("{name} is shot by an arrow.")\ - .format(name=to_kill.translated_name.capitalize())+ " " \ - + to_kill.take_damage(self.held_by, self.damage + getattr(self.held_by, self.stat))) + 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))) def equip(self) -> None: """ @@ -523,6 +524,12 @@ class LongRangeWeapon(Item): or intelligence for a magic staff. """ + @property + def string(self) -> str: + """ + 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 @@ -538,3 +545,27 @@ class Bow(LongRangeWeapon): Here it is 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." diff --git a/squirrelbattle/entities/player.py b/squirrelbattle/entities/player.py index b4be043..615dfd5 100644 --- a/squirrelbattle/entities/player.py +++ b/squirrelbattle/entities/player.py @@ -4,7 +4,7 @@ from random import randint from typing import Dict, Optional, Tuple -from .items import Item, Bow +from .items import Item from ..interfaces import FightingEntity, InventoryHolder diff --git a/squirrelbattle/interfaces.py b/squirrelbattle/interfaces.py index 2618892..dc4bdda 100644 --- a/squirrelbattle/interfaces.py +++ b/squirrelbattle/interfaces.py @@ -630,7 +630,7 @@ class Entity: Trumpet from squirrelbattle.entities.items import BodySnatchPotion, Bomb, \ Heart, Sword, Shield, Chestplate, Helmet, RingCritical, RingXP, \ - ScrollofDamage, ScrollofWeakening, Ruler, Bow + ScrollofDamage, ScrollofWeakening, Ruler, Bow, FireBallStaff return { "Tiger": Tiger, "Bomb": Bomb, @@ -654,6 +654,7 @@ class Entity: "ScrollofDamage": ScrollofDamage, "ScrollofWeakening": ScrollofWeakening, "Bow": Bow, + "FireBallStaff": FireBallStaff, } def save_state(self) -> dict: