From: Jeremy Stanley Date: Wed, 25 Dec 2019 20:02:41 +0000 (+0000) Subject: Relocate activate_avatar menu functions X-Git-Tag: 0.1.0~14 X-Git-Url: https://mudpy.org/gitweb?a=commitdiff_plain;h=1e22e0aca6b5804bfcde8eccaafabd46aab8a146;p=mudpy.git Relocate activate_avatar menu functions Move the action and create logic for the activate_avatar state from their respective facets to the menu module, hiding them behind consistently-named entry points. --- diff --git a/mudpy/menu.py b/mudpy/menu.py index a1d18f7..1bdccb0 100644 --- a/mudpy/menu.py +++ b/mudpy/menu.py @@ -3,3 +3,19 @@ # Copyright (c) 2019 mudpy authors. Permission to use, copy, # modify, and distribute this software is granted under terms # provided in the LICENSE file distributed with this software. + + +def activate_avatar_action(user): + """Activate the selected avatar in the activate_avatar state.""" + return user.activate_avatar_by_index(int(user.choice) - 1) + + +def activate_avatar_action_a(user): + """Abort selection by doing nothing.""" + return True + + +def activate_avatar_create(user): + """List available avatars as choices for the activate_avatar state.""" + return dict( + [(str(x + 1), y) for x, y in enumerate(user.list_avatar_names())]) diff --git a/share/menu.yaml b/share/menu.yaml index 3350e8f..fd8199c 100644 --- a/share/menu.yaml +++ b/share/menu.yaml @@ -7,12 +7,11 @@ _desc: This is the standard library of menu definitions. _lock: true -menu.activate_avatar.action: user.activate_avatar_by_index(int(user.choice)-1) -menu.activate_avatar.action_a: pass +menu.activate_avatar.action: mudpy.menu.activate_avatar_action(user) +menu.activate_avatar.action_a: mudpy.menu.activate_avatar_action_a(user) menu.activate_avatar.branch_a: main_utility menu.activate_avatar.choice_a: abort selection -menu.activate_avatar.create: dict([(str(x+1),y) for x,y in - enumerate(user.list_avatar_names())]) +menu.activate_avatar.create: mudpy.menu.activate_avatar_create(user) menu.activate_avatar.default: "1" menu.activate_avatar.description: This is the list of avatars available for you to awaken.