f16a2b409302d1fe9e4cd84a511ae3489427de9e
[mudpy.git] / mudpy / menu.py
1 """Utility functions for menu operation."""
2
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.
6
7 import mudpy
8
9
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)
13
14
15 def activate_avatar_action_a(user):
16     """Abort selection by doing nothing."""
17     return True
18
19
20 def activate_avatar_create(user):
21     """List available avatars as choices for the activate_avatar state."""
22     return dict(
23         [(str(x + 1), y) for x, y in enumerate(user.list_avatar_names())])
24
25
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()
29
30
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()
34
35
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])
39
40
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])
44
45
46 def choose_name_create_1(user):
47     """Provide a randomly-generated name as choice 1."""
48     return mudpy.misc.random_name()
49
50
51 def choose_name_create_2(user):
52     """Provide a randomly-generated name as choice 2."""
53     return mudpy.misc.random_name()
54
55
56 def choose_name_create_3(user):
57     """Provide a randomly-generated name as choice 3."""
58     return mudpy.misc.random_name()
59
60
61 def choose_name_create_4(user):
62     """Provide a randomly-generated name as choice 4."""
63     return mudpy.misc.random_name()
64
65
66 def choose_name_create_5(user):
67     """Provide a randomly-generated name as choice 5."""
68     return mudpy.misc.random_name()
69
70
71 def choose_name_create_6(user):
72     """Provide a randomly-generated name as choice 6."""
73     return mudpy.misc.random_name()
74
75
76 def choose_name_create_7(user):
77     """Provide a randomly-generated name as choice 7."""
78     return mudpy.misc.random_name()
79
80
81 def delete_account_action_y(user):
82     """Permanently delete the account and all avatars, as requested."""
83     return user.destroy()
84
85
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])
90
91
92 def delete_avatar_action_a(user):
93     """Abort avatar deletion."""
94     return True
95
96
97 def delete_avatar_create(user):
98     """List available avatars for possible deletion."""
99     return dict(
100         [(str(x + 1), y) for x, y in enumerate(user.list_avatar_names())])