diff --git a/Irpg/Action.pm b/Irpg/Action.pm index 6595314c6c72469177d29dd518de53db7265fe7b..6cbe307735808d23d203e9d2697321eaa3086c3a 100644 --- a/Irpg/Action.pm +++ b/Irpg/Action.pm @@ -164,7 +164,10 @@ sub steal_result { "pair of gloves","set of leggings","shield", "pair of boots"); my $type = $items[rand(@items)]; - if (int($rps->{$p2}{item}{$type}) > int($rps->{$p1}{item}{$type})) { + my ($item1,) = $rps->{$p1}{item}{$type} =~ m/(\d+)\D?/; + my ($item2,) = $rps->{$p2}{item}{$type} =~ m/(\d+)\D?/; + #if (int($rps->{$p2}{item}{$type}) > int($rps->{$p1}{item}{$type})) { + if ($item2 > $item1) { my $tempitem = $rps->{$p1}{item}{$type}; $rps->{$p1}{item}{$type}=$rps->{$p2}{item}{$type}; $rps->{$p2}{item}{$type} = $tempitem; @@ -280,21 +283,20 @@ sub challenge_opp { # pit argument player against random player my $p1_res = "[$ret_action->{p1roll}/$ret_action->{p1sum}]*$ret_action->{p1atk}"; my $p2_res = "[$ret_action->{p2roll}/$ret_action->{p2sum}]*$ret_action->{p2def}"; my $mesg = ''; - my $msg .= $ret_action->{vict} ? "\x033" : "\x035"; if ($action_type eq 'fight') { $mesg .= "$p1 $p1_res has challenged $p2 $p2_res in combat and \x03". - ($ret_action->{vict} ? "3won" : "5lost")."!\x03 "; + ($ret_action->{vict} ? "3won" : "5lost")."!"; } elsif ($action_type eq 'mystic') { $mesg .= "$p1 $p1_res has cast a spell on $p2 $p2_res and \x03". - ($ret_action->{vict} ? "3succeed" : "5failed")."! "; + ($ret_action->{vict} ? "3succeed" : "5failed")."!"; } else { #($action_type eq 'steal') $mesg .= "$p1 $p1_res has tried to steal from $p2 $p2_res and \x03". - ($ret_action->{vict} ? "3succeed" : "5failed")."! "; + ($ret_action->{vict} ? "3succeed" : "5failed")."!"; } - $mesg .= "\x03"; + $mesg .= "\x03 "; $mesg .= shift @$res_action; Irpg::Irc::chanmsg(Irpg::Utils::clog($mesg)); foreach (@$res_action) { Irpg::Irc::chanmsg(Irpg::Utils::clog($_)); } @@ -310,27 +312,27 @@ sub collision_action { my $p1_res = "[$ret_action->{p1roll}/$ret_action->{p1sum}]*$ret_action->{p1atk}"; my $p2_res = "[$ret_action->{p2roll}/$ret_action->{p2sum}]*$ret_action->{p2def}"; my $mesg = "$p1 $p1_res has come upon $p2 $p2_res and "; - $mesg .= $ret_action->{vict} ? "\x033" : "\x035"; + $mesg .= $ret_action->{vict} ? "\x033" : "\x035"; if ($action_type eq 'fight') { $mesg .= ($ret_action->{vict} ? 'taken '.pronoun(3, $rps->{$p2}{gender}): 'been defeated'). - " in combat! "; + " in combat!"; } elsif ($action_type eq 'mystic') { $mesg .= ($ret_action->{vict} ? 'made '.pronoun(3, $rps->{$p2}{gender}). ' lost '.pronoun(2, $rps->{$p2}{gender}): 'lost '.pronoun(2, $rps->{$p1}{gender})). - " minds! "; + " minds!"; } else { #($action_type eq 'steal') $mesg .= ($ret_action->{vict} ? 'stolen ': 'been caught stealing '). - 'from '.pronoun(3, $rps->{$p2}{gender})."! "; + 'from '.pronoun(3, $rps->{$p2}{gender})."!"; } - $mesg .= "\x03"; + $mesg .= "\x03 "; $mesg .= shift @$res_action; Irpg::Irc::chanmsg(Irpg::Utils::clog($mesg)); foreach (@$res_action) { Irpg::Irc::chanmsg(Irpg::Utils::clog($_)); } @@ -403,7 +405,7 @@ sub rpcheck { sub do_actions { my ($userhost, $usernick, $username, $source, @arg) = @_; - my $ret; + my $ret; do { $ret = do_action($userhost, $usernick, $username, $source, @arg); } while ($rps->{$username}{actions} && !$ret); @@ -476,21 +478,22 @@ sub do_action { my $mesg = ''; if ($action_type eq 'fight') { - $mesg .= "$p1 $p1_res has provoked $p2 $p2_res in a fight, and ". - ($ret_action->{vict} ? 'won': 'lost')."! "; + $mesg .= "$p1 $p1_res has provoked $p2 $p2_res in a fight, and \x03". + ($ret_action->{vict} ? "3won": "5lost")."!"; } elsif ($action_type eq 'mystic') { - $mesg .= "$p1 $p1_res has performed mystical deeds on $p2 $p2_res, and ". + $mesg .= "$p1 $p1_res has performed mystical deeds on $p2 $p2_res, and \x03". ($ret_action->{vict} ? - 'dazed '.pronoun(3, $rps->{$p2}{gender}): - 'got confused'). - "! "; + "3dazed ".pronoun(3, $rps->{$p2}{gender}): + "5got confused"). + "!"; } else { #($action_type eq 'steal') - $mesg .= "$p1 $p1_res has sneaked on $p2 $p2_res in the shadows and ". - ($ret_action->{vict} ? 'stolen ' : 'been caught stealing '). - 'from '.pronoun(3, $rps->{$p2}{gender})."! "; + $mesg .= "$p1 $p1_res has sneaked on $p2 $p2_res in the shadows and \x03". + ($ret_action->{vict} ? "3stolen " : "5been caught stealing "). + 'from '.pronoun(3, $rps->{$p2}{gender})."!"; } + $mesg .= "\x03 "; $mesg .= shift @$res_action; Irpg::Irc::chanmsg(Irpg::Utils::clog($mesg)); foreach (@$res_action) { Irpg::Irc::chanmsg(Irpg::Utils::clog($_)); } diff --git a/Irpg/Users.pm b/Irpg/Users.pm index 3aa4c12de3a97626e5f1a62f844ec2874169ff80..454cbbacdc29c5f3780bddf581f7f45207771ced 100644 --- a/Irpg/Users.pm +++ b/Irpg/Users.pm @@ -139,16 +139,17 @@ sub register { sub chtitle { my ($userhost, $usernick, $username, $source, @arg) = @_; + my $title = join(' ', @arg); if (!defined($username)) { Irpg::Irc::notice("You are not logged in.", $usernick); } - elsif (!defined($arg[0])) { + elsif (!$title) { Irpg::Irc::notice("Try: CHTITLE <new title>", $usernick); } else { - $rps->{$username}{title} = "@arg[2..$#arg]"; + $rps->{$username}{title} = $title; Irpg::Irc::privmsg("Your title was changed.",$source); - Irpg::Irc::chanmsg("Title for $arg[0] changed to @arg[2..$#arg]."); + Irpg::Irc::chanmsg("Title for $arg[0] changed to $title."); Irpg::Main::penalize($username,"chtitle"); } } @@ -410,6 +411,8 @@ sub chclass { my ($userhost, $usernick, $username, $source, @arg) = @_; my $cname = lc(join(' ', @arg)); $cname =~ s/\b(\w)/\u$1/g; # capitalize the first letter of each word + my $cname_ = $cname; + my $cname_ =~ s/ /_/g; if (!defined($username)) { Irpg::Irc::notice("You are not logged in.", $usernick); return; @@ -423,7 +426,7 @@ sub chclass { s/Irpg\/Classes\/(\w+)\.pm/$1/; push @classes, $_; } - if (!grep { $cname eq $_ } @classes) { + if (!grep { $cname_ eq $_ } @classes) { Irpg::Irc::privmsg("I know you are a very special unique person ". "with your very own feelings, sensitivity, emotions, ". "competences and everything, but you really can't be ". @@ -437,8 +440,8 @@ sub chclass { $source) } else { - eval "require Irpg::Classes::$cname"; - my $new_class = eval 'Irpg::Classes::'.$cname.'->new($rps->{$username}{stats})'; + eval "require Irpg::Classes::$cname_"; + my $new_class = eval 'Irpg::Classes::'.$cname_.'->new($rps->{$username}{stats})'; if ($new_class) { $rps->{$username}{class} = $new_class; Irpg::Main::penalize($username, 'chclass');