-
Notifications
You must be signed in to change notification settings - Fork 12
/
cmd-wizzes.muf
291 lines (262 loc) · 8.87 KB
/
cmd-wizzes.muf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
(* cmd-wizzes.muf
* Staff listing program
* Just link an action to it and use #help for instructions
*
* By Cohote at Hope Island MUCK - Public Domain
*)
$include $lib/tabtoolkit
: help
{
"========================================================================="
"General Usage:"
command @ " - List folks that will help you." strcat
"-------------------------------------------------------------------------"
"Staff Member Commands:"
command @ " #onduty - Go on-duty!" strcat
command @ " #offduty - Clock out." strcat
command @ " #skills <skills> - Set your skills!" strcat
"-------------------------------------------------------------------------"
"Boss/Admin Commands:"
command @ " #add <player> - Add a new Staff Member." strcat
command @ " #remove - Remove a Staff Member." strcat
"========================================================================="
}tell
;
( This checks that the calling user is allowed to do admin funcs on this. )
: is-admin? ( -- b )
( Get the user's DB )
me @
( See if the user is a wizard. )
"w" flag?
( Get this MUF's owner's DB. )
trigger @ owner
( Get this user's DB. )
me @
( Compare the DB ref's )
dbcmp
( Now compare the two cases.)
or
;
( Puts the DBRef and Prop onto the stack. )
: make-stafflist ( -- d1 s1 )
trigger @ "/_staff/minimumwage"
;
( This will get the staff list and put it on the stack, ready for a reflist_* command. )
: get-stafflist-forref ( d2 -- d1 s1 d2 )
make-stafflist
rot (d1 s1 d2)
;
( This checks to see if the calling player is a staff-member or not. )
: is-staff ( -- b )
( Get the user's DB )
me @ ( d )
( Get the reflist, and then pop it all and see if the user's on the list. )
get-stafflist-forref reflist_find
( Make sure the number's over 0. )
0 >
;
( Adds a user to the staff list. )
: add-user ( s -- )
( Duplicate the string, convert the name into a dbref, and then see if that's a player. )
dup pmatch dup player? if ( Found a player. Add them to the list. )
swap pop ( Remove user's input. )
dup name swap ( Read the top-most DBref# and get the name. )
( Put the object, prop, and person to add onto the stack, and add it to the list. )
get-stafflist-forref reflist_add
"Congrats on making " swap strcat " an employee! Now put them to work!" strcat tell
else
pop
( No player. Let them know. )
"Could not find player by the name of '" strcat "'." strcat tell
then
;
( Removes a user from the staff list. )
: remove-user ( s -- )
( Duplicate the string, convert the name into a dbref, and then see if that's a player. )
dup pmatch dup player? if ( Found a player. Take them off the list. )
swap pop ( Remove user's input. )
dup name swap ( Read the top-most DBref# and get the name. )
( Put the object, prop, and person to add onto the stack, and remove it from the list. )
get-stafflist-forref reflist_del
"Sorry to hear you let " swap strcat " go!" strcat tell
else
pop
( No player. Let them know. )
"Could not find player by the name of '" strcat "'. Are you sure they work for you?" strcat tell
then
;
( Outputs the header to the user. Does no stack changes. )
: display-header ( -- )
( Put the DB# of this up, and the prop name, and then load up the list onto the stack. )
trigger @ "header" array_get_proplist
( Show the default? )
dup array_count not if
{
" Staff"
}tell
else
( Now loop through the list, outputting it. )
foreach
tell pop ( Output the line, and then drop the index off the stack. )
repeat
then
;
( Outputs the footer to the user. Does no stack changes. )
: display-footer ( -- )
( Put the DB# of this up, and the prop name, and then load up the list onto the stack. )
trigger @ "footer" array_get_proplist
( Now loop through the list, outputting it. )
foreach
tell pop ( Output the line, and then drop the index off the stack. )
repeat
;
( Adds a string to the stak that contains our root storage prop. )
: get-storage-prop ( -- s )
"_staff/#" trigger @ intostr strcat "/" strcat
;
( Displays the list of staff! )
: display ( -- )
(First, display the header.)
display-header
(Now, the contents!)
(Get the reflist into an array on the stack.)
make-stafflist array_get_reflist
dup array_count not if
pop "> No staff yet!" tell exit
then
"Name Status Specialties" tell
(Loop through each person. )
foreach ([index dbref])
(Duplicate the DBRef, get the name from it.)
dup name
(Trim the name, contatenate two spaces, and then output it.)
19 tt-shave-to-len " " strcat
(Duplicate the DBref again, see if they're awake.)
swap dup awake? if ([index string1 dbref])
(We need to see if they're on duty. Generate our prop first..)
dup get-storage-prop "offduty?" strcat
getpropstr tolower
(Compare if they're off duty.)
"yes" strcmp not if
( Put the label on. )
"Off Duty"
else
"On Duty"
then
else
(Just say they're napping!)
"Sleeping"
then
(By here, we have [index string1 dbref string2] we need to: Do a little dance..)
swap -rot ([index string1 string2 dbref] ... [index dbref string1 string2])
(Add our padding, and trim it, then cat the two strings.)
8 tt-shave-to-len strcat
(Put our dbref back on top. So now we're back to: [index string1 dbref])
swap
(Now, to get their specialities.)
dup get-storage-prop "skills" strcat
(Get the propr string, add two spaces for padding.)
getpropstr " " swap strcat
(.. Get down tonight!)
swap -rot
(Add the strings together, format it to 78 degrees.)
strcat 78 tt-shave-to-len
(Output it to player.)
tell
(Get rid of the unused items. The dbref should likey be gotten rid of above by NOT 'dup'ing it.)
pop pop
repeat
( And finally, a little foot-work here. )
display-footer
;
( Saves a prop on the player for a string of the player's object. )
: set-skills ( s -- )
( First make sure the player is a staff member.. )
is-staff if
( Check if the string is null. )
strip dup if ( Duplicate the string and then see if it's null. )
( Set the proper skillset. )
me @ get-storage-prop "skills" strcat ( [ skilllist dbref prop ] )
rot setprop ( Rotate so the skilllist is last, and then set the prop. )
"Skills added!" tell
else
( It's not null. Unset the prop. )
me @ get-storage-prop "skills" strcat remove_prop
pop ( remove the unneeded null. )
"Skillset removed!" tell
then
else
"We all know you don't have any useable skills, now." tell
then
;
( Take the truthfullness of the top item on the stack, and set's player's on-duty status. )
: set-duty-status ( x -- )
if
( Since the prop is for OFF duty, we simply remove the property if they're ON duty. )
me @ get-storage-prop "offduty?" strcat remove_prop
else
me @ get-storage-prop "offduty?" strcat "yes" setprop
then
;
( The main function! )
: main ( s -- )
( Go through our options.. )
( #add - adds a staff member. )
dup "#add " 5 strncmp not if
is-admin? if
" " split swap pop ( Get just the name.. )
( Call the 'add' function. )
add-user
else
"Sadly, your soul has not been accepted by the devil yet. You can not do that." tell
then
exit
then
( #remove - removes a staff member )
dup "#remove " 8 strncmp not if
is-admin? if
" " split swap pop ( And, get just the name.. )
( Call the 'remove' function. )
remove-user
else
"Sadly, your soul has not been accepted by the devil yet. You can not do that." tell
then
exit
then
( #skills - sets a short skills message: 'Building, Char Development, and Pizza!' )
dup "#skills " 8 strncmp not if
" " split swap pop ( Now we ONLY have the message in the stack. Or null if they wanna clear it. )
set-skills
exit
then
( #on & #onduty - Sets someone in the list "on duty")
( TODO: Allow a wiz to pass the name of someone on the list to 'force' them? )
dup "#on" strcmp not if ( [s s s] -> [s] )
( Call the 'Duty' function. )
1 set-duty-status
exit
then
dup "#onduty" strcmp not if ( [s s s] -> [s])
( Call the 'Duty' function. )
1 set-duty-status
exit
then
( #off & #offduty - Sets someone in the list "on duty")
( TODO: Allow a wiz to pass the name of someone on the list to 'force' them? )
dup "#off" strcmp not if ( [s s s] -> [s] )
( Call the 'Duty' function. )
0 set-duty-status
exit
then
dup "#offduty" strcmp not if ( [s s s] -> [s])
( Call the 'Duty' function. )
0 set-duty-status
exit
then
( If we got this far, and the first character is a "#", they plum fucked up. )
"#" 1 strncmp not if
( Call help! )
help exit
then
display
;