mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Make evadventure get_sides more consistent. Resolve #3199
This commit is contained in:
parent
0d8533e61e
commit
eed5ea78a4
9 changed files with 20 additions and 52 deletions
|
|
@ -332,8 +332,6 @@ class EvAdventureCombatBaseHandler(DefaultScript):
|
|||
def get_combat_summary(self, combatant):
|
||||
|
||||
allies, enemies = self.get_sides(combatant)
|
||||
# we must include outselves at the top of the list (we are not returned from get_sides)
|
||||
allies.insert(0, combatant)
|
||||
nallies, nenemies = len(allies), len(enemies)
|
||||
|
||||
# prepare colors and hurt-levels
|
||||
|
|
|
|||
|
|
@ -176,11 +176,11 @@ class EvadventureTurnbasedCombatHandler(EvAdventureCombatBaseHandler):
|
|||
npcs = [comb for comb in self.combatants if comb not in pcs]
|
||||
if combatant in pcs:
|
||||
# combatant is a PC, so NPCs are all enemies
|
||||
allies = [comb for comb in pcs if comb != combatant]
|
||||
allies = pcs
|
||||
enemies = npcs
|
||||
else:
|
||||
# combatant is an NPC, so PCs are all enemies
|
||||
allies = [comb for comb in npcs if comb != combatant]
|
||||
allies = npcs
|
||||
enemies = pcs
|
||||
return allies, enemies
|
||||
```
|
||||
|
|
@ -897,7 +897,7 @@ def node_choose_allied_recipient(caller, raw_string, **kwargs):
|
|||
- Finally we merge this with the existing `kwargs` dict. The result is a new dict that now has the updated `"action_dict"` key pointing to an action-dict where `target` is set.
|
||||
- **Line 23**: We extend the `options` list with the default wizard options (`back`, `abort`). Since we made a helper function for this, this is only one line.
|
||||
|
||||
Creating the three other needed nodes `node_choose_enemy_recipient`, `node_choose_allied_target` and `node_choose_allied_recipient` are following the same pattern; they just use either the `allies` or `enemies` return from `combathandler.get_sides()` (for the `allies`, don't forget to add `caller` so you can target yourself!). It then sets either the `target` or `recipient` field in the `action_dict`. We leave these up to the reader to implement.
|
||||
Creating the three other needed nodes `node_choose_enemy_recipient`, `node_choose_allied_target` and `node_choose_allied_recipient` are following the same pattern; they just use either the `allies` or `enemies` return from `combathandler.get_sides(). It then sets either the `target` or `recipient` field in the `action_dict`. We leave these up to the reader to implement.
|
||||
|
||||
### Choose an Ability
|
||||
|
||||
|
|
|
|||
|
|
@ -152,11 +152,11 @@ class EvAdventureCombatTwitchHandler(EvAdventureCombatBaseHandler):
|
|||
npcs = [comb for comb in combatants if comb not in pcs]
|
||||
if combatant in pcs:
|
||||
# combatant is a PC, so NPCs are all enemies
|
||||
allies = [comb for comb in pcs if comb != combatant]
|
||||
allies = pcs
|
||||
enemies = npcs
|
||||
else:
|
||||
# combatant is an NPC, so PCs are all enemies
|
||||
allies = [comb for comb in npcs if comb != combatant]
|
||||
allies = npcs
|
||||
enemies = pcs
|
||||
return allies, enemies
|
||||
|
||||
|
|
@ -357,7 +357,6 @@ class EvAdventureCombatTwitchHandler(EvAdventureCombatBaseHandler):
|
|||
"""
|
||||
|
||||
allies, enemies = self.get_sides(self.obj)
|
||||
allies.append(self.obj)
|
||||
|
||||
location = self.obj.location
|
||||
|
||||
|
|
@ -382,7 +381,7 @@ class EvAdventureCombatTwitchHandler(EvAdventureCombatBaseHandler):
|
|||
|
||||
We must make sure to check if combat is over.
|
||||
|
||||
- **Line 12**: With our `.get_sides()` method we can easily get the two sides of the conflict. Note that `combatant` is not included among the allies, so we need to add it back in on the following line.
|
||||
- **Line 12**: With our `.get_sides()` method we can easily get the two sides of the conflict.
|
||||
- **Lines 18, 19**: We get everyone still alive _and still in the same room_. The latter condition is important in case we move away from the battle - you can't hit your enemy from another room.
|
||||
|
||||
In the `stop_method` we'll need to do a bunch of cleanup. We'll hold off on implementing this until we have the Commands written out. Read on.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue