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.
|
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.
|
Indicates what should be done when the item is thrown.
|
||||||
"""
|
"""
|
||||||
|
@ -555,7 +555,7 @@ class LongRangeWeapon(Weapon):
|
||||||
self.held_by, self.damage
|
self.held_by, self.damage
|
||||||
+ getattr(self.held_by, self.stat))
|
+ getattr(self.held_by, self.stat))
|
||||||
self.held_by.map.logs.add_message(line)
|
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:
|
def equip(self) -> None:
|
||||||
"""
|
"""
|
||||||
|
@ -621,17 +621,18 @@ class FireBallStaff(LongRangeWeapon):
|
||||||
def string(self) -> str:
|
def string(self) -> str:
|
||||||
return " is shot by a fire ball."
|
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.
|
Adds an explosion animation when killing something.
|
||||||
"""
|
"""
|
||||||
coord = super().throw(direction)
|
coord = super().throw(direction)
|
||||||
if coord:
|
if coord:
|
||||||
x = coord[0]
|
y = coord[0]
|
||||||
y = coord[1]
|
x = coord[1]
|
||||||
|
|
||||||
explosion = Explosion(y=y, x=x)
|
explosion = Explosion(y=y, x=x)
|
||||||
self.held_by.map.add_entity(explosion)
|
self.held_by.map.add_entity(explosion)
|
||||||
|
return y, x
|
||||||
|
|
||||||
|
|
||||||
class Monocle(Item):
|
class Monocle(Item):
|
||||||
|
|
|
@ -53,7 +53,8 @@ class KeyValues(Enum):
|
||||||
DANCE = auto()
|
DANCE = auto()
|
||||||
|
|
||||||
@staticmethod
|
@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.
|
Translates the raw string key into an enum value that we can use.
|
||||||
"""
|
"""
|
||||||
|
@ -91,4 +92,3 @@ class KeyValues(Enum):
|
||||||
return KeyValues.LAUNCH
|
return KeyValues.LAUNCH
|
||||||
elif key == settings.KEY_DANCE:
|
elif key == settings.KEY_DANCE:
|
||||||
return KeyValues.DANCE
|
return KeyValues.DANCE
|
||||||
return None
|
|
||||||
|
|
|
@ -292,7 +292,8 @@ class Game:
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.player.equipped_main:
|
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:
|
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.game.handle_key_pressed(KeyValues.DANCE)
|
||||||
self.assertEqual(rabbit.confused, 1)
|
self.assertEqual(rabbit.confused, 1)
|
||||||
string = rabbit.hit(self.game.player)
|
string = rabbit.hit(self.game.player)
|
||||||
self.assertEqual(string,
|
self.assertEqual(
|
||||||
"{name} is confused, it can not hit {opponent}."
|
string, _("{name} is confused, it can not hit {opponent}.")
|
||||||
.format(name=_(rabbit.translated_name.capitalize()
|
.format(name=rabbit.translated_name.capitalize(),
|
||||||
), opponent=_(
|
opponent=self.game.player.translated_name))
|
||||||
self.game.player.translated_name
|
|
||||||
)))
|
|
||||||
rabbit.confused = 0
|
rabbit.confused = 0
|
||||||
self.game.player.charisma = 0
|
self.game.player.charisma = 0
|
||||||
self.game.handle_key_pressed(KeyValues.DANCE)
|
self.game.handle_key_pressed(KeyValues.DANCE)
|
||||||
|
|
Loading…
Reference in New Issue