From 16f272d142c0145da4875fa9e776865219772fc1 Mon Sep 17 00:00:00 2001
From: ElTata <eltata@firemail.cc>
Date: Mon, 2 Dec 2019 19:16:24 +0100
Subject: [PATCH] bug fixes

- corrections colors
- correction space in classe name
---
 Irpg/Action.pm | 36 ++++++++++++++++++------------------
 Irpg/Users.pm  |  7 ++++---
 2 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/Irpg/Action.pm b/Irpg/Action.pm
index 6595314..c297121 100644
--- a/Irpg/Action.pm
+++ b/Irpg/Action.pm
@@ -280,21 +280,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($_)); }
@@ -315,22 +314,22 @@ sub collision_action {
         $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($_)); }
@@ -476,21 +475,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 3aa4c12..f149f0b 100644
--- a/Irpg/Users.pm
+++ b/Irpg/Users.pm
@@ -410,6 +410,7 @@ 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 =~ s/ /_/g;
     if (!defined($username)) {
         Irpg::Irc::notice("You are not logged in.", $usernick);
         return;
@@ -423,7 +424,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 +438,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');
-- 
GitLab