Merge branch 'broken-bows' into 'master'
Broken bows Closes #70 See merge request ynerant/squirrel-battle!68
This commit is contained in:
commit
0821a5fa7a
@ -47,7 +47,7 @@ class Item(Entity):
|
||||
Indicates what should be done when the item is used.
|
||||
"""
|
||||
|
||||
def throw(self, direction: int) -> None:
|
||||
def throw(self, direction: int) -> Any:
|
||||
"""
|
||||
Indicates what should be done when the item is thrown.
|
||||
"""
|
||||
@ -555,7 +555,7 @@ class LongRangeWeapon(Weapon):
|
||||
self.held_by, self.damage
|
||||
+ getattr(self.held_by, self.stat))
|
||||
self.held_by.map.logs.add_message(line)
|
||||
return (to_kill.x, to_kill.y) if to_kill else None
|
||||
return (to_kill.y, to_kill.x) if to_kill else None
|
||||
|
||||
def equip(self) -> None:
|
||||
"""
|
||||
@ -621,17 +621,18 @@ class FireBallStaff(LongRangeWeapon):
|
||||
def string(self) -> str:
|
||||
return " is shot by a fire ball."
|
||||
|
||||
def throw(self, direction: int) -> None:
|
||||
def throw(self, direction: int) -> Any:
|
||||
"""
|
||||
Adds an explosion animation when killing something.
|
||||
"""
|
||||
coord = super().throw(direction)
|
||||
if coord:
|
||||
x = coord[0]
|
||||
y = coord[1]
|
||||
y = coord[0]
|
||||
x = coord[1]
|
||||
|
||||
explosion = Explosion(y=y, x=x)
|
||||
self.held_by.map.add_entity(explosion)
|
||||
return y, x
|
||||
|
||||
|
||||
class Monocle(Item):
|
||||
|
@ -53,7 +53,8 @@ class KeyValues(Enum):
|
||||
DANCE = auto()
|
||||
|
||||
@staticmethod
|
||||
def translate_key(key: str, settings: Settings) -> Optional["KeyValues"]:
|
||||
def translate_key(key: str, settings: Settings) \
|
||||
-> Optional["KeyValues"]: # noqa: C901
|
||||
"""
|
||||
Translates the raw string key into an enum value that we can use.
|
||||
"""
|
||||
@ -91,4 +92,3 @@ class KeyValues(Enum):
|
||||
return KeyValues.LAUNCH
|
||||
elif key == settings.KEY_DANCE:
|
||||
return KeyValues.DANCE
|
||||
return None
|
||||
|
@ -292,7 +292,8 @@ class Game:
|
||||
return
|
||||
|
||||
if self.player.equipped_main:
|
||||
self.player.equipped_main.throw(direction)
|
||||
if self.player.equipped_main.throw(direction):
|
||||
self.map.tick(self.player)
|
||||
|
||||
def handle_key_pressed_inventory(self, key: KeyValues) -> None:
|
||||
"""
|
||||
|
@ -260,12 +260,10 @@ class TestGame(unittest.TestCase):
|
||||
self.game.handle_key_pressed(KeyValues.DANCE)
|
||||
self.assertEqual(rabbit.confused, 1)
|
||||
string = rabbit.hit(self.game.player)
|
||||
self.assertEqual(string,
|
||||
"{name} is confused, it can not hit {opponent}."
|
||||
.format(name=_(rabbit.translated_name.capitalize()
|
||||
), opponent=_(
|
||||
self.game.player.translated_name
|
||||
)))
|
||||
self.assertEqual(
|
||||
string, _("{name} is confused, it can not hit {opponent}.")
|
||||
.format(name=rabbit.translated_name.capitalize(),
|
||||
opponent=self.game.player.translated_name))
|
||||
rabbit.confused = 0
|
||||
self.game.player.charisma = 0
|
||||
self.game.handle_key_pressed(KeyValues.DANCE)
|
||||
|
Loading…
Reference in New Issue
Block a user