diff --git a/CHANGELOG.md b/CHANGELOG.md index 828e6a342a4ee47e92a820be2f7a04f625e92934..894e38e14f483a0979c93ddc6217a77fdbfcfb44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,15 @@ Thanks for your interest in the Idle RPG! Feel free to contact me with ideas and comments, or post them in the issues of the project for public view. +-- +## v5.1.0: released 10/22/19 + +- CLASS function only return info about a player +- new function CHCLASS to change class +- no more immediate new action +- some texts corrections +- calculs in actions are rounded, not truncated + -- ## v5.0.1: released 10/21/19 new classes and bugfixes diff --git a/Irpg/Action.pm b/Irpg/Action.pm index dbacf78ebd1dd98bf31b752a80f8d7e6f4a07fe5..47e3fb28ad601c8987a071525132344b0b5ce96b 100644 --- a/Irpg/Action.pm +++ b/Irpg/Action.pm @@ -48,10 +48,10 @@ 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 'Evil' ? int($sum*.9) : - $rps->{$user}{alignment} eq 'Good' ? int($sum*1.1) : + $sum = $rps->{$user}{alignment} eq 'Evil' ? int(0.5+$sum*.9) : + $rps->{$user}{alignment} eq 'Good' ? int(0.5+$sum*1.1) : $sum; - return $rps->{$user}{class}->real_sum($sum); + return int(0.5 + $rps->{$user}{class}->real_sum($sum)); } return $sum; } @@ -144,7 +144,7 @@ sub mystic_result { $rps->{$p2}{next} -= $gain; push(@queue, "$p1 transfers ".duration($gain)." from ". - "${p2}'s clock to ".pronoun(2, $rps->{$p1}{gender})." own.". + "${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})."."); } @@ -238,17 +238,17 @@ sub perform_action { my $p2def = eval '$rps->{$p2}{class}->'.$action_type.'_def()'; my $p1sum = itemsum($p1,1); my $p2sum = itemsum($p2,1); - my $p1roll = int(rand($p1sum) * $p1atk); - my $p2roll = int(rand($p2sum) * $p2def); + my $p1roll = int(0.5 + rand($p1sum) * $p1atk); + my $p2roll = int(0.5 + rand($p2sum) * $p2def); my $ret; if ($p1roll < 5 || $p2roll < 5 || $p1sum < 5 || $p2roll < 5) { - $ret = {p1sum=>int($p1sum), p2sum=>int($p2sum), - p1roll=>int($p1roll), p2roll=>int($p2roll), + $ret = {p1sum=>$p1sum, p2sum=>$p2sum, + p1roll=>$p1roll, p2roll=>$p2roll, vict=>0}; } else { - $ret = {p1sum=>int($p1sum/5), p2sum=>int($p2sum/5), - p1roll=>int($p1roll/5), p2roll=>int($p2roll/5), + $ret = {p1sum=>int(0.5+$p1sum/5), p2sum=>int(0.5+$p2sum/5), + p1roll=>int(0.5+$p1roll/5), p2roll=>int(0.5+$p2roll/5), vict=>0}; } if ($p1roll >= $p2roll) { @@ -450,6 +450,7 @@ sub do_action { $p2 = $opps[int(rand(@opps))]; } $rps->{$username}{actions}--; + $rps->{$username}{next_a} = 3600 unless ($rps->{$username}{next_a}); my $p1 = $username; my $action_type = choose_action($p1); my $ret_action = perform_action($p1, $p2, $action_type); diff --git a/Irpg/Main.pm b/Irpg/Main.pm index cc631e9a331c7bccebf2ef59ae66023a02be49a6..4659e70bd21f88b145c9016059210b1090ee3104 100644 --- a/Irpg/Main.pm +++ b/Irpg/Main.pm @@ -277,7 +277,9 @@ sub rpcheck { # check levels, update database for my $i (0..2) { $#u >= $i and Irpg::Irc::chanmsg("$u[$i], the level $rps->{$u[$i]}{level} ". - "$rps->{$u[$i]}{title}, is #" . ($i + 1) . "! Next level in ". + "$rps->{$u[$i]}{alignment} $rps->{$u[$i]}{title} ". + "$rps->{$u[$i]}{class}->{NAME}, is #". + ($i + 1) . "! Next level in ". (duration($rps->{$u[$i]}{next}))."."); } backup($opts); @@ -331,17 +333,19 @@ sub rpcheck { # check levels, update database $rps->{$k}{next} = int($opts->{rpbase} * ($opts->{rpstep}**$rps->{$k}{level})); } - Irpg::Irc::chanmsg("$k, the $rps->{$k}{title} ". - "$rps->{$k}{class}->{NAME}, has attained level ". - "$rps->{$k}{level}! Next level in ". - duration($rps->{$k}{next})."."); + Irpg::Irc::chanmsg("$k, the $rps->{$k}{alignment} ". + "$rps->{$k}{title} $rps->{$k}{class}->{NAME}, ". + "has attained level $rps->{$k}{level}! ". + "Next level in ".duration($rps->{$k}{next})."."); find_item($k); challenge_opp($k); } if ($rps->{$k}{next_a} < 1 && $rps->{$k}{actions} < int($rps->{$k}{level}/10)) { $rps->{$k}{actions}++; - $rps->{$k}{next_a} = 3600; # 1 hour + if ($rps->{$k}{actions} < int($rps->{$k}{level}/10)) { + $rps->{$k}{next_a} = 3600 + } Irpg::Irc::notice("You feel ready to perform a new deed !", $rps->{$k}{nick}); } diff --git a/Irpg/Users.pm b/Irpg/Users.pm index 3f2da72b61b57a23f44c32151240d4935c016136..4b7592c8155ded94d50a4c2cc597f74cf616ca75 100644 --- a/Irpg/Users.pm +++ b/Irpg/Users.pm @@ -357,7 +357,7 @@ sub points { if (!@arg) { Irpg::Irc::privmsg("Your raw competences are the following: ". join(', ', map { uc($_)." $rps->{$username}{stats}{$_}" } - keys($rps->{$username}{stats})).".", $source); + qw(str con int wis cha dex)).".", $source); return; } if (@arg != 2 || $arg[1] !~ m/^\d+$/) { @@ -370,7 +370,7 @@ sub points { Irpg::Irc::privmsg("You do not have that much points to spend.", $source); return; } - if (!grep { $stat } qw(str con wis int cha dex)) { + if (!grep { $_ eq $stat } qw(str con wis int cha dex)) { Irpg::Irc::privmsg("'$stat' is not a valid stat name.", $source); return } @@ -381,6 +381,31 @@ sub points { } sub class { + my ($userhost, $usernick, $username, $source, @arg) = @_; + if (!defined($username)) { + Irpg::Irc::notice("You are not logged in.", $usernick); + return; + } + my $asked = exists($arg[0]) ? $arg[0] : $username; + + $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 $cname = $rps->{$asked}{class}->{NAME}; + my $who = $asked eq $username ? 'You are' : "$asked is"; + Irpg::Irc::privmsg("$who a".($cname =~ m/^[AEIOUYÆŒ].*/ ? 'n':''). + " $cname with the following stats: ". + join(', ', map { uc($_)." ".eval('$rps->{$asked}{class}->'.$_.'()') } + qw(str con int wis cha dex)).".", $source); + return; + } +} + +sub chclass { my ($userhost, $usernick, $username, $source, @arg) = @_; my $cname = exists($arg[0]) ? lc($arg[0]) : ''; # lower case $cname =~ s/(\w)/\u$1/; # capitalize the first letter @@ -389,12 +414,8 @@ sub class { return; } elsif (!$cname) { - $cname = $rps->{$username}{class}->{NAME}; - Irpg::Irc::privmsg("You are a".($cname =~ m/^[aeiouyæœ].*/ ? 'n':''). - " $cname with the following stats: ". - join(', ', map { uc($_)." ".eval('$rps->{$username}{class}->'.$_.'()') } - keys($rps->{$username}{stats})).".", $source); - return; + Irpg::Irc::notice("Try: CHCLASS <class name>", $usernick); + return } my @classes; foreach (<Irpg/Classes/*.pm>) { @@ -480,15 +501,19 @@ our $commands = { info => {ref => \&info, adm => 0, prv => 1, pub => 0, hlp => 'INFO : get some info about the bot.'}, - points => {ref => \&points, adm => 0, prv => 1, pub => 0, + points => {ref => \&points, adm => 0, prv => 1, pub => 1, hlp => 'POINTS [<stat> <n>] : shows your points repartition, '. 'or adds n points to your stat. '. 'stats are {str, con, wis, int, cha, dex}.'}, class => {ref => \&class, adm => 0, prv => 1, pub => 1, - hlp => 'CLASS [<class name>]: gives your class info, '. - 'or tries to change your class. Changing class cost '. - 'the TTL of your level.'} + hlp => 'CLASS [<usernick>|<char name>]: gives the class info '. + 'of a character, or of a usernick\'s character. '. + 'Yours by default.'}, + + chclass => {ref => \&chclass, adm => 0, prv => 1, pub => 1, + hlp => 'CHCLASS <class name>: apply for a new class membership. '. + 'Changing class cost the TTL of your level.'} }; 1; diff --git a/irpg_bot.pl b/irpg_bot.pl index 0a13767c8696d202274e69123e308cd3a1ad40b5..dcbf7b3c334744a54c4f65efd5ad0081931dc62f 100644 --- a/irpg_bot.pl +++ b/irpg_bot.pl @@ -38,7 +38,7 @@ use Irpg::Main; my $opts = readconfig(); -my $version = "4.0.0"; +my $version = "5.1.0"; sub help { # print help message (my $prog = $0) =~ s/^.*\///;