From 9a526e1427afc5065ef85c864cbb5b844492fb80 Mon Sep 17 00:00:00 2001 From: Eitan Date: Sun, 10 Apr 2011 19:07:38 -0600 Subject: [PATCH] Werewolf: Use constants for maximum/gun player counts. --- doc/CHANGELOG | 1 + modules/Werewolf.pm | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/doc/CHANGELOG b/doc/CHANGELOG index fb3566f..382db6c 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -3,6 +3,7 @@ Auto IRC Bot 3.0: Change Log 3.0 Indev =============================================================================== + * Werewolf: Use constants for maximum/gun player counts. * Werewolf: Fixed an annoyance in VOTES. * Werewolf: Fixed another round of bugs. * Werewolf: Fixed a grammatical error. Thanks TAD! diff --git a/modules/Werewolf.pm b/modules/Werewolf.pm index 66b1b4a..0750dca 100644 --- a/modules/Werewolf.pm +++ b/modules/Werewolf.pm @@ -11,6 +11,11 @@ my ($GAME, $PGAME, $GAMECHAN, $GAMETIME, %PLAYERS, %NICKS, @STATIC, $PHASE, $SEE our $WAIT; my $FCHAR = (conf_get('fantasy_pf'))[0][0]; +use constant MAX_PLAYERS = 25; +use constant GUN_PLAYERS = 7; + + + # Initialization subroutine. sub _init { # Create the WOLF command. @@ -136,8 +141,8 @@ sub cmd_wolf { return; } - # Maximum amount of players is 30. - if (keys %PLAYERS >= 30) { + # Are we over the max number of -players? + if (keys %PLAYERS >= MAX_PLAYERS) { notice($src->{svr}, $src->{nick}, 'Too many players! Try again next time.'); return; } @@ -271,7 +276,7 @@ sub cmd_wolf { } # If there's 6 or more players, give one of them a gun. - if (keys %PLAYERS >= 6) { + if (keys %PLAYERS >= GUN_PLAYERS) { my $rpi = $plyrs[int rand scalar @plyrs]; while ($PLAYERS{$rpi} =~ m/w/xsm || $PLAYERS{$rpi} =~ m/t/xsm) { $rpi = $plyrs[int rand scalar @plyrs] } $PLAYERS{$rpi} .= 'b';