Esempio n. 1
0
static void command_calc(sourceinfo_t *si, int parc, char *parv[])
{
	char *arg;
	mychan_t *mc;
	int i, times = 1;

	if (!gs_do_parameters(si, &parc, &parv, &mc))
		return;
	if (parc < 1)
	{
		command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "CALC");
		command_fail(si, fault_needmoreparams, _("Syntax: CALC [times] <expression>"));
		return;
	}
	if (parc < 2)
		arg = parv[0];
	else
	{
		times = atoi(parv[0]);
		arg = parv[1];

		if (times > 10)
			times = 10;
	}

	for (i = 0; i < times; i++)
		eval_calc(si, arg);
}
Esempio n. 2
0
static void command_rps(sourceinfo_t *si, int parc, char *parv[])
{
	mychan_t *mc;
	static const char *rps_responses[3] = {
		N_("Rock"),
		N_("Paper"),
		N_("Scissors")
	};

	if (!gs_do_parameters(si, &parc, &parv, &mc))
		return;

	gs_command_report(si, "%s", _(rps_responses[rand() % 3]));
}
Esempio n. 3
0
static void
command_namegen(struct sourceinfo *si, int parc, char *parv[])
{
	unsigned int iter;
	unsigned int amt = 20;
	char buf[BUFSIZE];
	struct mychan *mc;

	if (!gs_do_parameters(si, &parc, &parv, &mc))
		return;

	if (parv[0])
		amt = atoi(parv[0]);


	// limit to 20
	if (amt > 20)
		amt = 20;

	*buf = '\0';

	for (iter = 0; iter < amt; iter++)
	{
		char namebuf[BUFSIZE];
		unsigned int medial_iter;

		// Here we generate the name.
		mowgli_strlcpy(namebuf, begin_sym[rand() % BEGIN_SYM_SZ], BUFSIZE);

		for (medial_iter = rand() % 3; medial_iter > 0; medial_iter--)
			mowgli_strlcat(namebuf, medial_sym[rand() % MEDIAL_SYM_SZ], BUFSIZE);

		mowgli_strlcat(namebuf, end_sym[rand() % END_SYM_SZ], BUFSIZE);

		if (iter == 0)
			mowgli_strlcpy(buf, namebuf, BUFSIZE);
		else
			mowgli_strlcat(buf, namebuf, BUFSIZE);

		mowgli_strlcat(buf, iter + 1 < amt ? ", " : ".", BUFSIZE);
	}

	gs_command_report(si, _("Some names to ponder: %s"), buf);
}
Esempio n. 4
0
static void command_lottery(sourceinfo_t *si, int parc, char *parv[])
{
	mychan_t *mc;
	user_t *u;

	if (!gs_do_parameters(si, &parc, &parv, &mc))
		return;

	if (si->c == NULL)
	{
		command_fail(si, fault_nosuch_target, _("This command may only be used on a channel."));
		return;
	}

	u = pick_a_sucker(si->c);
	return_if_fail(u != NULL);

	gs_command_report(si, "%s", u->nick);
}
Esempio n. 5
0
static void
command_eightball(struct sourceinfo *si, int parc, char *parv[])
{
	struct mychan *mc;

	if (!gs_do_parameters(si, &parc, &parv, &mc))
		return;

	static const char *eightball_responses[28] = {
		N_("Absolutely yes!"),
		N_("Prospect looks hopeful."),
		N_("I'd like to think so."),
		N_("Yes, yes, yes, and yes again."),
		N_("Most likely."),
		N_("All signs point to yes."),
		N_("Yes."),
		N_("Without a doubt."),
		N_("Sometime in the near future."),
		N_("Of course!"),
		N_("Definitely."),
		N_("Answer hazy."),
		N_("Prospect looks bleak."),
		N_("That's a question you should ask yourself."),
		N_("Maybe."),
		N_("That question is better remained unanswered."),
		N_("The stars would have to align for that to happen."),
		N_("No."),
		N_("Not even on a GOOD day."),
		N_("It would take a disturbed person to even ask."),
		N_("You wish."),
		N_("Not bloody likely."),
		N_("No way."),
		N_("Never."),
		N_("NO!"),
		N_("Over my dead body."),
		N_("We won't go there"),
		N_("No chance at all!")
	};

	gs_command_report(si, "%s", _(eightball_responses[rand() % 28]));
}
Esempio n. 6
0
static void command_df(sourceinfo_t *si, int parc, char *parv[])
{
	mychan_t *mc;
	char *arg_dice;
	char buf[BUFSIZE];
	int i, dice;

	if (!gs_do_parameters(si, &parc, &parv, &mc))
		return;
	if (parc < 1)
	{
		command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "DF");
		command_fail(si, fault_needmoreparams, _("Syntax: DF <dice>"));
		return;
	}
	arg_dice = parv[0];

	dice = atoi(arg_dice);
	*buf = '\0';

	if (dice > 30 || dice < 1)
	{
		command_fail(si, fault_badparams, _("Only 1-30 dice may be thrown at one time."));
		return;
	}

	for (i = 0; i < dice; i++)
	{
		int roll = arc4random() % 3;

		if (*buf != '\0')
			mowgli_strlcat(buf, df_dice_table[roll], BUFSIZE);
		else
			mowgli_strlcpy(buf, df_dice_table[roll], BUFSIZE);
	}

	gs_command_report(si, _("Result: %s"), buf);
}
Esempio n. 7
0
static void command_dice(sourceinfo_t *si, int parc, char *parv[])
{
	char *arg;
	mychan_t *mc;
	int i, times = 1;

	if (!gs_do_parameters(si, &parc, &parv, &mc))
		return;
	if (parc < 1)
	{
		command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "ROLL");
		command_fail(si, fault_needmoreparams, _("Syntax: ROLL [times] [dice]d<sides>"));
		return;
	}
	if (parc < 2)
		arg = parv[0];
	else
	{
		times = atoi(parv[0]);
		arg = parv[1];

		if (times > 10)
			times = 10;
	}

	if (!strcasecmp("RICK", arg))
	{
		gs_command_report(si, "Never gonna give you up; Never gonna let you down");
		gs_command_report(si, "Never gonna run around and desert you; Never gonna make you cry");
		gs_command_report(si, "Never gonna say goodbye; Never gonna tell a lie and hurt you");
		return;
	}

	for (i = 0; i < times; i++)
		if(!eval_dice(si, arg))
			break;
}
Esempio n. 8
0
static void command_wod(sourceinfo_t *si, int parc, char *parv[])
{
	mychan_t *mc;
	char *arg_dice, *arg_difficulty;
	int ii = 0;
	int dice, difficulty;
	int roll, total, roll_count = 0, i;
	int success = 0, failure = 0, botches = 0, rerolls = 0;
	static char buf[BUFSIZE];
	char *end_p;

	if (!gs_do_parameters(si, &parc, &parv, &mc))
		return;
	if (parc < 2)
	{
		command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "WOD");
		command_fail(si, fault_needmoreparams, _("Syntax: WOD <dice> <difficulty>"));
		return;
	}
	arg_dice = parv[ii++];
	arg_difficulty = parv[ii++];

	while (roll_count < 3 && arg_dice != NULL && arg_difficulty != NULL)
	{
		success = 0, failure = 0, botches = 0, rerolls = 0;
		roll_count++;

		dice = atoi(arg_dice);
		difficulty = atoi(arg_difficulty);

		if (dice > 30 || dice < 1)
		{
			command_fail(si, fault_badparams, _("Only 1-30 dice may be thrown at one time."));
			return;
		}
		else if (difficulty > 10 || difficulty < 1)
		{
			command_fail(si, fault_badparams, _("Difficulty setting must be between 1 and 10."));
			return;
		}
		else
		{
			end_p = buf;

			for (i = 0; i < dice; i++)
			{
				roll = (arc4random() % 10) + 1;

				end_p += snprintf(end_p, BUFSIZE - (end_p - buf), "%d  ", roll);

				if (roll == 1)
				{
					botches++;
					continue;
				}
				else if (roll == 10)
					rerolls++;

				if (roll >= difficulty)
					success++;
				else
					failure++;
			}

			rerolls = rerolls - botches;
			total = success - botches;

			gs_command_report(si, _("%s rolls %d dice at difficulty %d: %s"), si->su->nick, dice, difficulty, buf);

			if (rerolls > 0)
				gs_command_report(si, _("Successes: %d, Failures: %d, Botches: %d, Total: %d. You may reroll %d if you have a specialty."),
					success, failure, botches, total, rerolls);
			else
				gs_command_report(si, _("Successes: %d, Failures: %d, Botches: %d, Total: %d."),
					success, failure, botches, total);
		}

		/* prepare for another go. */
		arg_dice = parv[ii++];
		arg_difficulty = parv[ii++];
	}
}
Esempio n. 9
0
static void command_nwod(sourceinfo_t *si, int parc, char *parv[])
{
	mychan_t *mc;
	char *arg_dice, *arg_rerollflag;
	int ii = 0;
	int dice, reroll;
	int roll, total, roll_count = 0, i;
	int success = 0, failure = 0, botches = 0, rerolls = 0;
	static char buf[BUFSIZE];
	char *end_p;

	if (!gs_do_parameters(si, &parc, &parv, &mc))
		return;
	if (parc < 2)
	{
		command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "NWOD");
		command_fail(si, fault_needmoreparams, _("Syntax: NWOD [-chance] <dice> [-reroll] [reroll]"));
		return;
	}
	arg_dice = parv[ii++];
	arg_rerollflag = parv[ii++];

	while (roll_count < 3 && arg_dice != NULL)
	{
		success = 0, failure = 0, botches = 0, rerolls = 0;
		roll_count++;

		dice = atoi(arg_dice);

		if (dice == 0 && !strcasecmp(arg_dice, "-chance"))
		{
			roll = (arc4random() % 10) + 1;

			if (roll == 1)
				botches++;

			if (roll == 10)
				success++;

			gs_command_report(si, _("%s rolls a chance die: %d"), si->su->nick, roll);
			gs_command_report(si, _("Successes: %d, Failures: %d, Botches: %d."), success, failure, botches);
			return;
		}

		if (dice > 30 || dice < 1)
		{
			command_fail(si, fault_badparams, _("Only 1-30 dice may be thrown at one time."));
			return;
		}

		if (arg_rerollflag != NULL && !strcasecmp(arg_rerollflag, "-reroll") && parv[ii + 1] != NULL)
			reroll = atoi(parv[ii++]);
		else
			reroll = 10;

		{
			end_p = buf;

			for (i = 0; i < dice; i++)
			{
				roll = (arc4random() % 10) + 1;

				end_p += snprintf(end_p, BUFSIZE - (end_p - buf), "%d  ", roll);

				if (roll == 1)
				{
					botches++;
					continue;
				}
				else if (roll >= reroll)
					rerolls++;

				if (roll >= 8)
					success++;
				else
					failure++;
			}

			rerolls = rerolls - botches;
			total = success - botches;

			gs_command_report(si, _("%s rolls %d dice: %s"), si->su->nick, dice, buf);

			if (rerolls > 0)
				gs_command_report(si, _("Successes: %d, Failures: %d, Botches: %d, Total: %d. You may reroll %d."),
					success, failure, botches, total, rerolls);
			else
				gs_command_report(si, _("Successes: %d, Failures: %d, Botches: %d, Total: %d."),
					success, failure, botches, total);
		}

		/* prepare for another go. */
		arg_dice = parv[ii++];
		arg_rerollflag = parv[ii++];
	}
}
Esempio n. 10
0
static void command_eightball(sourceinfo_t *si, int parc, char *parv[])
{
	mychan_t *mc;

	if (!gs_do_parameters(si, &parc, &parv, &mc))
		return;

	static const char *eightball_responses[28] = {
		N_("Absolutely yes!"),
		N_("Prospect looks hopeful."),
		N_("I'd like to think so."),
		N_("Yes, yes, yes, and yes again."),
		N_("Most likely."),
		N_("All signs point to yes."),
		N_("Yes."),
		N_("Without a doubt."),
		N_("Sometime in the near future."),
		N_("Of course!"),
		N_("Definitely."),
		N_("Answer hazy."),
		N_("Prospect looks bleak."),
		N_("That's a question you should ask yourself."),
		N_("Maybe."),
		N_("That question is better remained unanswered."),
		N_("The stars would have to align for that to happen."),
		N_("No."),
		N_("Not even on a GOOD day."),
		N_("It would take a disturbed person to even ask."),
		N_("You wish."),
		N_("Not bloody likely."),
		N_("No way."),
		N_("Never."),
		N_("NO!"),
		N_("Over my dead body."),
		N_("We won't go there"),
		N_("No chance at all!")
	};

	static const char *alcohol[21] = {
		"booze",
		"rum",
		"vodka",
		"gin",
		"tequila",
		"beer",
		"wine",
		"cider",
		"liquor",
		"bourbon",
		"drink",
		"whiskey",
		"scotch",
		"mead",
		"schnapps",
		"liquer",
		"sake",
		"sochu",
		"rye",
		"absinthe",
		"jager"
	};


        if(parv)
        {
		for(int i = 0; i < parc; i++)
			for(int j = 0; parv[i][j]; j++)
				parv[i][j] = tolower(parv[i][j]);
                
		for(int i = 0; i < parc; i++)
		{
			for(int j = 0; j < 21; j++)
			{
				if(strstr(parv[i],alcohol[j]) != 0)
	                	{
                        	gs_command_report(si, "%s", eightball_responses[rand() % 11]);
				return;
            		 	}
			}
		}
        }

	gs_command_report(si, "%s", eightball_responses[rand() % 28]);
}