/** * rps.C: Rock Paper Scissors * * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team * Rights to this code are as documented in COPYING. * * * Portions of this file were derived from sources bearing the following license: * Copyright © 2005-2006 William Pitcock et al * Rights to this code are documented in doc/pod/license.pod. * * $Id: rps.C,v 1.6 2007/09/22 14:27:27 pippijn Exp $ */ #include "atheme.h" #include #include static char const rcsid[] = "$Id: rps.C,v 1.6 2007/09/22 14:27:27 pippijn Exp $"; REGISTER_MODULE ("gameserv/rps", false, "The Ermyth Team "); static void command_rps (sourceinfo_t *si, int parc, char *parv[]); command_t const cmd_rps = { "RPS", N_("Rock Paper Scissors."), AC_NONE, 0, command_rps }; E cmdvec gs_cmdtree; E cmdvec cs_cmdtree; bool _modinit (module *m) { gs_cmdtree << cmd_rps; cs_cmdtree << cmd_rps; return true; } void _moddeinit () { gs_cmdtree >> cmd_rps; cs_cmdtree >> cmd_rps; } /* * Handle reporting for both fantasy commands and normal commands in GameServ * quickly and easily. Of course, sourceinfo has a vtable that can be manipulated, * but this is quicker and easier... -- nenolod */ static void gs_command_report (sourceinfo_t *si, char const * const fmt, ...) { va_list args; char buf[BUFSIZE]; va_start (args, fmt); vsnprintf (buf, BUFSIZE, fmt, args); va_end (args); if (si->c != NULL) phandler->privmsg (chansvs.nick, si->c->name, "%s", buf); else command_success_nodata (si, "%s", buf); } static void command_rps (sourceinfo_t *si, int parc, char *parv[]) { static char const * const rps_responses[] = { N_("Rock"), N_("Paper"), N_("Scissors") }; gs_command_report (si, "%s", rps_responses[gen_rand32 () % 3]); }