Skip to content
Extraits de code Groupes Projets
Valider dbd751c2 rédigé par ElTata's avatar ElTata :ok_hand:
Parcourir les fichiers

new formula for physical & mystical fights

focused on the level gap, and not on level
parent d92d294f
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -2,6 +2,7 @@ package Irpg::Action;
use strict;
use warnings;
use POSIX;
use Irpg::Utils qw(:text);
use Irpg::Irc qw(:interaction);
use Exporter qw(import);
......@@ -70,13 +71,40 @@ sub choose_action {
return 'steal';
}
sub minimize {
my $x = shift;
return unless defined($x);
return 5*exp(-pow($x,2)/5000);
}
sub maximize {
my $x = shift;
return unless defined($x);
return 5+pow($x,2)/1000;
}
sub perc_defeat {
my $lvl_gap = shift;
return unless defined($lvl_gap);
return 5 if $lvl_gap == 0;
return $lvl_gap > 0 ? minimize($lvl_gap) : maximize($lvl_gap);
}
sub perc_victory {
my $lvl_gap = shift;
return unless defined($lvl_gap);
return 5 if $lvl_gap == 0;
return $lvl_gap > 0 ? maximize($lvl_gap) : minimize($lvl_gap);
}
sub fight_result {
my ($p1, $p2, $win, $wanted) = @_;
return unless $p1 && $p2 && defined($win);
my @queue = ();
if ($win) {
my $gain = int($rps->{$p2}{level}/4);
$gain = 7 if $gain < 7;
#my $gain = int($rps->{$p2}{level}/4);
#$gain = 7 if $gain < 7;
my $gain = perc_victory($rps->{$p2}{level} - $rps->{$p1}{level});
$gain *= $rps->{$p1}{class}->{MOD_CRT} if ($win == 2);
$gain *= 1.2 if ($wanted);
$gain = int(($gain/100)*$rps->{$p1}{next});
......@@ -86,8 +114,7 @@ sub fight_result {
duration($gain)." is removed from $p1\'s clock.");
if ($win == 2) {
$gain = int(0.05*$rps->{$p2}{next});
$gain = $rps->{$p2}{class}->real_gain($gain);
$rps->{$p2}{next} += $gain;
$rps->{$p2}{next} += $rps->{$p2}{class}->real_gain($gain);
push(@queue,
"$p1 has dealt $p2 a Critical Strike! ".
duration($gain)." is added to $p2\'s clock. ".
......@@ -95,8 +122,9 @@ sub fight_result {
}
}
else {
my $gain = $rps->{$p2}{level}/7;
$gain = 7 if $gain < 7;
#my $gain = $rps->{$p2}{level}/7;
#$gain = 7 if $gain < 7;
my $gain = perc_defeat($rps->{$p2}{level} - $rps->{$p1}{level});
$gain *= 1.2 if ($wanted);
$gain = int(($gain/100)*$rps->{$p1}{next});
$gain = $rps->{$p1}{class}->real_gain($gain);
......@@ -114,8 +142,9 @@ sub mystic_result {
return unless $p1 && $p2 && defined($win);
my @queue = ();
if ($win) {
my $gain = int($rps->{$p2}{level}/8);
$gain = 5 if $gain < 5;
#my $gain = int($rps->{$p2}{level}/8);
#$gain = 5 if $gain < 5;
my $gain = perc_victory($rps->{$p2}{level} - $rps->{$p1}{level})*0.70;
$gain *= 1.2 if ($wanted);
$gain = int(($gain/100)*$rps->{$p1}{next});
$gain = -$rps->{$p1}{class}->real_gain(-$gain);
......@@ -139,8 +168,9 @@ sub mystic_result {
}
}
else {
my $gain = $rps->{$p2}{level}/10;
$gain = 5 if $gain < 5;
#my $gain = $rps->{$p2}{level}/10;
#$gain = 5 if $gain < 5;
my $gain = perc_defeat($rps->{$p2}{level} - $rps->{$p1}{level})*0.70;
$gain *= 1.2 if ($wanted);
$gain = int(($gain/100)*$rps->{$p1}{next});
$gain = $rps->{$p1}{class}->real_gain($gain);
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter