From 3791a07bd5468e245f607d88be01020657ddfc85 Mon Sep 17 00:00:00 2001 From: ElTata <eltata@firemail.cc> Date: Mon, 21 Oct 2019 18:06:09 +0200 Subject: [PATCH] bug fixes - status command fixed (you can ask either for the nick or the character name of a player) - some typos fixed - alignement is now the full word (not juste 'n','g','e') --- Irpg/Action.pm | 12 ++++++------ Irpg/Event.pm | 10 +++++----- Irpg/Main.pm | 2 +- Irpg/Users.pm | 43 +++++++++++++++++-------------------------- Irpg/Utils.pm | 2 +- 5 files changed, 30 insertions(+), 39 deletions(-) diff --git a/Irpg/Action.pm b/Irpg/Action.pm index 7b0c6b5..dbacf78 100644 --- a/Irpg/Action.pm +++ b/Irpg/Action.pm @@ -48,8 +48,8 @@ sub itemsum { if (!exists($rps->{$user})) { return -1; } $sum += int($rps->{$user}{item}{$_}) for keys(%{$rps->{$user}{item}}); if ($battle) { - $sum = $rps->{$user}{alignment} eq 'e' ? int($sum*.9) : - $rps->{$user}{alignment} eq 'g' ? int($sum*1.1) : + $sum = $rps->{$user}{alignment} eq 'Evil' ? int($sum*.9) : + $rps->{$user}{alignment} eq 'Good' ? int($sum*1.1) : $sum; return $rps->{$user}{class}->real_sum($sum); } @@ -119,7 +119,7 @@ sub mystic_result { $rps->{$p2}{next} += $gain; push(@queue, "$p1 transfers ".duration($gain)." from ". - pronoun(2, $rps->{$p1}{gender}). " clock to $p2\'s. ". + pronoun(2, $rps->{$p1}{gender})." clock to $p2\'s. ". "$p1 reaches next level in ".duration($rps->{$p1}{next}).". ". "$p2 reaches next level in ".duration($rps->{$p2}{next})."."); if ($win == 2) { @@ -144,7 +144,7 @@ sub mystic_result { $rps->{$p2}{next} -= $gain; push(@queue, "$p1 transfers ".duration($gain)." from ". - pronoun(2, $rps->{$p1}{gender}). "clock to $p2\'s. ". + "${p2}'s clock to ".pronoun(2, $rps->{$p1}{gender})." own.". "$p1 reaches next level in ".duration($rps->{$p1}{next}).". ". "$p2 reaches next level in ".duration($rps->{$p2}{next})."."); } @@ -254,8 +254,8 @@ sub perform_action { if ($p1roll >= $p2roll) { # VICTORY $ret->{vict}++; - my $align_mod = $rps->{$p1}{alignment} eq "g" ? 0.05 : - $rps->{$p1}{alignment} eq "e" ? -0.10 : + my $align_mod = $rps->{$p1}{alignment} eq 'Good' ? 0.05 : + $rps->{$p1}{alignment} eq 'Evil' ? -0.10 : 1; if ($p1roll >= $p1sum * $p1atk * ($rps->{$p1}{class}->{CRIT_SK} + $align_mod)) { # CRITICAL STRIKE diff --git a/Irpg/Event.pm b/Irpg/Event.pm index 10acbb9..ae6412e 100644 --- a/Irpg/Event.pm +++ b/Irpg/Event.pm @@ -302,13 +302,13 @@ sub godsend { # bless the unworthy } sub evilness { - my @evil = grep { $rps->{$_}{alignment} eq "e" && + my @evil = grep { $rps->{$_}{alignment} eq 'Evil' && $rps->{$_}{online} } keys(%$rps); return unless @evil; my $me = $evil[rand(@evil)]; if (int(rand(2)) < 1) { # evil only steals from good :^( - my @good = grep { $rps->{$_}{alignment} eq "g" && + my @good = grep { $rps->{$_}{alignment} eq 'Good' && $rps->{$_}{online} } keys(%$rps); my $target = $good[rand(@good)]; my @items = ("ring","amulet","charm","weapon","helm","tunic", @@ -371,7 +371,7 @@ sub evilchase { sub goodness { - my @players = grep { $rps->{$_}{alignment} eq "g" && + my @players = grep { $rps->{$_}{alignment} eq 'Good' && $rps->{$_}{online} } keys(%$rps); return unless @players > 1; if (int(rand(2)) < 1) { @@ -404,9 +404,9 @@ sub rpcheck { my $rpreport = shift; my $online = shift; my $onlineevil = scalar(grep { $rps->{$_}{online} && - $rps->{$_}{alignment} eq "e" } keys(%$rps)); + $rps->{$_}{alignment} eq 'Evil' } keys(%$rps)); my $onlinegood = scalar(grep { $rps->{$_}{online} && - $rps->{$_}{alignment} eq "g" } keys(%$rps)); + $rps->{$_}{alignment} eq 'Good' } keys(%$rps)); if (!$opts->{noscale}) { if (rand((20*86400)/$opts->{self_clock}) < $online) { hog(); } if (rand((24*86400)/$opts->{self_clock}) < $online) { team_battle(); } diff --git a/Irpg/Main.pm b/Irpg/Main.pm index 4ff791d..4cdb1ee 100644 --- a/Irpg/Main.pm +++ b/Irpg/Main.pm @@ -236,7 +236,7 @@ sub moveplayers { # at the last move, evil users who has not fought # chase near players if ($i == $opts->{self_clock}-1 - && $rps->{$player}{alignment} == 'e' + && $rps->{$player}{alignment} == 'Evil' && !(grep { $player eq $_ } @who_fought)) { evilchase($player, \%positions); } diff --git a/Irpg/Users.pm b/Irpg/Users.pm index 7f66d5e..3f2da72 100644 --- a/Irpg/Users.pm +++ b/Irpg/Users.pm @@ -108,7 +108,7 @@ sub register { $rps->{$arg[0]}{pass} = crypt($arg[1],mksalt()); $rps->{$arg[0]}{x} = int(rand($opts->{mapx})); $rps->{$arg[0]}{y} = int(rand($opts->{mapy})); - $rps->{$arg[0]}{alignment}="n"; + $rps->{$arg[0]}{alignment}="Neutral"; $rps->{$arg[0]}{gender}="n"; $rps->{$arg[0]}{isadmin} = 0; for my $item ("ring","amulet","charm","weapon","helm", @@ -184,12 +184,9 @@ sub login { $rps->{$arg[0]}{nick} = $usernick; $rps->{$arg[0]}{userhost} = $userhost; $rps->{$arg[0]}{lastlogin} = time(); - my $almt = $rps->{$arg[0]}{alignment}; - $almt = $almt eq 'g' ? 'Good': - $almt eq 'e' ? 'Evil': - 'Neutral'; Irpg::Irc::chanmsg("$arg[0], the level $rps->{$arg[0]}{level} ". - "$rps->{$arg[0]}{title} $almt $rps->{$arg[0]}{class}->{NAME}, ". + "$rps->{$arg[0]}{alignment} $rps->{$arg[0]}{title} ". + "$rps->{$arg[0]}{class}->{NAME}, ". "is now online from nickname $usernick. Next level in ". duration($rps->{$arg[0]}{next})."."); Irpg::Irc::notice("Logon successful. Next level in ". @@ -213,21 +210,17 @@ sub status { return unless ($opts->{statuscmd}); my ($userhost, $usernick, $username, $source, @arg) = @_; my $asked = exists($arg[0]) ? $arg[0] : $username; - return unless ($asked); - my $asked_found = Irpg::Main::finduser($asked) unless (exists($rps->{$asked})); - $asked = $asked_found if ($asked_found); - $asked = Irpg::Main::finduser($asked, 1) unless ($asked_found); + + $asked = Irpg::Main::finduser($asked) unless (exists($rps->{$asked})); + $asked = Irpg::Main::finduser($asked, 1) unless ($asked); if (!$asked) { Irpg::Irc::privmsg("No matching user found.",$source); } else { - my $almt = $rps->{$asked}{alignment}; - $almt = $almt eq 'g' ? 'Good': - $almt eq 'e' ? 'Evil': - 'Neutral'; Irpg::Irc::privmsg("$asked: Level $rps->{$asked}{level} ". - "$rps->{$asked}{title} $almt $rps->{$asked}{class}->{NAME}; ". + "$rps->{$asked}{alignment} $rps->{$asked}{title} ". + "$rps->{$asked}{class}->{NAME}; ". "Status: O".($rps->{$asked}{online}?"n":"ff")."line; ". "TTL: ".duration($rps->{$asked}{next})."; ". "Idled: ".duration($rps->{$asked}{idled})."; ". @@ -243,13 +236,10 @@ sub whoami { Irpg::Irc::notice("You are not logged in.", $usernick); } else { - my $almt = $rps->{$username}{alignment}; - $almt = $almt eq 'g' ? 'Good': - $almt eq 'e' ? 'Evil': - 'Neutral'; Irpg::Irc::privmsg("You are $username, the level ". - "$rps->{$username}{level} $rps->{$username}{title} ". - "$almt $rps->{$username}{class}->{NAME}. You have ". + "$rps->{$username}{level} $rps->{$username}{alignment} ". + "$rps->{$username}{title} ". + "$rps->{$username}{class}->{NAME}. You have ". "$rps->{$username}{points} point(s) available, and ". "$rps->{$username}{actions} action(s) you can trigger. ". "Next level in ".duration($rps->{$username}{next}), @@ -281,11 +271,12 @@ sub align { Irpg::Irc::notice("Try: ALIGN <good|neutral|evil>", $usernick); } else { - $rps->{$username}{alignment} = substr(lc($arg[0]),0,1); - Irpg::Irc::chanmsg("$username has changed alignment to: ".lc($arg[0]). - "."); - Irpg::Irc::privmsg("Your alignment was changed to ".lc($arg[0]).".", - $source); + $rps->{$username}{alignment} = substr(uc($arg[0]),0,1). + substr(lc($arg[0]),1,length $arg[0]); + Irpg::Irc::chanmsg("$username has changed alignment to: ". + "$rps->{$username}{alignment}."); + Irpg::Irc::privmsg("Your alignment was changed to ". + "$rps->{$username}{alignment}.", $source); Irpg::Main::penalize($username,"align"); } } diff --git a/Irpg/Utils.pm b/Irpg/Utils.pm index 8718775..6f77e69 100644 --- a/Irpg/Utils.pm +++ b/Irpg/Utils.pm @@ -470,7 +470,7 @@ sub createdb { $rps{$uname}{lastlogin} = time(); $rps{$uname}{x} = int(rand($opts->{mapx})); $rps{$uname}{y} = int(rand($opts->{mapy})); - $rps{$uname}{alignment}="n"; + $rps{$uname}{alignment}='Neutral'; $rps{$uname}{gender}="n"; $rps{$uname}{isadmin} = 1; for my $item ("ring","amulet","charm","weapon","helm", -- GitLab