evennia.contrib.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.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.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.clothing.Clothing @set shirt/clothing_type = ‘top’ wear shirt

evennia.contrib.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.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.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.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.clothing.Clothing(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.

exception DoesNotExist

Bases: evennia.objects.objects.DefaultObject.DoesNotExist

exception MultipleObjectsReturned

Bases: evennia.objects.objects.DefaultObject.MultipleObjectsReturned

path = 'evennia.contrib.clothing.Clothing'
typename = 'Clothing'
class evennia.contrib.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.

return_appearance(looker)[source]

This formats a description. It is the hook a ‘look’ command should call.

Parameters

looker (Object) – Object doing the looking.

Notes

The name of every clothing item carried and worn by the character is appended to their description. If the clothing’s db.worn value is set to True, only the name is appended, but if the value is a string, the string is appended to the end of the name, to allow characters to specify how clothing is worn.

exception DoesNotExist

Bases: evennia.objects.objects.DefaultCharacter.DoesNotExist

exception MultipleObjectsReturned

Bases: evennia.objects.objects.DefaultCharacter.MultipleObjectsReturned

path = 'evennia.contrib.clothing.ClothedCharacter'
typename = 'ClothedCharacter'
class evennia.contrib.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 shirt wear scarf wrapped loosely about the shoulders

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 performs the actual command.

aliases = []
lock_storage = 'cmd:all();'
class evennia.contrib.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 performs the actual command.

aliases = []
lock_storage = 'cmd:all();'
class evennia.contrib.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 <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'
func()[source]

This performs the actual command.

aliases = []
lock_storage = 'cmd:all();'
class evennia.contrib.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'
func()[source]

This performs the actual command.

aliases = []
lock_storage = 'cmd:all();'
class evennia.contrib.clothing.CmdDrop(**kwargs)[source]

Bases: evennia.commands.default.muxcommand.MuxCommand

drop something

Usage:

drop <obj>

Lets you drop an object from your inventory into the location you are currently in.

key = 'drop'
locks = 'cmd:all()'
arg_regex = re.compile('\\s|$', re.IGNORECASE)
func()[source]

Implement command

aliases = []
help_category = 'general'
lock_storage = 'cmd:all()'
class evennia.contrib.clothing.CmdGive(**kwargs)[source]

Bases: evennia.commands.default.muxcommand.MuxCommand

give away something to someone

Usage:

give <inventory obj> = <target>

Gives an items from your inventory to another character, placing it in their inventory.

key = 'give'
locks = 'cmd:all()'
arg_regex = re.compile('\\s|$', re.IGNORECASE)
func()[source]

Implement give

aliases = []
help_category = 'general'
lock_storage = 'cmd:all()'
class evennia.contrib.clothing.CmdInventory(**kwargs)[source]

Bases: evennia.commands.default.muxcommand.MuxCommand

view inventory

Usage:

inventory inv

Shows your inventory.

key = 'inventory'
aliases = ['i', 'inv']
locks = 'cmd:all()'
arg_regex = re.compile('$', re.IGNORECASE)
func()[source]

check inventory

help_category = 'general'
lock_storage = 'cmd:all()'
class evennia.contrib.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'
at_cmdset_creation()[source]

Populates the cmdset

path = 'evennia.contrib.clothing.ClothedCharacterCmdSet'