evennia.contrib.game_systems.clothing.clothing¶
Clothing - Provides a typeclass and commands for wearable clothing, which is appended to a character’s description when worn.
Evennia contribution - Tim Ashley Jenkins 2017
Clothing items, when worn, are added to the character’s description in a list. For example, if wearing the following clothing items:
a thin and delicate necklace a pair of regular ol’ shoes one nice hat a very pretty dress
A character’s description may look like this:
Superuser(#1) This is User #1.
Superuser is wearing one nice hat, a thin and delicate necklace, a very pretty dress and a pair of regular ol’ shoes.
Characters can also specify the style of wear for their clothing - I.E. to wear a scarf ‘tied into a tight knot around the neck’ or ‘draped loosely across the shoulders’ - to add an easy avenue of customization. For example, after entering:
wear scarf draped loosely across the shoulders
The garment appears like so in the description:
Superuser(#1) This is User #1.
Superuser is wearing a fanciful-looking scarf draped loosely across the shoulders.
Items of clothing can be used to cover other items, and many options are provided to define your own clothing types and their limits and behaviors. For example, to have undergarments automatically covered by outerwear, or to put a limit on the number of each type of item that can be worn. The system as-is is fairly freeform - you can cover any garment with almost any other, for example - but it can easily be made more restrictive, and can even be tied into a system for armor or other equipment.
To install, import this module and have your default character inherit from ClothedCharacter in your game’s characters.py file:
from evennia.contrib.game_systems.clothing import ClothedCharacter
class Character(ClothedCharacter):
And then add ClothedCharacterCmdSet in your character set in your game’s commands/default_cmdsets.py:
from evennia.contrib.game_systems.clothing import ClothedCharacterCmdSet
- class CharacterCmdSet(default_cmds.CharacterCmdSet):
… at_cmdset_creation(self):
super().at_cmdset_creation() … self.add(ClothedCharacterCmdSet) # <– add this
From here, you can use the default builder commands to create clothes with which to test the system:
@create a pretty shirt : evennia.contrib.game_systems.clothing.ContribClothing @set shirt/clothing_type = ‘top’ wear shirt
-
evennia.contrib.game_systems.clothing.clothing.
order_clothes_list
(clothes_list)[source]¶ Orders a given clothes list by the order specified in CLOTHING_TYPE_ORDER.
- Parameters
clothes_list (list) – List of clothing items to put in order
- Returns
ordered_clothes_list (list) –
- The same list as passed, but re-ordered
according to the hierarchy of clothing types specified in CLOTHING_TYPE_ORDER.
-
evennia.contrib.game_systems.clothing.clothing.
get_worn_clothes
(character, exclude_covered=False)[source]¶ Get a list of clothes worn by a given character.
- Parameters
character (obj) – The character to get a list of worn clothes from.
- Keyword Arguments
exclude_covered (bool) – If True, excludes clothes covered by other clothing from the returned list.
- Returns
ordered_clothes_list (list) –
- A list of clothing items worn by the
given character, ordered according to the CLOTHING_TYPE_ORDER option specified in this module.
-
evennia.contrib.game_systems.clothing.clothing.
clothing_type_count
(clothes_list)[source]¶ Returns a dictionary of the number of each clothing type in a given list of clothing objects.
- Parameters
clothes_list (list) – A list of clothing items from which to count the number of clothing types represented among them.
- Returns
types_count (dict) –
- A dictionary of clothing types represented
in the given list and the number of each clothing type represented.
-
evennia.contrib.game_systems.clothing.clothing.
single_type_count
(clothes_list, type)[source]¶ Returns an integer value of the number of a given type of clothing in a list.
- Parameters
clothes_list (list) – List of clothing objects to count from
type (str) – Clothing type to count
- Returns
type_count (int) –
- Number of garments of the specified type in the given
list of clothing objects
-
class
evennia.contrib.game_systems.clothing.clothing.
ContribClothing
(id, db_key, db_typeclass_path, db_date_created, db_lock_storage, db_account, db_sessid, db_location, db_home, db_destination, db_cmdset_storage)[source]¶ Bases:
evennia.objects.objects.DefaultObject
-
wear
(wearer, wearstyle, quiet=False)[source]¶ Sets clothes to ‘worn’ and optionally echoes to the room.
- Parameters
wearer (obj) – character object wearing this clothing object
wearstyle (True or str) – string describing the style of wear or True for none
- Keyword Arguments
quiet (bool) – If false, does not message the room
Notes
Optionally sets db.worn with a ‘wearstyle’ that appends a short passage to the end of the name of the clothing to describe how it’s worn that shows up in the wearer’s desc - I.E. ‘around his neck’ or ‘tied loosely around her waist’. If db.worn is set to ‘True’ then just the name will be shown.
-
remove
(wearer, quiet=False)[source]¶ Removes worn clothes and optionally echoes to the room.
- Parameters
wearer (obj) – character object wearing this clothing object
- Keyword Arguments
quiet (bool) – If false, does not message the room
-
at_get
(getter)[source]¶ Makes absolutely sure clothes aren’t already set as ‘worn’ when they’re picked up, in case they’ve somehow had their location changed without getting removed.
-
at_pre_move
(destination, **kwargs)[source]¶ Called just before starting to move this object to destination. Return False to abort move.
Notes
If this method returns False/None, the move is cancelled before it is even started.
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶ Bases:
evennia.objects.objects.DefaultObject.MultipleObjectsReturned
-
path
= 'evennia.contrib.game_systems.clothing.clothing.ContribClothing'¶
-
typename
= 'ContribClothing'¶
-
-
class
evennia.contrib.game_systems.clothing.clothing.
ClothedCharacter
(*args, **kwargs)[source]¶ Bases:
evennia.objects.objects.DefaultCharacter
Character that displays worn clothing when looked at. You can also just copy the return_appearance hook defined below to your own game’s character typeclass.
-
get_display_desc
(looker, **kwargs)[source]¶ Get the ‘desc’ component of the object description. Called by return_appearance.
- Parameters
looker (Object) – Object doing the looking.
**kwargs – Arbitrary data for use when overriding.
- Returns
str – The desc display string.
-
get_display_things
(looker, **kwargs)[source]¶ Get the ‘things’ component of the object’s contents. Called by return_appearance.
- Parameters
looker (Object) – Object doing the looking.
**kwargs – Arbitrary data for use when overriding.
- Returns
str – A string describing the things in object.
-
exception
DoesNotExist
¶ Bases:
evennia.objects.objects.DefaultCharacter.DoesNotExist
-
exception
MultipleObjectsReturned
¶ Bases:
evennia.objects.objects.DefaultCharacter.MultipleObjectsReturned
-
path
= 'evennia.contrib.game_systems.clothing.clothing.ClothedCharacter'¶
-
typename
= 'ClothedCharacter'¶
-
-
class
evennia.contrib.game_systems.clothing.clothing.
CmdWear
(**kwargs)[source]¶ Bases:
evennia.commands.default.muxcommand.MuxCommand
Puts on an item of clothing you are holding.
- Usage:
wear <obj> [=] [wear style]
Examples
wear red shirt wear scarf wrapped loosely about the shoulders wear blue hat = at a jaunty angle
All the clothes you are wearing are appended to your description. If you provide a ‘wear style’ after the command, the message you provide will be displayed after the clothing’s name.
-
key
= 'wear'¶
-
help_category
= 'clothing'¶
-
func
()[source]¶ This is the hook function that actually does all the work. It is called by the cmdhandler right after self.parser() finishes, and so has access to all the variables defined therein.
-
aliases
= []¶
-
lock_storage
= 'cmd:all();'¶
-
search_index_entry
= {'aliases': '', 'category': 'clothing', 'key': 'wear', 'no_prefix': ' ', 'tags': '', 'text': "\n Puts on an item of clothing you are holding.\n\n Usage:\n wear <obj> [=] [wear style]\n\n Examples:\n wear red shirt\n wear scarf wrapped loosely about the shoulders\n wear blue hat = at a jaunty angle\n\n All the clothes you are wearing are appended to your description.\n If you provide a 'wear style' after the command, the message you\n provide will be displayed after the clothing's name.\n "}¶
-
class
evennia.contrib.game_systems.clothing.clothing.
CmdRemove
(**kwargs)[source]¶ Bases:
evennia.commands.default.muxcommand.MuxCommand
Takes off an item of clothing.
- Usage:
remove <obj>
Removes an item of clothing you are wearing. You can’t remove clothes that are covered up by something else - you must take off the covering item first.
-
key
= 'remove'¶
-
help_category
= 'clothing'¶
-
func
()[source]¶ This is the hook function that actually does all the work. It is called by the cmdhandler right after self.parser() finishes, and so has access to all the variables defined therein.
-
aliases
= []¶
-
lock_storage
= 'cmd:all();'¶
-
search_index_entry
= {'aliases': '', 'category': 'clothing', 'key': 'remove', 'no_prefix': ' ', 'tags': '', 'text': "\n Takes off an item of clothing.\n\n Usage:\n remove <obj>\n\n Removes an item of clothing you are wearing. You can't remove\n clothes that are covered up by something else - you must take\n off the covering item first.\n "}¶
-
class
evennia.contrib.game_systems.clothing.clothing.
CmdCover
(**kwargs)[source]¶ Bases:
evennia.commands.default.muxcommand.MuxCommand
Covers a worn item of clothing with another you’re holding or wearing.
- Usage:
cover <worn obj> with <obj>
When you cover a clothing item, it is hidden and no longer appears in your description until it’s uncovered or the item covering it is removed. You can’t remove an item of clothing if it’s covered.
-
key
= 'cover'¶
-
help_category
= 'clothing'¶
-
rhs_split
= (' with ', '=')¶
-
func
()[source]¶ This is the hook function that actually does all the work. It is called by the cmdhandler right after self.parser() finishes, and so has access to all the variables defined therein.
-
aliases
= []¶
-
lock_storage
= 'cmd:all();'¶
-
search_index_entry
= {'aliases': '', 'category': 'clothing', 'key': 'cover', 'no_prefix': ' ', 'tags': '', 'text': "\n Covers a worn item of clothing with another you're holding or wearing.\n\n Usage:\n cover <worn obj> with <obj>\n\n When you cover a clothing item, it is hidden and no longer appears in\n your description until it's uncovered or the item covering it is removed.\n You can't remove an item of clothing if it's covered.\n "}¶
-
class
evennia.contrib.game_systems.clothing.clothing.
CmdUncover
(**kwargs)[source]¶ Bases:
evennia.commands.default.muxcommand.MuxCommand
Reveals a worn item of clothing that’s currently covered up.
- Usage:
uncover <obj>
When you uncover an item of clothing, you allow it to appear in your description without having to take off the garment that’s currently covering it. You can’t uncover an item of clothing if the item covering it is also covered by something else.
-
key
= 'uncover'¶
-
help_category
= 'clothing'¶
-
aliases
= []¶
-
lock_storage
= 'cmd:all();'¶
-
search_index_entry
= {'aliases': '', 'category': 'clothing', 'key': 'uncover', 'no_prefix': ' ', 'tags': '', 'text': "\n Reveals a worn item of clothing that's currently covered up.\n\n Usage:\n uncover <obj>\n\n When you uncover an item of clothing, you allow it to appear in your\n description without having to take off the garment that's currently\n covering it. You can't uncover an item of clothing if the item covering\n it is also covered by something else.\n "}¶
-
class
evennia.contrib.game_systems.clothing.clothing.
CmdInventory
(**kwargs)[source]¶ Bases:
evennia.commands.default.muxcommand.MuxCommand
view inventory
- Usage:
inventory inv
Shows your inventory.
-
key
= 'inventory'¶
-
aliases
= ['inv', 'i']¶
-
locks
= 'cmd:all()'¶
-
arg_regex
= re.compile('$', re.IGNORECASE)¶
-
help_category
= 'general'¶
-
lock_storage
= 'cmd:all()'¶
-
search_index_entry
= {'aliases': 'inv i', 'category': 'general', 'key': 'inventory', 'no_prefix': ' inv i', 'tags': '', 'text': '\n view inventory\n\n Usage:\n inventory\n inv\n\n Shows your inventory.\n '}¶
-
class
evennia.contrib.game_systems.clothing.clothing.
ClothedCharacterCmdSet
(cmdsetobj=None, key=None)[source]¶ Bases:
evennia.commands.default.cmdset_character.CharacterCmdSet
Command set for clothing, including new versions of ‘give’ and ‘drop’ that take worn and covered clothing into account, as well as a new version of ‘inventory’ that differentiates between carried and worn items.
-
key
= 'DefaultCharacter'¶
-
path
= 'evennia.contrib.game_systems.clothing.clothing.ClothedCharacterCmdSet'¶
-