Merge branch 'master' into 'moreitems'
# Conflicts: # squirrelbattle/entities/items.py # squirrelbattle/interfaces.py # squirrelbattle/tests/game_test.py
This commit is contained in:
@ -1,11 +1,12 @@
|
||||
# Copyright (C) 2020 by ÿnérant, eichhornchen, nicomarg, charlse
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import random
|
||||
import unittest
|
||||
|
||||
from squirrelbattle.entities.items import BodySnatchPotion, Bomb, Heart, Item, \
|
||||
Explosion
|
||||
from squirrelbattle.entities.monsters import Tiger, Hedgehog, Rabbit, TeddyBear
|
||||
from squirrelbattle.entities.monsters import Tiger, Hedgehog, Rabbit,\
|
||||
TeddyBear, GiantSeaEagle
|
||||
from squirrelbattle.entities.friendly import Trumpet
|
||||
from squirrelbattle.entities.player import Player
|
||||
from squirrelbattle.interfaces import Entity, Map
|
||||
@ -264,3 +265,17 @@ class TestEntities(unittest.TestCase):
|
||||
|
||||
player_state = player.save_state()
|
||||
self.assertEqual(player_state["current_xp"], 10)
|
||||
|
||||
def test_critical_hit(self) -> None:
|
||||
"""
|
||||
Ensure that critical hits are working.
|
||||
"""
|
||||
random.seed(2) # Next random.randint(1, 100) will output 8
|
||||
self.player.critical = 10
|
||||
sea_eagle = GiantSeaEagle()
|
||||
self.map.add_entity(sea_eagle)
|
||||
sea_eagle.move(2, 6)
|
||||
old_health = sea_eagle.health
|
||||
self.player.hit(sea_eagle)
|
||||
self.assertEqual(sea_eagle.health,
|
||||
old_health - self.player.strength * 4)
|
||||
|
@ -1,8 +1,8 @@
|
||||
# Copyright (C) 2020 by ÿnérant, eichhornchen, nicomarg, charlse
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import curses
|
||||
import os
|
||||
import random
|
||||
import unittest
|
||||
|
||||
from ..bootstrap import Bootstrap
|
||||
@ -11,7 +11,7 @@ from ..display.display_manager import DisplayManager
|
||||
from ..entities.friendly import Merchant, Sunflower, Chest
|
||||
from ..entities.items import Bomb, Heart, Sword, Explosion, Shield, Helmet, \
|
||||
Chestplate, RingCritical, Bow, FireBallStaff, ScrollofDamage,\
|
||||
ScrollofWeakening
|
||||
ScrollofWeakening, Monocle
|
||||
from ..entities.monsters import Rabbit, GiantSeaEagle
|
||||
from ..entities.player import Player
|
||||
from ..enums import DisplayActions, KeyValues, GameMode
|
||||
@ -67,6 +67,7 @@ class TestGame(unittest.TestCase):
|
||||
|
||||
new_state = self.game.save_state()
|
||||
self.assertEqual(old_state, new_state)
|
||||
self.assertIsNone(self.game.message)
|
||||
|
||||
# Ensure that the bomb is loaded
|
||||
self.assertTrue(self.game.player.inventory)
|
||||
@ -258,10 +259,12 @@ class TestGame(unittest.TestCase):
|
||||
self.game.state = GameMode.MAINMENU
|
||||
|
||||
# Change the color of the artwork
|
||||
self.game.display_actions(DisplayActions.MOUSE, 0, 10)
|
||||
self.game.display_actions(DisplayActions.MOUSE, 0, 10,
|
||||
curses.BUTTON1_CLICKED)
|
||||
|
||||
# Settings menu
|
||||
self.game.display_actions(DisplayActions.MOUSE, 25, 21)
|
||||
self.game.display_actions(DisplayActions.MOUSE, 25, 21,
|
||||
curses.BUTTON1_CLICKED)
|
||||
self.assertEqual(self.game.main_menu.position, 4)
|
||||
self.assertEqual(self.game.state, GameMode.SETTINGS)
|
||||
|
||||
@ -273,11 +276,13 @@ class TestGame(unittest.TestCase):
|
||||
self.game.state = GameMode.INVENTORY
|
||||
|
||||
# Click nowhere
|
||||
self.game.display_actions(DisplayActions.MOUSE, 0, 0)
|
||||
self.game.display_actions(DisplayActions.MOUSE, 0, 0,
|
||||
curses.BUTTON1_CLICKED)
|
||||
self.assertEqual(self.game.state, GameMode.INVENTORY)
|
||||
|
||||
# Click on the second item
|
||||
self.game.display_actions(DisplayActions.MOUSE, 8, 25)
|
||||
self.game.display_actions(DisplayActions.MOUSE, 8, 25,
|
||||
curses.BUTTON1_CLICKED)
|
||||
self.assertEqual(self.game.state, GameMode.INVENTORY)
|
||||
self.assertEqual(self.game.inventory_menu.position, 1)
|
||||
|
||||
@ -573,12 +578,14 @@ class TestGame(unittest.TestCase):
|
||||
# Buy the second item by clicking on it
|
||||
item = self.game.store_menu.validate()
|
||||
self.assertIn(item, merchant.inventory)
|
||||
self.game.display_actions(DisplayActions.MOUSE, 7, 25)
|
||||
self.game.display_actions(DisplayActions.MOUSE, 7, 25,
|
||||
curses.BUTTON1_CLICKED)
|
||||
self.assertIn(item, self.game.player.inventory)
|
||||
self.assertNotIn(item, merchant.inventory)
|
||||
|
||||
# Buy a heart
|
||||
merchant.inventory[1] = Heart()
|
||||
self.game.display_actions(DisplayActions.REFRESH)
|
||||
item = self.game.store_menu.validate()
|
||||
self.assertIn(item, merchant.inventory)
|
||||
self.assertEqual(item, merchant.inventory[1])
|
||||
@ -697,19 +704,21 @@ class TestGame(unittest.TestCase):
|
||||
self.game.save_state()
|
||||
ring.unequip()
|
||||
|
||||
def test_critical_hit(self) -> None:
|
||||
def test_monocle(self) -> None:
|
||||
"""
|
||||
Ensure that critical hits are working.
|
||||
The player is wearing a monocle, then the stats are displayed.
|
||||
"""
|
||||
random.seed(2) # Next random.randint(1, 100) will output 8
|
||||
self.game.player.critical = 10
|
||||
self.game.state = GameMode.PLAY
|
||||
|
||||
monocle = Monocle()
|
||||
monocle.hold(self.game.player)
|
||||
monocle.equip()
|
||||
|
||||
sea_eagle = GiantSeaEagle()
|
||||
self.game.map.add_entity(sea_eagle)
|
||||
sea_eagle.move(2, 6)
|
||||
old_health = sea_eagle.health
|
||||
self.game.player.hit(sea_eagle)
|
||||
self.assertEqual(sea_eagle.health,
|
||||
old_health - self.game.player.strength * 4)
|
||||
|
||||
self.game.display_actions(DisplayActions.REFRESH)
|
||||
|
||||
def test_ladders(self) -> None:
|
||||
"""
|
||||
@ -748,9 +757,11 @@ class TestGame(unittest.TestCase):
|
||||
"""
|
||||
self.game.state = GameMode.MAINMENU
|
||||
|
||||
self.game.display_actions(DisplayActions.MOUSE, 41, 41)
|
||||
self.game.display_actions(DisplayActions.MOUSE, 41, 41,
|
||||
curses.BUTTON1_CLICKED)
|
||||
self.assertEqual(self.game.state, GameMode.CREDITS)
|
||||
self.game.display_actions(DisplayActions.MOUSE, 21, 21)
|
||||
self.game.display_actions(DisplayActions.MOUSE, 21, 21,
|
||||
curses.BUTTON1_CLICKED)
|
||||
self.game.display_actions(DisplayActions.REFRESH)
|
||||
|
||||
self.game.state = GameMode.CREDITS
|
||||
|
@ -67,9 +67,18 @@ class TestTranslations(unittest.TestCase):
|
||||
self.assertEqual(_("sunflower"), "tournesol")
|
||||
self.assertEqual(_("teddy bear"), "nounours")
|
||||
self.assertEqual(_("tiger"), "tigre")
|
||||
self.assertEqual(_("eagle"), "pygargue")
|
||||
|
||||
self.assertEqual(_("body snatch potion"), "potion d'arrachage de corps")
|
||||
self.assertEqual(_("bomb"), "bombe")
|
||||
self.assertEqual(_("explosion"), "explosion")
|
||||
self.assertEqual(_("heart"), "cœur")
|
||||
self.assertEqual(_("sword"), "épée")
|
||||
self.assertEqual(_("helmet"), "casque")
|
||||
self.assertEqual(_("chestplate"), "plastron")
|
||||
self.assertEqual(_("shield"), "bouclier")
|
||||
self.assertEqual(_("ring of critical damage"),
|
||||
"anneau de coup critique")
|
||||
self.assertEqual(_("ring of more experience"),
|
||||
"anneau de plus d'expérience")
|
||||
self.assertEqual(_("monocle"), "monocle")
|
||||
|
Reference in New Issue
Block a user