From e590c0dee3b4721731c6761dfcd28c7bc193b041 Mon Sep 17 00:00:00 2001 From: Elijah Perrault Date: Mon, 18 Apr 2011 14:23:58 -0600 Subject: [PATCH] Werewolf: Improved STATS to be smart. --- doc/CHANGELOG | 1 + modules/Werewolf.pm | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 0ea7d4a..0ed3a97 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -3,6 +3,7 @@ Auto IRC Bot 3.0: Change Log 3.0 Indev =============================================================================== + * Werewolf: Improved STATS to be smart. * Werewolf 1.04: Added village drunks and fixed other issues. * Werewolf: Fixed various annoyances. Also raised chance of gun hitting. * Werewolf: Fixed a nasty lynch nick exploit. diff --git a/modules/Werewolf.pm b/modules/Werewolf.pm index 13d06ab..45743c6 100644 --- a/modules/Werewolf.pm +++ b/modules/Werewolf.pm @@ -592,6 +592,7 @@ sub cmd_wolf { privmsg($src->{svr}, $src->{chan}, "$src->{nick}: \2".keys(%PLAYERS)."\2 players: $str"); # If all roles have been assigned, return the count of each. if ($GAME) { + # Get a count of all roles. my $cwolves = my $cseers = my $charlots = my $cangels = my $ctraitors = my $cdetectives = 0; foreach my $flags (values %PLAYERS) { if ($flags =~ m/w/xsm) { $cwolves++ } @@ -601,9 +602,22 @@ sub cmd_wolf { if ($flags =~ m/t/xsm) { $ctraitors++ } if ($flags =~ m/d/xsm) { $cdetectives++ } } - privmsg($src->{svr}, $src->{chan}, "$src->{nick}: There are \2$cwolves\2 wolves, \2$cseers\2 seers, ". - "\2$charlots\2 ".((conf_get('werewolf:rated-g')) ? '' : 'harlots').", \2$ctraitors\2 traitors, \2$cdetectives\2 detectives, ". - "and \2$cangels\2 guardian angels."); + # Prepare an array of data. + my @data; + push @data, "\2$cwolves\2 wolves"; + push @data, "\2$cseers\2 seers"; + + # Push extra roles. + if (!conf_get('werewolf:rated-g')) { push @data, "\2$charlots\2 harlots" } + if (!conf_get('werewolf:no-angels')) { push @data, "\2$cangels\2 guardian angels" } + if (conf_get('werewolf:traitors')) { push @data, "\2$ctraitors\2 traitors" } + if (conf_get('werewolf:detectives')) { push @data, "\2$cdetectives\2 detectives" } + + # Prepare message. + my $msg = "$src->{nick}: There are ".join(', ', @data[0..$#data-1]); + $msg .= ", and $data[$#data]."; + + privmsg($src->{svr}, $src->{chan}, $msg); } } when (/^(KICK|K)$/) {