Fix tests

This commit is contained in:
Griatch 2023-03-06 20:12:54 +01:00
parent 6a7f59eaab
commit 4a08a6ae94
2 changed files with 10 additions and 16 deletions

View file

@ -512,22 +512,18 @@ class EvAdventureCombatHandler(DefaultScript):
mapping={locobj.key: locobj for locobj in location_objs},
)
def add_combatants(self, *combatants):
def add_combatant(self, combatant):
"""
Add a new combatant to the battle.
Args:
*combatants (EvAdventureCharacter, EvAdventureNPC): Any number of combatants to add to
the combat.
Returns:
bool: True if the combatant was added, False otherwise (that is, they
were already added from before).
"""
for combatant in combatants:
if combatant not in self.combatants:
self.combatants[combatant] = deque((), maxlen=self.max_action_queue_size)
return True
if combatant not in self.combatants:
self.combatants[combatant] = deque((), maxlen=self.max_action_queue_size)
return True
return False
def remove_combatant(self, combatant):
"""
@ -718,7 +714,7 @@ def get_or_create_combathandler(combatant, combathandler_name="combathandler", c
interval=combat_tick,
persistent=True,
)
combathandler.add_combatants(combatant)
combathandler.add_combatant(combatant)
return combathandler
@ -835,7 +831,7 @@ class CmdAttack(_CmdCombatBase):
return
# this can be done over and over
is_new = self.combathandler.add_combatants(self)
is_new = self.combathandler.add_combatant(self)
if is_new:
# just joined combat - add the combat cmdset
self.caller.cmdset.add(CombatCmdSet)

View file

@ -59,7 +59,7 @@ class EvAdventureCombatHandlerTest(BaseEvenniaTest):
self.combathandler = combat.get_or_create_combathandler(self.combatant)
# add target to combat
self.combathandler.add_combatants(self.target)
self.combathandler.add_combatant(self.target)
def _get_action(self, action_dict={"key": "nothing"}):
action_class = self.combathandler.action_classes[action_dict["key"]]
@ -143,7 +143,8 @@ class EvAdventureCombatHandlerTest(BaseEvenniaTest):
location=self.location,
attributes=(("is_idle", True),),
)
self.combathandler.add_combatants(combatant2, target2)
self.combathandler.add_combatant(combatant2)
self.combathandler.add_combatant(target2)
# allies to combatant
allies, enemies = self.combathandler.get_sides(self.combatant)
@ -360,9 +361,6 @@ class EvAdventureCombatHandlerTest(BaseEvenniaTest):
# swap to zweihander (two-handed sword)
actiondict["item"] = zweihander
from evennia import set_trace
set_trace()
self._run_actions(actiondict)
self.assertEqual(self.combatant.weapon, zweihander)
self.assertEqual(self.combatant.equipment.slots[WieldLocation.WEAPON_HAND], None)