[SimBot-commits] CVS: simbot/plugins dice.pl,1.26,1.27
Status: Abandoned
Brought to you by:
kstange
|
From: Pete P. <fou...@us...> - 2007-01-22 03:41:54
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv16146/plugins Modified Files: dice.pl Log Message: This is the first change to the changelog since 10 Nov 2005. Added a feature by KewlioMZX to give the sum of rolled dice. Index: dice.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/dice.pl,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -p -r1.26 -r1.27 --- dice.pl 23 Nov 2006 08:52:11 -0000 1.26 +++ dice.pl 22 Jan 2007 03:41:50 -0000 1.27 @@ -8,7 +8,7 @@ # coin with '%flip' and play "rock, paper, scissors, with '%rps.' # # COPYRIGHT: -# Copyright (C) 2003-05, Pete Pearson +# Copyright (C) 2003-07, Pete Pearson # # This program is free software; you can redistribute and/or modify it # under the terms of version 2 of the GNU General Public License as @@ -58,6 +58,7 @@ use constant RPS_CHEER => ( sub roll_dice { my $numDice = 2; my $numSides = 6; + my $diceTotal = 0; my ($kernel, $nick, $channel, undef, $dice) = @_; if($dice =~ m/(\d*)[Dd](\d+)/) { $numDice = (defined $1 ? $1 : 1); @@ -76,10 +77,12 @@ sub roll_dice { } else { my @rolls = (); for(my $x=0;$x<$numDice;$x++) { - push(@rolls, int rand($numSides)+1); + my $diceRoll = int rand($numSides)+1; + $diceTotal += $diceRoll; + push(@rolls, $diceRoll); } - &SimBot::send_action($channel, "rolls $numDice ${numSides}-sided " . (($numDice==1) ? 'die' : 'dice') . " for ${nick}: " . join(' ', @rolls)); + &SimBot::send_action($channel, "rolls $numDice ${numSides}-sided " . (($numDice==1) ? 'die' : 'dice') . " for ${nick}: " . join(' ', @rolls) . ($numDice==1 ? '' : " -- total of $diceTotal")); } } |