Fix tests
This commit is contained in:
parent
6a7f59eaab
commit
4a08a6ae94
2 changed files with 10 additions and 16 deletions
|
|
@ -512,22 +512,18 @@ class EvAdventureCombatHandler(DefaultScript):
|
||||||
mapping={locobj.key: locobj for locobj in location_objs},
|
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.
|
Add a new combatant to the battle.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
*combatants (EvAdventureCharacter, EvAdventureNPC): Any number of combatants to add to
|
*combatants (EvAdventureCharacter, EvAdventureNPC): Any number of combatants to add to
|
||||||
the combat.
|
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:
|
||||||
if combatant not in self.combatants:
|
self.combatants[combatant] = deque((), maxlen=self.max_action_queue_size)
|
||||||
self.combatants[combatant] = deque((), maxlen=self.max_action_queue_size)
|
return True
|
||||||
return True
|
return False
|
||||||
|
|
||||||
def remove_combatant(self, combatant):
|
def remove_combatant(self, combatant):
|
||||||
"""
|
"""
|
||||||
|
|
@ -718,7 +714,7 @@ def get_or_create_combathandler(combatant, combathandler_name="combathandler", c
|
||||||
interval=combat_tick,
|
interval=combat_tick,
|
||||||
persistent=True,
|
persistent=True,
|
||||||
)
|
)
|
||||||
combathandler.add_combatants(combatant)
|
combathandler.add_combatant(combatant)
|
||||||
return combathandler
|
return combathandler
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -835,7 +831,7 @@ class CmdAttack(_CmdCombatBase):
|
||||||
return
|
return
|
||||||
|
|
||||||
# this can be done over and over
|
# this can be done over and over
|
||||||
is_new = self.combathandler.add_combatants(self)
|
is_new = self.combathandler.add_combatant(self)
|
||||||
if is_new:
|
if is_new:
|
||||||
# just joined combat - add the combat cmdset
|
# just joined combat - add the combat cmdset
|
||||||
self.caller.cmdset.add(CombatCmdSet)
|
self.caller.cmdset.add(CombatCmdSet)
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ class EvAdventureCombatHandlerTest(BaseEvenniaTest):
|
||||||
|
|
||||||
self.combathandler = combat.get_or_create_combathandler(self.combatant)
|
self.combathandler = combat.get_or_create_combathandler(self.combatant)
|
||||||
# add target to combat
|
# add target to combat
|
||||||
self.combathandler.add_combatants(self.target)
|
self.combathandler.add_combatant(self.target)
|
||||||
|
|
||||||
def _get_action(self, action_dict={"key": "nothing"}):
|
def _get_action(self, action_dict={"key": "nothing"}):
|
||||||
action_class = self.combathandler.action_classes[action_dict["key"]]
|
action_class = self.combathandler.action_classes[action_dict["key"]]
|
||||||
|
|
@ -143,7 +143,8 @@ class EvAdventureCombatHandlerTest(BaseEvenniaTest):
|
||||||
location=self.location,
|
location=self.location,
|
||||||
attributes=(("is_idle", True),),
|
attributes=(("is_idle", True),),
|
||||||
)
|
)
|
||||||
self.combathandler.add_combatants(combatant2, target2)
|
self.combathandler.add_combatant(combatant2)
|
||||||
|
self.combathandler.add_combatant(target2)
|
||||||
|
|
||||||
# allies to combatant
|
# allies to combatant
|
||||||
allies, enemies = self.combathandler.get_sides(self.combatant)
|
allies, enemies = self.combathandler.get_sides(self.combatant)
|
||||||
|
|
@ -360,9 +361,6 @@ class EvAdventureCombatHandlerTest(BaseEvenniaTest):
|
||||||
# swap to zweihander (two-handed sword)
|
# swap to zweihander (two-handed sword)
|
||||||
actiondict["item"] = zweihander
|
actiondict["item"] = zweihander
|
||||||
|
|
||||||
from evennia import set_trace
|
|
||||||
|
|
||||||
set_trace()
|
|
||||||
self._run_actions(actiondict)
|
self._run_actions(actiondict)
|
||||||
self.assertEqual(self.combatant.weapon, zweihander)
|
self.assertEqual(self.combatant.weapon, zweihander)
|
||||||
self.assertEqual(self.combatant.equipment.slots[WieldLocation.WEAPON_HAND], None)
|
self.assertEqual(self.combatant.equipment.slots[WieldLocation.WEAPON_HAND], None)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue