From 71056bc2ed85e96fef50be4693c9afb38d6df7d2 Mon Sep 17 00:00:00 2001 From: Elijah Perrault Date: Tue, 22 Feb 2011 22:30:01 -0700 Subject: [PATCH] Fixed a bug with wildcards and made red|green|blue|yellow valid colors. --- modules/UNO.pm | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/modules/UNO.pm b/modules/UNO.pm index 66ef257..eee7c2b 100644 --- a/modules/UNO.pm +++ b/modules/UNO.pm @@ -240,6 +240,16 @@ sub cmd_uno { return; } + # Fix color. + $argv[1] =~ s/blue/B/ixsm; + $argv[1] =~ s/red/R/ixsm; + $argv[1] =~ s/green/G/ixsm; + $argv[1] =~ s/yellow/Y/ixsm; + $argv[2] =~ s/blue/B/ixsm; + $argv[2] =~ s/red/R/ixsm; + $argv[2] =~ s/green/G/ixsm; + $argv[2] =~ s/yellow/Y/ixsm; + # Check if they have this card. if (!_hascard(lc $src->{nick}, uc $argv[1].':'.uc $argv[2])) { notice($src->{svr}, $src->{nick}, 'You don\'t have that card.'); @@ -274,6 +284,15 @@ sub cmd_uno { } } + # If it's a wildcard... + if ($argv[1] =~ m/^W/ixsm) { + # Ensure the third argument is a valid color. + if ($argv[2] !~ m/^(R|B|G|Y)$/ixsm) { + notice($src->{svr}, $src->{nick}, "Invalid color \2$argv[2]\2."); + return; + } + } + privmsg($src->{svr}, $src->{chan}, "\2$src->{nick}\2 plays "._fmtcard(uc $argv[1].':'.uc $argv[2])); # Delete the card from the player's hand. @@ -1241,7 +1260,7 @@ sub on_kick { # Start initialization. -API::Std::mod_init('UNO', 'Xelhua', '1.00', '3.0.0a5', __PACKAGE__); +API::Std::mod_init('UNO', 'Xelhua', '1.01', '3.0.0a5', __PACKAGE__); # vim: set ai sw=4 ts=4: # build: perl=5.010000 @@ -1253,7 +1272,7 @@ UNO - Three editions of the UNO card game =head1 VERSION - 1.00 + 1.01 =head1 SYNOPSIS