MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / onCommand

Function onCommand

_datafiles/world/default/rooms/tutorial/903.js:14–75  ·  view source on GitHub ↗
(cmd, rest, user, room)

Source from the content-addressed store, hash-verified

12
13// Generic Command Handler
14function onCommand(cmd, rest, user, room) {
15
16 ignoreCommand = false;
17
18 teacherMob = getTeacher(room);
19
20 fullCommand = ExpandCommand(cmd);
21 if ( rest.length > 0 ) {
22 fullCommand = cmd + ' ' + rest;
23 }
24
25 if ( commandNow >= 2 ) {
26 return false;
27 }
28
29 if ( teach_commands[commandNow] == fullCommand ) {
30
31 if ( fullCommand == "equip cap" ) {
32 teacherMob.Command("say Good job!", 1.0);
33 } else {
34 teacherMob.Command("say Good job! You earned it!", 1.0);
35 }
36
37 commandNow++;
38
39 } else {
40
41 if ( allowed_commands.includes(cmd) || teach_commands.slice(0, commandNow).includes(cmd) ) {
42 return false;
43 }
44
45 ignoreCommand = true;
46 }
47
48 switch (commandNow) {
49 case 0:
50 teacherMob.Command('emote gestures to the <ansi fg="item">graduation cap</ansi> on the ground.', 1.0);
51 teacherMob.Command('say type <ansi fg="command">get cap</ansi> to pick up the <ansi fg="item">graduation cap</ansi>.', 1.0);
52 break;
53 case 1:
54 teacherMob.Command('say Go ahead and wear the <ansi fg="item">graduation cap</ansi> by typing <ansi fg="command">equip cap</ansi>.', 1.0);
55 break;
56 case 2:
57
58 teacherMob.Command('say It\'s time to say goodbye', 1.0);
59 teacherMob.Command('say I\'ll summon a portal to send you to the heart of <ansi fg="zone">Frostfang city</ansi>, where your adventure begins.', 1.0);
60
61 exits = room.GetExits();
62 if ( !exits.portal ) {
63 teacherMob.Command('emote glows intensely, and a ' + UtilApplyColorPattern('swirling portal', 'pink') + ' appears!', 1.0);
64 room.AddTemporaryExit('swirling portal', ':pink', 0, "1 real day"); // RoomId 0 is an alias for start room. Portal can live a long time since the room is ephemeral.
65 }
66
67 teacherMob.Command('say Enter the portal by typing <ansi fg="command">swirling portal</ansi> (or just <ansi fg="command">portal</ansi>) when you are ready.', 1.0);
68
69 break;
70 default:
71 break;

Callers

nothing calls this directly

Calls 6

ExpandCommandFunction · 0.85
UtilApplyColorPatternFunction · 0.85
GetExitsMethod · 0.80
getTeacherFunction · 0.70
CommandMethod · 0.45
AddTemporaryExitMethod · 0.45

Tested by

no test coverage detected