Start combat unit testing

This commit is contained in:
Griatch 2023-03-04 20:02:11 +01:00
parent 890cee5c91
commit 3f96004e99
2 changed files with 36 additions and 2 deletions

View file

@ -785,8 +785,8 @@ class _CmdCombatBase(Command):
self.args = self.args.strip()
if not self.caller.location:
self.caller.msg("Can't fight here!")
if not self.caller.location or not self.callerlocation.allow_combat:
self.msg("Can't fight here!")
raise InterruptCommand()

View file

@ -15,6 +15,40 @@ from ..npcs import EvAdventureMob
from ..objects import EvAdventureConsumable, EvAdventureRunestone, EvAdventureWeapon
from .mixins import EvAdventureMixin
class EvAdventureCombatHandlerTest(EvAdventureMixin, BaseEvenniaTest):
"""
Test methods on the turn-based combat handler
"""
maxDiff = None
# make sure to mock away all time-keeping elements
@patch(
"evennia.contrib.tutorials.evadventure.combat_turnbased.EvAdventureCombatHandler.interval",
new=-1,
)
@patch(
"evennia.contrib.tutorials.evadventure.combat_turnbased.delay",
new=MagicMock(return_value=None),
)
def setUp(self):
super().setUp()
self.location.allow_combat = True
self.location.allow_death = True
self.combatant = self.character
self.target = create.create_object(
EvAdventureMob,
key="testmonster",
location=self.location,
attributes=(("is_idle", True),),
)
# this already starts turn 1
self.combathandler = combat_turnbased.join_combat(self.combatant, self.target)
# class EvAdventureTurnbasedCombatHandlerTest(EvAdventureMixin, BaseEvenniaTest):
# """
# Test methods on the turn-based combat handler.