1 |
/** |
2 |
* eightball.C: A Magic 8 Ball. Oh noes! |
3 |
* |
4 |
* Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team |
5 |
* Rights to this code are as documented in COPYING. |
6 |
* |
7 |
* |
8 |
* Portions of this file were derived from sources bearing the following license: |
9 |
* Copyright © 2005-2006 William Pitcock <nenolod@nenolod.net> et al |
10 |
* Rights to this code are documented in doc/pod/license.pod. |
11 |
* |
12 |
* $Id: eightball.C,v 1.5 2007-09-16 18:54:43 pippijn Exp $ |
13 |
*/ |
14 |
|
15 |
#include "atheme.h" |
16 |
#include <ermyth/module.h> |
17 |
#include <util/random.h> |
18 |
|
19 |
static char const rcsid[] = "$Id: eightball.C,v 1.5 2007-09-16 18:54:43 pippijn Exp $"; |
20 |
|
21 |
REGISTER_MODULE ("gameserv/eightball", false, "The Ermyth Team <http://ermyth.xinutec.org>"); |
22 |
|
23 |
static void command_eightball (sourceinfo_t *si, int parc, char *parv[]); |
24 |
|
25 |
command_t const cmd_eightball = { "EIGHTBALL", N_("Ask the 8-Ball a question."), AC_NONE, 0, command_eightball }; |
26 |
|
27 |
E cmdvec gs_cmdtree; |
28 |
E cmdvec cs_cmdtree; |
29 |
|
30 |
E helpvec gs_helptree; |
31 |
E helpvec cs_helptree; |
32 |
|
33 |
bool |
34 |
_modinit (module *m) |
35 |
{ |
36 |
|
37 |
gs_cmdtree << cmd_eightball; |
38 |
cs_cmdtree << cmd_eightball; |
39 |
|
40 |
help_addentry (gs_helptree, "EIGHTBALL", "help/gameserv/eightball", NULL); |
41 |
help_addentry (cs_helptree, "EIGHTBALL", "help/gameserv/eightball", NULL); |
42 |
|
43 |
return true; |
44 |
} |
45 |
|
46 |
void |
47 |
_moddeinit () |
48 |
{ |
49 |
gs_cmdtree >> cmd_eightball; |
50 |
cs_cmdtree >> cmd_eightball; |
51 |
|
52 |
help_delentry (gs_helptree, "EIGHTBALL"); |
53 |
help_delentry (cs_helptree, "EIGHTBALL"); |
54 |
} |
55 |
|
56 |
/* |
57 |
* Handle reporting for both fantasy commands and normal commands in GameServ |
58 |
* quickly and easily. Of course, sourceinfo has a vtable that can be manipulated, |
59 |
* but this is quicker and easier... -- nenolod |
60 |
*/ |
61 |
static void |
62 |
gs_command_report (sourceinfo_t *si, char const * const fmt, ...) |
63 |
{ |
64 |
va_list args; |
65 |
char buf[BUFSIZE]; |
66 |
|
67 |
va_start (args, fmt); |
68 |
vsnprintf (buf, BUFSIZE, fmt, args); |
69 |
va_end (args); |
70 |
|
71 |
if (si->c != NULL) |
72 |
phandler->privmsg (chansvs.nick, si->c->name, "%s", buf); |
73 |
else |
74 |
command_success_nodata (si, "%s", buf); |
75 |
} |
76 |
|
77 |
static void |
78 |
command_eightball (sourceinfo_t *si, int parc, char *parv[]) |
79 |
{ |
80 |
static char const * const eightball_responses[] = { |
81 |
N_("Absolutely yes!"), |
82 |
N_("Prospect looks hopeful."), |
83 |
N_("I'd like to think so."), |
84 |
N_("Yes, yes, yes, and yes again."), |
85 |
N_("Most likely."), |
86 |
N_("All signs point to yes."), |
87 |
N_("Yes."), |
88 |
N_("Without a doubt."), |
89 |
N_("Sometime in the near future."), |
90 |
N_("Of course!"), |
91 |
N_("Definitely."), |
92 |
N_("Answer hazy."), |
93 |
N_("Prospect looks bleak."), |
94 |
N_("That's a question you should ask yourself."), |
95 |
N_("Maybe."), |
96 |
N_("That question is better remained unanswered."), |
97 |
N_("The stars would have to align for that to happen."), |
98 |
N_("No."), |
99 |
N_("Not even on a GOOD day."), |
100 |
N_("It would take a disturbed person to even ask."), |
101 |
N_("You wish."), |
102 |
N_("Not bloody likely."), |
103 |
N_("No way."), |
104 |
N_("Never."), |
105 |
N_("NO!"), |
106 |
N_("Over my dead body."), |
107 |
N_("We won't go there"), |
108 |
N_("No chance at all!") |
109 |
}; |
110 |
|
111 |
gs_command_report (si, "%s", eightball_responses[gen_rand32 () % 28]); |
112 |
} |