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 df64db50634e4b5b165db0c7fd8d92cfd3a5a409..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; } @@ -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) { diff --git a/Irpg/Users.pm b/Irpg/Users.pm index b50182bc508526a4fdc11a34b3c3799e8acf981d..cf8e5e5cf324aafd08b0dc46458823f94dde91d5 100644 --- a/Irpg/Users.pm +++ b/Irpg/Users.pm @@ -382,20 +382,40 @@ sub points { sub class { 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 if (!defined($username)) { Irpg::Irc::notice("You are not logged in.", $usernick); return; } - elsif (!$cname) { - $cname = $rps->{$username}{class}->{NAME}; + 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}; 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); + join(', ', map { uc($_)." ".eval('$rps->{$asked}{class}->'.$_.'()') } + keys($rps->{$asked}{stats})).".", $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 + if (!defined($username)) { + Irpg::Irc::notice("You are not logged in.", $usernick); + return; + } + elsif (!$cname) { + Irpg::Irc::notice("Try: CHCLASS <class name>", $usernick); + return + } my @classes; foreach (<Irpg/Classes/*.pm>) { s/Irpg\/Classes\/(\w+)\.pm/$1/; @@ -480,15 +500,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/^.*\///;