evennia.contrib.game_systems.achievements.achievements

Achievements

This provides a system for adding and tracking player achievements in your game.

Achievements are defined as dicts, loosely similar to the prototypes system.

An example of an achievement dict:

ACHIEVE_DIRE_RATS = {

“name”: “Once More, But Bigger”, “desc”: “Somehow, normal rats just aren’t enough any more.”, “category”: “defeat”, “tracking”: “dire rat”, “count”: 10, “prereqs”: “ACHIEVE_TEN_RATS”,

}

The recognized fields for an achievement are:

  • key (str): The unique, case-insensitive key identifying this achievement. The variable name is

    used by default.

  • name (str): The name of the achievement. This is not the key and does not need to be unique.

  • desc (str): The longer description of the achievement. Common uses for this would be flavor text

    or hints on how to complete it.

  • category (str): The category of conditions which this achievement tracks. It will most likely be

    an action and you will most likely specify it based on where you’re checking from. e.g. killing 10 rats might have a category of “defeat”, which you’d then check from your code that runs when a player defeats something.

  • tracking (str or list): The specific condition this achievement tracks. e.g. for the above example of

    10 rats, the tracking field would be “rat”.

  • tracking_type: The options here are “sum” and “separate”. “sum” means that matching any tracked

    item will increase the total. “separate” means all tracked items are counted individually. This is only useful when tracking is a list. The default is “sum”.

  • count (int): The total tallies the tracked item needs for this to be completed. e.g. for the rats

    example, it would be 10. The default is 1

  • prereqs (str or list): An optional achievement key or list of keys that must be completed before

    this achievement is available.

To add achievement tracking, put track_achievements in your relevant hooks.

Example

def at_defeated(self, victor):

# called when this object is defeated in combat # we’ll use the “mob_type” tag category as the tracked information for achievements mob_type = self.tags.get(category=”mob_type”) track_achievements(victor, category=”defeated”, tracking=mob_type, count=1)

evennia.contrib.game_systems.achievements.achievements.track_achievements(achiever, category=None, tracking=None, count=1, **kwargs)[source]

Update and check achievement progress.

Parameters

achiever (Account or Character) – The entity that’s collecting achievement progress.

Keyword Arguments
  • category (str or None) – The category of an achievement.

  • tracking (str or None) – The specific item being tracked in the achievement.

Returns

tuple – The keys of any achievements that were completed by this update.

evennia.contrib.game_systems.achievements.achievements.get_achievement(key)[source]

Get an achievement by its key.

Parameters

key (str) – The achievement key. This is the variable name the achievement dict is assigned to.

Returns

dict or None – The achievement data, or None if it doesn’t exist

evennia.contrib.game_systems.achievements.achievements.all_achievements()[source]

Returns a dict of all achievements in the game.

Returns

dict

evennia.contrib.game_systems.achievements.achievements.get_achievement_progress(achiever, key)[source]

Retrieve the progress data on a particular achievement for a particular achiever.

Parameters
  • achiever (Account or Character) – The entity tracking achievement progress.

  • key (str) – The achievement key

Returns

dict – The progress data

evennia.contrib.game_systems.achievements.achievements.search_achievement(search_term)[source]

Search for an achievement containing the search term. If no matches are found in the achievement names, it searches in the achievement descriptions.

Parameters

search_term (str) – The string to search for.

Returns

dict – A dict of key:data pairs of matching achievements.

class evennia.contrib.game_systems.achievements.achievements.CmdAchieve(**kwargs)[source]

Bases: evennia.commands.default.muxcommand.MuxCommand

view achievements

Usage:

achievements[/switches] [args]

Switches:

all View all achievements, including locked ones. completed View achievements you’ve completed. progress View achievements you have partially completed

Check your achievement statuses or browse the list. Providing a command argument will search all your currently unlocked achievements for matches, and the switches will filter the list to something other than “all unlocked”. Combining a command argument with a switch will search only in that list.

Examples

achievements apples achievements/all achievements/progress rats

key = 'achievements'
aliases = ['achieves', 'achievement', 'achieve']
switch_options = ('progress', 'completed', 'done', 'all')
template = '|w{name}|n\n{desc}\n{status}'
format_achievement(achievement_data)[source]

Formats the raw achievement data for display.

Parameters

achievement_data (dict) – The data to format.

Returns

str: The display string to be sent to the caller.

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.

help_category = 'general'
lock_storage = 'cmd:all();'
search_index_entry = {'aliases': 'achieves achievement achieve', 'category': 'general', 'key': 'achievements', 'no_prefix': ' achieves achievement achieve', 'tags': '', 'text': '\n view achievements\n\n Usage:\n achievements[/switches] [args]\n\n Switches:\n all View all achievements, including locked ones.\n completed View achievements you\'ve completed.\n progress View achievements you have partially completed\n\n Check your achievement statuses or browse the list. Providing a command argument\n will search all your currently unlocked achievements for matches, and the switches\n will filter the list to something other than "all unlocked". Combining a command\n argument with a switch will search only in that list.\n\n Examples:\n achievements apples\n achievements/all\n achievements/progress rats\n '}