evennia.contrib.tutorials.evadventure.combat_base¶
EvAdventure Base combat utilities.
This establishes the basic building blocks for combat:
CombatFailure - exception for combat-specific errors.
CombatAction (and subclasses) - classes encompassing all the working around an action. They are initialized from ‘action-dicts** - dictionaries with all the relevant data for the particular invocation
CombatHandler - base class for running a combat. Exactly how this is used depends on the type of combat intended (twitch- or turn-based) so many details of this will be implemented in child classes.
-
exception
evennia.contrib.tutorials.evadventure.combat_base.
CombatFailure
[source]¶ Bases:
RuntimeError
Some failure during combat actions.
-
class
evennia.contrib.tutorials.evadventure.combat_base.
CombatAction
(combathandler, combatant, action_dict)[source]¶ Bases:
object
Parent class for all actions.
This represents the executable code to run to perform an action. It is initialized from an ‘action-dict’, a set of properties stored in the action queue by each combatant.
-
__init__
(combathandler, combatant, action_dict)[source]¶ Each key-value pair in the action-dict is stored as a property on this class for later access.
- Parameters
combatant (EvAdventureCharacter, EvAdventureNPC) – The combatant performing the action.
action_dict (dict) – A dict containing all properties to initialize on this class. This should not be any keys with _ prefix, since these are used internally by the class.
-
msg
(message, broadcast=True)[source]¶ Convenience route to the combathandler msg-sender mechanism.
- Parameters
message (str) – Message to send; use $You() and $You(other.key) to refer to the combatant doing the action and other combatants, respectively.
-
can_use
()[source]¶ Called to determine if the action is usable with the current settings. This does not actually perform the action.
- Returns
bool – If this action can be used at this time.
-
-
class
evennia.contrib.tutorials.evadventure.combat_base.
CombatActionHold
(combathandler, combatant, action_dict)[source]¶ Bases:
evennia.contrib.tutorials.evadventure.combat_base.CombatAction
Action that does nothing.
action_dict = { "key": "hold" }
-
class
evennia.contrib.tutorials.evadventure.combat_base.
CombatActionAttack
(combathandler, combatant, action_dict)[source]¶ Bases:
evennia.contrib.tutorials.evadventure.combat_base.CombatAction
A regular attack, using a wielded weapon.
action-dict = { "key": "attack", "target": Character/Object }
-
class
evennia.contrib.tutorials.evadventure.combat_base.
CombatActionStunt
(combathandler, combatant, action_dict)[source]¶ Bases:
evennia.contrib.tutorials.evadventure.combat_base.CombatAction
Perform a stunt the grants a beneficiary (can be self) advantage on their next action against a target. Whenever performing a stunt that would affect another negatively (giving them disadvantage against an ally, or granting an advantage against them, we need to make a check first. We don’t do a check if giving an advantage to an ally or ourselves.
action_dict = { "key": "stunt", "recipient": Character/NPC, "target": Character/NPC, "advantage": bool, # if False, it's a disadvantage "stunt_type": Ability, # what ability (like STR, DEX etc) to use to perform this stunt. "defense_type": Ability, # what ability to use to defend against (negative) effects of this stunt. }
-
class
evennia.contrib.tutorials.evadventure.combat_base.
CombatActionUseItem
(combathandler, combatant, action_dict)[source]¶ Bases:
evennia.contrib.tutorials.evadventure.combat_base.CombatAction
Use an item in combat. This is meant for one-off or limited-use items (so things like scrolls and potions, not swords and shields). If this is some sort of weapon or spell rune, we refer to the item to determine what to use for attack/defense rolls.
action_dict = { "key": "use", "item": Object "target": Character/NPC/Object/None }
-
class
evennia.contrib.tutorials.evadventure.combat_base.
CombatActionWield
(combathandler, combatant, action_dict)[source]¶ Bases:
evennia.contrib.tutorials.evadventure.combat_base.CombatAction
Wield a new weapon (or spell) from your inventory. This will swap out the one you are currently wielding, if any.
action_dict = { "key": "wield", "item": Object }
-
class
evennia.contrib.tutorials.evadventure.combat_base.
EvAdventureCombatBaseHandler
(*args, **kwargs)[source]¶ Bases:
evennia.scripts.scripts.DefaultScript
This script is created when a combat starts. It ‘ticks’ the combat and tracks all sides of it.
-
action_classes
= {'attack': <class 'evennia.contrib.tutorials.evadventure.combat_base.CombatActionAttack'>, 'hold': <class 'evennia.contrib.tutorials.evadventure.combat_base.CombatActionHold'>, 'stunt': <class 'evennia.contrib.tutorials.evadventure.combat_base.CombatActionStunt'>, 'use': <class 'evennia.contrib.tutorials.evadventure.combat_base.CombatActionUseItem'>, 'wield': <class 'evennia.contrib.tutorials.evadventure.combat_base.CombatActionWield'>}¶
-
fallback_action_dict
¶ AttributeProperty.
-
classmethod
get_or_create_combathandler
(obj, **kwargs)[source]¶ Get or create a combathandler on obj.
- Parameters
obj (any) – The Typeclassed entity to store the CombatHandler Script on. This could be a location (for turn-based combat) or a Character (for twitch-based combat).
- Keyword Arguments
combathandler_key (str) – They key name for the script. Will be ‘combathandler’ by default.
**kwargs – Arguments to the Script, if it is created.
-
msg
(message, combatant=None, broadcast=True, location=None)[source]¶ Central place for sending messages to combatants. This allows for adding any combat-specific text-decoration in one place.
- Parameters
message (str) – The message to send.
combatant (Object) – The ‘You’ in the message, if any.
broadcast (bool) – If False, combatant must be included and will be the only one to see the message. If True, send to everyone in the location.
location (Object, optional) – If given, use this as the location to send broadcast messages to. If not, use self.obj as that location.
Notes
If combatant is given, use $You/you() markup to create a message that looks different depending on who sees it. Use $You(combatant_key) to refer to other combatants.
-
get_combat_summary
(combatant)[source]¶ Get a ‘battle report’ - an overview of the current state of combat from the perspective of one of the sides.
- Parameters
combatant (EvAdventureCharacter, EvAdventureNPC) – The combatant to get.
- Returns
EvTable – A table representing the current state of combat.
Example:
Goblin shaman (Perfect)
Gregor (Hurt) Goblin brawler(Hurt) Bob (Perfect) vs Goblin grunt 1 (Hurt)
Goblin grunt 2 (Perfect) Goblin grunt 3 (Wounded)
-
get_sides
(combatant)[source]¶ Get a listing of the two ‘sides’ of this combat, from the perspective of the provided combatant. The sides don’t need to be balanced.
- Parameters
combatant (Character or NPC) – The one whose sides are to determined.
- Returns
tuple – A tuple of lists (allies, enemies), from the perspective of combatant.
Note
The sides are found by checking PCs vs NPCs. PCs can normally not attack other PCs, so are naturally allies. If the current room has the allow_pvp Attribute set, then _all_ other combatants (PCs and NPCs alike) are considered valid enemies (one could expand this with group mechanics).
-
give_advantage
(recipient, target)[source]¶ Let a benefiter gain advantage against the target.
- Parameters
recipient (Character or NPC) – The one to gain the advantage. This may or may not be the same entity that creates the advantage in the first place.
target (Character or NPC) – The one against which the target gains advantage. This could (in principle) be the same as the benefiter (e.g. gaining advantage on some future boost)
-
give_disadvantage
(recipient, target)[source]¶ Let an affected party gain disadvantage against a target.
- Parameters
recipient (Character or NPC) – The one to get the disadvantage.
target (Character or NPC) – The one against which the target gains disadvantage, usually
enemy. (an) –
-
has_advantage
(combatant, target)[source]¶ Check if a given combatant has advantage against a target.
- Parameters
combatant (Character or NPC) – The one to check if they have advantage
target (Character or NPC) – The target to check advantage against.
-
has_disadvantage
(combatant, target)[source]¶ Check if a given combatant has disadvantage against a target.
- Parameters
combatant (Character or NPC) – The one to check if they have disadvantage
target (Character or NPC) – The target to check disadvantage against.
-
queue_action
(action_dict, combatant=None)[source]¶ Queue an action by adding the new actiondict.
- Parameters
action_dict (dict) – A dict describing the action class by name along with properties.
combatant (EvAdventureCharacter, EvAdventureNPC, optional) – A combatant queueing the action.
-
execute_next_action
(combatant)[source]¶ Perform a combatant’s next action.
- Parameters
combatant (EvAdventureCharacter, EvAdventureNPC) – The combatant performing and action.
-
check_stop_combat
()[source]¶ Check if this combat should be aborted, whatever this means for the particular the particular combat type.
- Keyword Arguments
kwargs – Any extra keyword args used.
- Returns
bool – If True, the stop_combat method should be called.
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶ Bases:
evennia.scripts.scripts.DefaultScript.MultipleObjectsReturned
-
path
= 'evennia.contrib.tutorials.evadventure.combat_base.EvAdventureCombatBaseHandler'¶
-
typename
= 'EvAdventureCombatBaseHandler'¶
-