From 8fbf63c8248e18576464d265e00178eea9f6a4ef Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Wed, 25 Dec 2019 22:13:16 +0000 Subject: [PATCH] Relocate choose_name menu functions Move the action and create logic for the choose_name state from their respective facets to the menu module, hiding them behind consistently-named entry points. --- mudpy/menu.py | 42 ++++++++++++++++++++++++++++++++++++++++++ share/menu.yaml | 17 ++++++++--------- 2 files changed, 50 insertions(+), 9 deletions(-) diff --git a/mudpy/menu.py b/mudpy/menu.py index b385198..75dc542 100644 --- a/mudpy/menu.py +++ b/mudpy/menu.py @@ -4,6 +4,8 @@ # modify, and distribute this software is granted under terms # provided in the LICENSE file distributed with this software. +import mudpy + def activate_avatar_action(user): """Activate the selected avatar in the activate_avatar state.""" @@ -34,3 +36,43 @@ def checking_new_account_name_action_g(user): def choose_gender_action(user): """Set the avatar's gender to the selected value.""" return user.avatar.set("gender", user.menu_choices[user.choice]) + + +def choose_name_action(user): + """Set the avatar's name to the selected value.""" + return user.avatar.set("name", user.menu_choices[user.choice]) + + +def choose_name_create_1(user): + """Provide a randomly-generated name as choice 1.""" + return mudpy.misc.random_name() + + +def choose_name_create_2(user): + """Provide a randomly-generated name as choice 2.""" + return mudpy.misc.random_name() + + +def choose_name_create_3(user): + """Provide a randomly-generated name as choice 3.""" + return mudpy.misc.random_name() + + +def choose_name_create_4(user): + """Provide a randomly-generated name as choice 4.""" + return mudpy.misc.random_name() + + +def choose_name_create_5(user): + """Provide a randomly-generated name as choice 5.""" + return mudpy.misc.random_name() + + +def choose_name_create_6(user): + """Provide a randomly-generated name as choice 6.""" + return mudpy.misc.random_name() + + +def choose_name_create_7(user): + """Provide a randomly-generated name as choice 7.""" + return mudpy.misc.random_name() diff --git a/share/menu.yaml b/share/menu.yaml index 37edaf0..87176eb 100644 --- a/share/menu.yaml +++ b/share/menu.yaml @@ -48,18 +48,17 @@ menu.choose_gender.description: First, your new avatar needs a birth gender. Avatars are one of male or female at birth. menu.choose_gender.prompt: "Pick a birth gender for your new avatar:" -menu.choose_name.action: user.avatar.set("name", - user.menu_choices[user.choice]) +menu.choose_name.action: mudpy.menu.choose_name_action(user) menu.choose_name.branch: main_utility menu.choose_name.branch_g: choose_name menu.choose_name.choice_g: generate more names -menu.choose_name.create_1: random_name() -menu.choose_name.create_2: random_name() -menu.choose_name.create_3: random_name() -menu.choose_name.create_4: random_name() -menu.choose_name.create_5: random_name() -menu.choose_name.create_6: random_name() -menu.choose_name.create_7: random_name() +menu.choose_name.create_1: mudpy.menu.choose_name_create_1(user) +menu.choose_name.create_2: mudpy.menu.choose_name_create_2(user) +menu.choose_name.create_3: mudpy.menu.choose_name_create_3(user) +menu.choose_name.create_4: mudpy.menu.choose_name_create_4(user) +menu.choose_name.create_5: mudpy.menu.choose_name_create_5(user) +menu.choose_name.create_6: mudpy.menu.choose_name_create_6(user) +menu.choose_name.create_7: mudpy.menu.choose_name_create_7(user) menu.choose_name.default: g menu.choose_name.description: Your new avatar needs a name. This will be the name with which $(tpsp) grew up, and will initially be the name by which -- 2.11.0