diff --git a/squirrelbattle/entities/friendly.py b/squirrelbattle/entities/friendly.py index d5ca628..6c99090 100644 --- a/squirrelbattle/entities/friendly.py +++ b/squirrelbattle/entities/friendly.py @@ -48,5 +48,5 @@ class Sunflower(FriendlyEntity): super().__init__(name="sunflower", maxhealth=maxhealth, *args, **kwargs) @property - def dialogue_option(self): + def dialogue_option(self) -> list: return [_("Flower power!!"), _("The sun is warm today")] diff --git a/squirrelbattle/enums.py b/squirrelbattle/enums.py index c04011b..7e4efa4 100644 --- a/squirrelbattle/enums.py +++ b/squirrelbattle/enums.py @@ -46,6 +46,7 @@ class KeyValues(Enum): DROP = auto() SPACE = auto() CHAT = auto() + WAIT = auto() @staticmethod def translate_key(key: str, settings: Settings) -> Optional["KeyValues"]: @@ -78,4 +79,6 @@ class KeyValues(Enum): return KeyValues.SPACE elif key == settings.KEY_CHAT: return KeyValues.CHAT + elif key == settings.KEY_WAIT: + return KeyValues.WAIT return None diff --git a/squirrelbattle/game.py b/squirrelbattle/game.py index 558f25a..ed3b60f 100644 --- a/squirrelbattle/game.py +++ b/squirrelbattle/game.py @@ -128,6 +128,8 @@ class Game: elif key == KeyValues.CHAT: # Wait for the direction of the friendly entity self.waiting_for_friendly_key = True + elif key == KeyValues.WAIT: + self.map.tick() def handle_friendly_entity_chat(self, key: KeyValues) -> None: """ diff --git a/squirrelbattle/locale/de/LC_MESSAGES/squirrelbattle.po b/squirrelbattle/locale/de/LC_MESSAGES/squirrelbattle.po index 8bcd104..39cfeec 100644 --- a/squirrelbattle/locale/de/LC_MESSAGES/squirrelbattle.po +++ b/squirrelbattle/locale/de/LC_MESSAGES/squirrelbattle.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: squirrelbattle 3.14.1\n" "Report-Msgid-Bugs-To: squirrel-battle@crans.org\n" -"POT-Creation-Date: 2020-12-12 17:24+0100\n" +"POT-Creation-Date: 2020-12-12 18:02+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -58,11 +58,11 @@ msgstr "Die Bombe explodiert." msgid "{player} exchanged its body with {entity}." msgstr "{player} täuscht seinem Körper mit {entity} aus." -#: squirrelbattle/game.py:203 squirrelbattle/tests/game_test.py:573 +#: squirrelbattle/game.py:205 squirrelbattle/tests/game_test.py:573 msgid "You do not have enough money" msgstr "Sie haben nicht genug Geld" -#: squirrelbattle/game.py:247 +#: squirrelbattle/game.py:249 msgid "" "Some keys are missing in your save file.\n" "Your save seems to be corrupt. It got deleted." @@ -70,7 +70,7 @@ msgstr "" "In Ihrer Speicherdatei fehlen einige Schlüssel.\n" "Ihre Speicherung scheint korrupt zu sein. Es wird gelöscht." -#: squirrelbattle/game.py:255 +#: squirrelbattle/game.py:257 msgid "" "No player was found on this map!\n" "Maybe you died?" @@ -78,7 +78,7 @@ msgstr "" "Auf dieser Karte wurde kein Spieler gefunden!\n" "Vielleicht sind Sie gestorben?" -#: squirrelbattle/game.py:275 +#: squirrelbattle/game.py:277 msgid "" "The JSON file is not correct.\n" "Your save seems corrupted. It got deleted." @@ -193,57 +193,61 @@ msgid "Key used to talk to a friendly entity" msgstr "Taste um mit einer friedlicher Entität zu sprechen" #: squirrelbattle/tests/translations_test.py:55 +msgid "Key used to wait" +msgstr "Wartentaste" + +#: squirrelbattle/tests/translations_test.py:56 msgid "Texture pack" msgstr "Textur-Packung" -#: squirrelbattle/tests/translations_test.py:56 +#: squirrelbattle/tests/translations_test.py:57 msgid "Language" msgstr "Sprache" -#: squirrelbattle/tests/translations_test.py:59 +#: squirrelbattle/tests/translations_test.py:60 msgid "player" msgstr "Spieler" -#: squirrelbattle/tests/translations_test.py:61 +#: squirrelbattle/tests/translations_test.py:62 msgid "hedgehog" msgstr "Igel" -#: squirrelbattle/tests/translations_test.py:62 +#: squirrelbattle/tests/translations_test.py:63 msgid "merchant" msgstr "Kaufmann" -#: squirrelbattle/tests/translations_test.py:63 +#: squirrelbattle/tests/translations_test.py:64 msgid "rabbit" msgstr "Kanninchen" -#: squirrelbattle/tests/translations_test.py:64 +#: squirrelbattle/tests/translations_test.py:65 msgid "sunflower" msgstr "Sonnenblume" -#: squirrelbattle/tests/translations_test.py:65 +#: squirrelbattle/tests/translations_test.py:66 msgid "teddy bear" msgstr "Teddybär" -#: squirrelbattle/tests/translations_test.py:66 +#: squirrelbattle/tests/translations_test.py:67 msgid "tiger" msgstr "Tiger" -#: squirrelbattle/tests/translations_test.py:68 +#: squirrelbattle/tests/translations_test.py:69 msgid "body snatch potion" msgstr "Leichenfleddererzaubertrank" -#: squirrelbattle/tests/translations_test.py:69 +#: squirrelbattle/tests/translations_test.py:70 msgid "bomb" msgstr "Bombe" -#: squirrelbattle/tests/translations_test.py:70 +#: squirrelbattle/tests/translations_test.py:71 msgid "explosion" msgstr "Explosion" -#: squirrelbattle/tests/translations_test.py:71 +#: squirrelbattle/tests/translations_test.py:72 msgid "heart" msgstr "Herz" -#: squirrelbattle/tests/translations_test.py:72 +#: squirrelbattle/tests/translations_test.py:73 msgid "sword" msgstr "schwert" diff --git a/squirrelbattle/locale/es/LC_MESSAGES/squirrelbattle.po b/squirrelbattle/locale/es/LC_MESSAGES/squirrelbattle.po index fc0239e..f4d1c3c 100644 --- a/squirrelbattle/locale/es/LC_MESSAGES/squirrelbattle.po +++ b/squirrelbattle/locale/es/LC_MESSAGES/squirrelbattle.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: squirrelbattle 3.14.1\n" "Report-Msgid-Bugs-To: squirrel-battle@crans.org\n" -"POT-Creation-Date: 2020-12-12 17:24+0100\n" +"POT-Creation-Date: 2020-12-12 18:02+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -57,11 +57,11 @@ msgstr "La bomba está explotando." msgid "{player} exchanged its body with {entity}." msgstr "{player} intercambió su cuerpo con {entity}." -#: squirrelbattle/game.py:203 squirrelbattle/tests/game_test.py:573 +#: squirrelbattle/game.py:205 squirrelbattle/tests/game_test.py:573 msgid "You do not have enough money" msgstr "No tienes suficiente dinero" -#: squirrelbattle/game.py:247 +#: squirrelbattle/game.py:249 msgid "" "Some keys are missing in your save file.\n" "Your save seems to be corrupt. It got deleted." @@ -69,7 +69,7 @@ msgstr "" "Algunas claves faltan en su archivo de guarda.\n" "Su guarda parece a ser corruptido. Fue eliminado." -#: squirrelbattle/game.py:255 +#: squirrelbattle/game.py:257 msgid "" "No player was found on this map!\n" "Maybe you died?" @@ -77,7 +77,7 @@ msgstr "" "No jugador encontrado sobre la carta !\n" "¿ Quizas murió ?" -#: squirrelbattle/game.py:275 +#: squirrelbattle/game.py:277 msgid "" "The JSON file is not correct.\n" "Your save seems corrupted. It got deleted." @@ -192,57 +192,61 @@ msgid "Key used to talk to a friendly entity" msgstr "Tecla para hablar con una entidad amiga" #: squirrelbattle/tests/translations_test.py:55 +msgid "Key used to wait" +msgstr "Tecla para espera" + +#: squirrelbattle/tests/translations_test.py:56 msgid "Texture pack" msgstr "Paquete de texturas" -#: squirrelbattle/tests/translations_test.py:56 +#: squirrelbattle/tests/translations_test.py:57 msgid "Language" msgstr "Languaje" -#: squirrelbattle/tests/translations_test.py:59 +#: squirrelbattle/tests/translations_test.py:60 msgid "player" msgstr "jugador" -#: squirrelbattle/tests/translations_test.py:61 +#: squirrelbattle/tests/translations_test.py:62 msgid "hedgehog" msgstr "erizo" -#: squirrelbattle/tests/translations_test.py:62 +#: squirrelbattle/tests/translations_test.py:63 msgid "merchant" msgstr "comerciante" -#: squirrelbattle/tests/translations_test.py:63 +#: squirrelbattle/tests/translations_test.py:64 msgid "rabbit" msgstr "conejo" -#: squirrelbattle/tests/translations_test.py:64 +#: squirrelbattle/tests/translations_test.py:65 msgid "sunflower" msgstr "girasol" -#: squirrelbattle/tests/translations_test.py:65 +#: squirrelbattle/tests/translations_test.py:66 msgid "teddy bear" msgstr "osito de peluche" -#: squirrelbattle/tests/translations_test.py:66 +#: squirrelbattle/tests/translations_test.py:67 msgid "tiger" msgstr "tigre" -#: squirrelbattle/tests/translations_test.py:68 +#: squirrelbattle/tests/translations_test.py:69 msgid "body snatch potion" msgstr "poción de intercambio" -#: squirrelbattle/tests/translations_test.py:69 +#: squirrelbattle/tests/translations_test.py:70 msgid "bomb" msgstr "bomba" -#: squirrelbattle/tests/translations_test.py:70 +#: squirrelbattle/tests/translations_test.py:71 msgid "explosion" msgstr "explosión" -#: squirrelbattle/tests/translations_test.py:71 +#: squirrelbattle/tests/translations_test.py:72 msgid "heart" msgstr "corazón" -#: squirrelbattle/tests/translations_test.py:72 +#: squirrelbattle/tests/translations_test.py:73 msgid "sword" msgstr "espada" diff --git a/squirrelbattle/locale/fr/LC_MESSAGES/squirrelbattle.po b/squirrelbattle/locale/fr/LC_MESSAGES/squirrelbattle.po index e0282e2..8b1c4db 100644 --- a/squirrelbattle/locale/fr/LC_MESSAGES/squirrelbattle.po +++ b/squirrelbattle/locale/fr/LC_MESSAGES/squirrelbattle.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: squirrelbattle 3.14.1\n" "Report-Msgid-Bugs-To: squirrel-battle@crans.org\n" -"POT-Creation-Date: 2020-12-12 17:24+0100\n" +"POT-Creation-Date: 2020-12-12 18:02+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -58,11 +58,11 @@ msgstr "La bombe explose." msgid "{player} exchanged its body with {entity}." msgstr "{player} a échangé son corps avec {entity}." -#: squirrelbattle/game.py:203 squirrelbattle/tests/game_test.py:573 +#: squirrelbattle/game.py:205 squirrelbattle/tests/game_test.py:573 msgid "You do not have enough money" msgstr "Vous n'avez pas assez d'argent" -#: squirrelbattle/game.py:247 +#: squirrelbattle/game.py:249 msgid "" "Some keys are missing in your save file.\n" "Your save seems to be corrupt. It got deleted." @@ -70,7 +70,7 @@ msgstr "" "Certaines clés de votre ficher de sauvegarde sont manquantes.\n" "Votre sauvegarde semble corrompue. Elle a été supprimée." -#: squirrelbattle/game.py:255 +#: squirrelbattle/game.py:257 msgid "" "No player was found on this map!\n" "Maybe you died?" @@ -78,7 +78,7 @@ msgstr "" "Aucun joueur n'a été trouvé sur la carte !\n" "Peut-être êtes-vous mort ?" -#: squirrelbattle/game.py:275 +#: squirrelbattle/game.py:277 msgid "" "The JSON file is not correct.\n" "Your save seems corrupted. It got deleted." @@ -193,57 +193,61 @@ msgid "Key used to talk to a friendly entity" msgstr "Touche pour parler à une entité pacifique" #: squirrelbattle/tests/translations_test.py:55 +msgid "Key used to wait" +msgstr "Touche pour attendre" + +#: squirrelbattle/tests/translations_test.py:56 msgid "Texture pack" msgstr "Pack de textures" -#: squirrelbattle/tests/translations_test.py:56 +#: squirrelbattle/tests/translations_test.py:57 msgid "Language" msgstr "Langue" -#: squirrelbattle/tests/translations_test.py:59 +#: squirrelbattle/tests/translations_test.py:60 msgid "player" msgstr "joueur" -#: squirrelbattle/tests/translations_test.py:61 +#: squirrelbattle/tests/translations_test.py:62 msgid "hedgehog" msgstr "hérisson" -#: squirrelbattle/tests/translations_test.py:62 +#: squirrelbattle/tests/translations_test.py:63 msgid "merchant" msgstr "marchand" -#: squirrelbattle/tests/translations_test.py:63 +#: squirrelbattle/tests/translations_test.py:64 msgid "rabbit" msgstr "lapin" -#: squirrelbattle/tests/translations_test.py:64 +#: squirrelbattle/tests/translations_test.py:65 msgid "sunflower" msgstr "tournesol" -#: squirrelbattle/tests/translations_test.py:65 +#: squirrelbattle/tests/translations_test.py:66 msgid "teddy bear" msgstr "nounours" -#: squirrelbattle/tests/translations_test.py:66 +#: squirrelbattle/tests/translations_test.py:67 msgid "tiger" msgstr "tigre" -#: squirrelbattle/tests/translations_test.py:68 +#: squirrelbattle/tests/translations_test.py:69 msgid "body snatch potion" msgstr "potion d'arrachage de corps" -#: squirrelbattle/tests/translations_test.py:69 +#: squirrelbattle/tests/translations_test.py:70 msgid "bomb" msgstr "bombe" -#: squirrelbattle/tests/translations_test.py:70 +#: squirrelbattle/tests/translations_test.py:71 msgid "explosion" msgstr "" -#: squirrelbattle/tests/translations_test.py:71 +#: squirrelbattle/tests/translations_test.py:72 msgid "heart" msgstr "cœur" -#: squirrelbattle/tests/translations_test.py:72 +#: squirrelbattle/tests/translations_test.py:73 msgid "sword" msgstr "épée" diff --git a/squirrelbattle/settings.py b/squirrelbattle/settings.py index 4e6040c..91edfa4 100644 --- a/squirrelbattle/settings.py +++ b/squirrelbattle/settings.py @@ -32,6 +32,7 @@ class Settings: self.KEY_EQUIP = ['e', 'Key used to equip an item in the inventory'] self.KEY_DROP = ['r', 'Key used to drop an item in the inventory'] self.KEY_CHAT = ['t', 'Key used to talk to a friendly entity'] + self.KEY_WAIT = ['w', 'Key used to wait'] self.TEXTURE_PACK = ['ascii', 'Texture pack'] self.LOCALE = [locale.getlocale()[0][:2], 'Language'] diff --git a/squirrelbattle/tests/game_test.py b/squirrelbattle/tests/game_test.py index e355086..52aeeaf 100644 --- a/squirrelbattle/tests/game_test.py +++ b/squirrelbattle/tests/game_test.py @@ -8,7 +8,7 @@ from ..bootstrap import Bootstrap from ..display.display import Display from ..display.display_manager import DisplayManager from ..entities.friendly import Merchant, Sunflower -from ..entities.items import Bomb, Heart, Sword +from ..entities.items import Bomb, Heart, Sword, Explosion from ..entities.player import Player from ..enums import DisplayActions from ..game import Game, KeyValues, GameMode @@ -140,6 +140,9 @@ class TestGame(unittest.TestCase): self.assertEqual(KeyValues.translate_key( self.game.settings.KEY_DROP, self.game.settings), KeyValues.DROP) + self.assertEqual(KeyValues.translate_key( + self.game.settings.KEY_WAIT, self.game.settings), + KeyValues.WAIT) self.assertEqual(KeyValues.translate_key(' ', self.game.settings), KeyValues.SPACE) self.assertEqual(KeyValues.translate_key('plop', self.game.settings), @@ -227,6 +230,12 @@ class TestGame(unittest.TestCase): self.assertEqual(new_y, y) self.assertEqual(new_x, x - 1) + explosion = Explosion() + self.game.map.add_entity(explosion) + self.assertIn(explosion, self.game.map.entities) + self.game.handle_key_pressed(KeyValues.WAIT) + self.assertNotIn(explosion, self.game.map.entities) + self.game.handle_key_pressed(KeyValues.SPACE) self.assertEqual(self.game.state, GameMode.MAINMENU) @@ -297,13 +306,13 @@ class TestGame(unittest.TestCase): self.game.handle_key_pressed(KeyValues.ENTER) self.assertEqual(self.game.state, GameMode.SETTINGS) - # Define the "move up" key to 'w' + # Define the "move up" key to 'h' self.assertFalse(self.game.settings_menu.waiting_for_key) self.game.handle_key_pressed(KeyValues.ENTER) self.assertTrue(self.game.settings_menu.waiting_for_key) - self.game.handle_key_pressed(None, 'w') + self.game.handle_key_pressed(None, 'h') self.assertFalse(self.game.settings_menu.waiting_for_key) - self.assertEqual(self.game.settings.KEY_UP_PRIMARY, 'w') + self.assertEqual(self.game.settings.KEY_UP_PRIMARY, 'h') # Navigate to "move left" self.game.handle_key_pressed(KeyValues.DOWN) @@ -324,7 +333,7 @@ class TestGame(unittest.TestCase): self.assertEqual(self.game.settings.KEY_LEFT_PRIMARY, 'a') # Navigate to "texture pack" - for ignored in range(10): + for ignored in range(11): self.game.handle_key_pressed(KeyValues.DOWN) # Change texture pack @@ -496,8 +505,8 @@ class TestGame(unittest.TestCase): self.assertEqual(self.game.state, GameMode.PLAY) self.assertTrue(self.game.logs.messages) # Ensure that the message is a good message - self.assertIn(self.game.logs.messages[1][16:], - Sunflower().dialogue_option) + self.assertTrue(any(self.game.logs.messages[1].endswith(msg) + for msg in Sunflower().dialogue_option)) # Test all directions to detect the friendly entity self.game.player.move(3, 6) diff --git a/squirrelbattle/tests/translations_test.py b/squirrelbattle/tests/translations_test.py index 4b8444d..0bd8873 100644 --- a/squirrelbattle/tests/translations_test.py +++ b/squirrelbattle/tests/translations_test.py @@ -52,6 +52,7 @@ class TestTranslations(unittest.TestCase): "Touche pour jeter un objet de l'inventaire") self.assertEqual(_("Key used to talk to a friendly entity"), "Touche pour parler à une entité pacifique") + self.assertEqual(_("Key used to wait"), "Touche pour attendre") self.assertEqual(_("Texture pack"), "Pack de textures") self.assertEqual(_("Language"), "Langue")