1 """Utility functions for menu operation."""
3 # Copyright (c) 2019 mudpy authors. Permission to use, copy,
4 # modify, and distribute this software is granted under terms
5 # provided in the LICENSE file distributed with this software.
10 def activate_avatar_action(user):
11 """Activate the selected avatar in the activate_avatar state."""
12 return user.activate_avatar_by_index(int(user.choice) - 1)
15 def activate_avatar_action_a(user):
16 """Abort selection by doing nothing."""
20 def activate_avatar_create(user):
21 """List available avatars as choices for the activate_avatar state."""
23 [(str(x + 1), y) for x, y in enumerate(user.list_avatar_names())])
26 def checking_new_account_name_action_d(user):
27 """Destroy the new account because the user asked to disconnect."""
28 return user.account.destroy()
31 def checking_new_account_name_action_g(user):
32 """Destroy the new account, the user asked to go back to name entry."""
33 return user.account.destroy()
36 def choose_gender_action(user):
37 """Set the avatar's gender to the selected value."""
38 return user.avatar.set("gender", user.menu_choices[user.choice])
41 def choose_name_action(user):
42 """Set the avatar's name to the selected value."""
43 return user.avatar.set("name", user.menu_choices[user.choice])
46 def choose_name_create_1(user):
47 """Provide a randomly-generated name as choice 1."""
48 return mudpy.misc.random_name()
51 def choose_name_create_2(user):
52 """Provide a randomly-generated name as choice 2."""
53 return mudpy.misc.random_name()
56 def choose_name_create_3(user):
57 """Provide a randomly-generated name as choice 3."""
58 return mudpy.misc.random_name()
61 def choose_name_create_4(user):
62 """Provide a randomly-generated name as choice 4."""
63 return mudpy.misc.random_name()
66 def choose_name_create_5(user):
67 """Provide a randomly-generated name as choice 5."""
68 return mudpy.misc.random_name()
71 def choose_name_create_6(user):
72 """Provide a randomly-generated name as choice 6."""
73 return mudpy.misc.random_name()
76 def choose_name_create_7(user):
77 """Provide a randomly-generated name as choice 7."""
78 return mudpy.misc.random_name()
81 def delete_account_action_y(user):
82 """Permanently delete the account and all avatars, as requested."""
86 def delete_avatar_action(user):
87 """Delete the selected avatar."""
88 return user.delete_avatar(
89 user.account.get("avatars")[int(user.choice) - 1])
92 def delete_avatar_action_a(user):
93 """Abort avatar deletion."""
97 def delete_avatar_create(user):
98 """List available avatars for possible deletion."""
100 [(str(x + 1), y) for x, y in enumerate(user.list_avatar_names())])
103 def main_utility_action_c(user):
104 """Create a new avatar."""
105 return user.new_avatar()
108 def main_utility_demand_a(user):
109 """Only include avatar activation if the account has avatars."""
110 return user.account.get("avatars")
113 def main_utility_demand_c(user):
114 """Only include avatar creation if avatar count is below the limit."""
115 return (len(user.account.get("avatars")) <
116 mudpy.misc.universe.contents["mudpy.limit"].get("avatars"))
119 def main_utility_demand_d(user):
120 """Only include avatar deletion if the account has avatars."""
121 return user.account.get("avatars")