evennia.contrib.tutorials.evadventure.combat_turnbased¶
EvAdventure Turn-based combat
This implements a turn-based (Final Fantasy, etc) style of MUD combat.
In this variation, all combatants are sharing the same combat handler, sitting on the current room. The user will receive a menu of combat options and each combatat has a certain time time (e.g. 30s) to select their next action or do nothing. To speed up play, as soon as everyone in combat selected their next action, the next turn runs immediately, regardless of the timeout.
With this example, all chosen combat actions are considered to happen at the same time (so you are able to kill and be killed in the same turn).
Unlike in twitch-like combat, there is no movement while in turn-based combat. Fleeing is a select action that takes several vulnerable turns to complete.
-
class
evennia.contrib.tutorials.evadventure.combat_turnbased.
CombatActionFlee
(combathandler, combatant, action_dict)[source]¶ Bases:
evennia.contrib.tutorials.evadventure.combat_base.CombatAction
Start (or continue) fleeing/disengaging from combat.
- action_dict = {
“key”: “flee”,
}
Note
Refer to as ‘flee’.
-
class
evennia.contrib.tutorials.evadventure.combat_turnbased.
EvAdventureTurnbasedCombatHandler
(*args, **kwargs)[source]¶ Bases:
evennia.contrib.tutorials.evadventure.combat_base.EvAdventureCombatBaseHandler
A version of the combathandler, handling turn-based combat.
-
action_classes
= {'attack': <class 'evennia.contrib.tutorials.evadventure.combat_base.CombatActionAttack'>, 'flee': <class 'evennia.contrib.tutorials.evadventure.combat_turnbased.CombatActionFlee'>, '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'>}¶
-
flee_timeout
¶ AttributeProperty.
-
fallback_action_dict
¶ AttributeProperty.
-
turn
¶ AttributeProperty.
-
combatants
¶ AttributeProperty.
-
advantage_matrix
¶ AttributeProperty.
-
disadvantage_matrix
¶ AttributeProperty.
-
fleeing_combatants
¶ AttributeProperty.
-
defeated_combatants
¶ AttributeProperty.
-
give_advantage
(combatant, target)[source]¶ Let a benefiter gain advantage against the target.
- Parameters
combatant (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
(combatant, target, **kwargs)[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 an enemy.
-
has_advantage
(combatant, target, **kwargs)[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.
-
add_combatant
(combatant)[source]¶ Add a new combatant to the battle. Can be called multiple times safely.
- Parameters
combatant (EvAdventureCharacter, EvAdventureNPC) – Any number of combatants to add to the combat.
- Returns
bool – If this combatant was newly added or not (it was already in combat).
-
remove_combatant
(combatant)[source]¶ Remove a combatant from the battle. This removes their queue.
- Parameters
combatant (EvAdventureCharacter, EvAdventureNPC) – A combatant to add to the combat.
-
start_combat
(**kwargs)[source]¶ This actually starts the combat. It’s safe to run this multiple times since it will only start combat if it isn’t already running.
-
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).
-
queue_action
(combatant, action_dict)[source]¶ Queue an action by adding the new actiondict.
- Parameters
combatant (EvAdventureCharacter, EvAdventureNPC) – A combatant queueing the action.
action_dict (dict) – A dict describing the action class by name along with properties.
-
get_next_action_dict
(combatant)[source]¶ Give the action_dict for the next action that will be executed.
- Parameters
combatant (EvAdventureCharacter, EvAdventureNPC) – The combatant to get the action for.
- Returns
dict – The next action-dict in the queue.
-
execute_next_action
(combatant)[source]¶ Perform a combatant’s next queued action. Note that there is _always_ an action queued, even if this action is ‘hold’, which means the combatant will do nothing.
- Parameters
combatant (EvAdventureCharacter, EvAdventureNPC) – The combatant performing and action.
-
at_repeat
()[source]¶ This method is called every time Script repeats (every interval seconds). Performs a full turn of combat, performing everyone’s actions in random order.
-
exception
DoesNotExist
¶ Bases:
evennia.contrib.tutorials.evadventure.combat_base.EvAdventureCombatBaseHandler.DoesNotExist
-
exception
MultipleObjectsReturned
¶
-
path
= 'evennia.contrib.tutorials.evadventure.combat_turnbased.EvAdventureTurnbasedCombatHandler'¶
-
typename
= 'EvAdventureTurnbasedCombatHandler'¶
-
-
evennia.contrib.tutorials.evadventure.combat_turnbased.
node_choose_enemy_target
(caller, raw_string, **kwargs)[source]¶ Choose an enemy as a target for an action
-
evennia.contrib.tutorials.evadventure.combat_turnbased.
node_choose_enemy_recipient
(caller, raw_string, **kwargs)[source]¶ Choose an enemy as a ‘recipient’ for an action.
-
evennia.contrib.tutorials.evadventure.combat_turnbased.
node_choose_allied_target
(caller, raw_string, **kwargs)[source]¶ Choose an enemy as a target for an action
-
evennia.contrib.tutorials.evadventure.combat_turnbased.
node_choose_allied_recipient
(caller, raw_string, **kwargs)[source]¶ Choose an allied recipient for an action
-
evennia.contrib.tutorials.evadventure.combat_turnbased.
node_choose_ability
(caller, raw_string, **kwargs)[source]¶ Select an ability to use/boost etc.
-
evennia.contrib.tutorials.evadventure.combat_turnbased.
node_choose_use_item
(caller, raw_string, **kwargs)[source]¶ Choose item to use.
-
evennia.contrib.tutorials.evadventure.combat_turnbased.
node_choose_wield_item
(caller, raw_string, **kwargs)[source]¶ Choose item to use.
-
evennia.contrib.tutorials.evadventure.combat_turnbased.
node_combat
(caller, raw_string, **kwargs)[source]¶ Base combat menu
-
class
evennia.contrib.tutorials.evadventure.combat_turnbased.
CmdTurnAttack
(**kwargs)[source]¶ Bases:
evennia.commands.command.Command
Start or join combat.
- Usage:
attack [<target>]
-
key
= 'attack'¶
-
aliases
= ['turnbased combat', 'hit']¶
-
turn_timeout
= 30¶
-
flee_time
= 3¶
-
parse
()[source]¶ Once the cmdhandler has identified this as the command we want, this function is run. If many of your commands have a similar syntax (for example ‘cmd arg1 = arg2’) you should simply define this once and just let other commands of the same form inherit from this. See the docstring of this module for which object properties are available to use (notably self.args).
-
func
()[source]¶ This is the actual executing part of the command. It is called directly after self.parse(). See the docstring of this module for which object properties are available (beyond those set in self.parse())
-
help_category
= 'general'¶
-
lock_storage
= 'cmd:all();'¶
-
search_index_entry
= {'aliases': 'turnbased combat hit', 'category': 'general', 'key': 'attack', 'no_prefix': ' turnbased combat hit', 'tags': '', 'text': '\n Start or join combat.\n\n Usage:\n attack [<target>]\n\n '}¶
-
class
evennia.contrib.tutorials.evadventure.combat_turnbased.
TurnCombatCmdSet
(cmdsetobj=None, key=None)[source]¶ Bases:
evennia.commands.cmdset.CmdSet
CmdSet for the turn-based combat.
-
at_cmdset_creation
()[source]¶ Hook method - this should be overloaded in the inheriting class, and should take care of populating the cmdset by use of self.add().
-
path
= 'evennia.contrib.tutorials.evadventure.combat_turnbased.TurnCombatCmdSet'¶
-