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)[源代码]

基类:evennia.contrib.tutorials.evadventure.combat_base.CombatAction

Start (or continue) fleeing/disengaging from combat.

action_dict = {

“key”: “flee”,

}

注解

Refer to as ‘flee’.

execute()[源代码]

Perform the action as the combatant. Should normally make use of the properties stored on the class during initialization.

class evennia.contrib.tutorials.evadventure.combat_turnbased.EvAdventureTurnbasedCombatHandler(*args, **kwargs)[源代码]

基类: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)[源代码]

Let a benefiter gain advantage against the target.

参数
  • 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)[源代码]

Let an affected party gain disadvantage against a target.

参数
  • 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)[源代码]

Check if a given combatant has advantage against a target.

参数
  • 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)[源代码]

Check if a given combatant has disadvantage against a target.

参数
  • 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)[源代码]

Add a new combatant to the battle. Can be called multiple times safely.

参数

combatant (EvAdventureCharacter, EvAdventureNPC) – Any number of combatants to add to the combat.

返回

bool – If this combatant was newly added or not (it was already in combat).

remove_combatant(combatant)[源代码]

Remove a combatant from the battle. This removes their queue.

参数

combatant (EvAdventureCharacter, EvAdventureNPC) – A combatant to add to the combat.

start_combat(**kwargs)[源代码]

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.

stop_combat()[源代码]

Stop the combat immediately.

get_combat_summary(combatant)[源代码]

Add your next queued action to summary

get_sides(combatant)[源代码]

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.

参数

combatant (Character or NPC) – The one whose sides are to determined.

返回

tuple – A tuple of lists (allies, enemies), from the perspective of combatant.

注解

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)[源代码]

Queue an action by adding the new actiondict.

参数
  • 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)[源代码]

Give the action_dict for the next action that will be executed.

参数

combatant (EvAdventureCharacter, EvAdventureNPC) – The combatant to get the action for.

返回

dict – The next action-dict in the queue.

execute_next_action(combatant)[源代码]

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.

参数

combatant (EvAdventureCharacter, EvAdventureNPC) – The combatant performing and action.

check_stop_combat()[源代码]

Check if it’s time to stop combat

at_repeat()[源代码]

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

基类:evennia.contrib.tutorials.evadventure.combat_base.EvAdventureCombatBaseHandler.DoesNotExist

exception MultipleObjectsReturned

基类:evennia.contrib.tutorials.evadventure.combat_base.EvAdventureCombatBaseHandler.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)[源代码]

Choose an enemy as a target for an action

evennia.contrib.tutorials.evadventure.combat_turnbased.node_choose_enemy_recipient(caller, raw_string, **kwargs)[源代码]

Choose an enemy as a ‘recipient’ for an action.

evennia.contrib.tutorials.evadventure.combat_turnbased.node_choose_allied_target(caller, raw_string, **kwargs)[源代码]

Choose an enemy as a target for an action

evennia.contrib.tutorials.evadventure.combat_turnbased.node_choose_allied_recipient(caller, raw_string, **kwargs)[源代码]

Choose an allied recipient for an action

evennia.contrib.tutorials.evadventure.combat_turnbased.node_choose_ability(caller, raw_string, **kwargs)[源代码]

Select an ability to use/boost etc.

evennia.contrib.tutorials.evadventure.combat_turnbased.node_choose_use_item(caller, raw_string, **kwargs)[源代码]

Choose item to use.

evennia.contrib.tutorials.evadventure.combat_turnbased.node_choose_wield_item(caller, raw_string, **kwargs)[源代码]

Choose item to use.

evennia.contrib.tutorials.evadventure.combat_turnbased.node_combat(caller, raw_string, **kwargs)[源代码]

Base combat menu

class evennia.contrib.tutorials.evadventure.combat_turnbased.CmdTurnAttack(**kwargs)[源代码]

基类:evennia.commands.command.Command

Start or join combat.

Usage:

attack [<target>]

key = 'attack'
aliases = ['turnbased combat', 'hit']
turn_timeout = 30
flee_time = 3
parse()[源代码]

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()[源代码]

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)[源代码]

基类:evennia.commands.cmdset.CmdSet

CmdSet for the turn-based combat.

key = 'turncombat_cmdset'
at_cmdset_creation()[源代码]

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'