/
guild.c
102 lines (91 loc) · 3.17 KB
/
guild.c
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
//*****************************************************************************
// Copyright (c) 2019 - Allen Cummings, RealmsMUD, All rights reserved. See
// the accompanying LICENSE file for details.
//*****************************************************************************
inherit "/lib/commands/baseCommand.c";
/////////////////////////////////////////////////////////////////////////////
public nomask void reset(int arg)
{
if (!arg)
{
CommandType = "Social";
addCommandTemplate("guild [-g ##Value##] [.*]");
}
}
/////////////////////////////////////////////////////////////////////////////
public nomask int execute(string command, object initiator)
{
int ret = 0;
if (canExecuteCommand(command))
{
string *guilds = initiator->memberOfGuilds();
if (!sizeof(guilds))
{
guilds += ({ "guildless" });
}
string guild;
if (sizeof(regexp(({ command }), "-g (" + implode(guilds, "|") + ")")))
{
guild = regreplace(command, "^guild -g (" + implode(guilds, "|") + ").*", "\\1");
}
else
{
guild = initiator->primaryGuild();
}
string message = 0;
if (sizeof(regexp(({ command }), "^guild (.+)")))
{
ret = 1;
message = regreplace(command, "^guild (-g " + implode(guilds, "|") + ")* *(.*)", "\\2");
object channels = load_object("/lib/dictionaries/channelDictionary.c");
if (channels && sizeof(message))
{
channels->broadcastMessage(guild, message, initiator);
}
}
else
{
notify_fail("What do you want to say on the guild line?\n");
}
}
return ret;
}
/////////////////////////////////////////////////////////////////////////////
protected string wildcardMeaning()
{
return "\x1b[0;31;1m<Message to speak>\x1b[0m";
}
/////////////////////////////////////////////////////////////////////////////
protected string synopsis(string displayCommand)
{
return "Send a message to every logged-in player of your guild";
}
/////////////////////////////////////////////////////////////////////////////
protected string flagInformation(string flag)
{
string ret = "";
string parsedFlag = regreplace(flag, "[^-]*(-[a-zA-Z]+).*", "\\1");
switch (parsedFlag)
{
case "-g":
{
ret = "This option will allow you to specify a specific guild "
"that you wish to send a message to. If this option is not "
"passed, the message will be sent to your primary guild.\n";
break;
}
}
return format(ret, 72);
}
/////////////////////////////////////////////////////////////////////////////
protected string description(string displayCommand)
{
return format("Guild allows a player to display a message to all players "
"of their guild who are currently logged on.", 78);
}
/////////////////////////////////////////////////////////////////////////////
protected string notes(string displayCommand)
{
return "See also: tell, whisper, reply, say, race, faction, party, "
"and shout";
}