From 152d50449f14ff6a71abec26f7712f810af5f7a2 Mon Sep 17 00:00:00 2001
From: ElTata <eltata@firemail.cc>
Date: Tue, 7 Jul 2020 14:17:42 +0200
Subject: [PATCH] improvement: lighter mystic time transfers

The percentage computed for a mystic fight is applied
on the attacker TTL AND defensor TTL, not anymore only
on the attacker's.
---
 Irpg/Action.pm | 40 +++++++++++++++++++++++-----------------
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/Irpg/Action.pm b/Irpg/Action.pm
index 831c981..1a0757c 100644
--- a/Irpg/Action.pm
+++ b/Irpg/Action.pm
@@ -144,19 +144,22 @@ sub mystic_result {
     if ($win) {
         #my $gain = int($rps->{$p2}{level}/8);
         #$gain = 5 if $gain < 5;
-        my $gain = perc_victory($rps->{$p2}{level} - $rps->{$p1}{level})*0.60;
-        $gain *= 1.2 if ($wanted);
-        $gain = int(($gain/100)*$rps->{$p1}{next});
-        $gain = -$rps->{$p1}{class}->real_gain(-$gain);
-        $rps->{$p1}{next} = $gain >= $rps->{$p1}{next} ? 0 : $rps->{$p1}{next} - $gain;
-        $rps->{$p2}{next} += $gain;
+        my $perc = perc_victory($rps->{$p2}{level} - $rps->{$p1}{level})*0.60;
+        $perc *= 1.2 if ($wanted);
+        my $gain_p1 = int(($perc/100)*$rps->{$p1}{next});
+        my $gain_p2 = int(($perc/100)*$rps->{$p2}{next});
+        $gain_p1 = -$rps->{$p1}{class}->real_gain(-$gain_p1);
+        $gain_p2 = -$rps->{$p2}{class}->real_gain(-$gain_p2);
+        $rps->{$p1}{next} = $gain_p1 >= $rps->{$p1}{next} ?
+                            0 : $rps->{$p1}{next} - $gain_p1;
+        $rps->{$p2}{next} += $gain_p2;
         push(@queue,
-            "$p1 transfers ".duration($gain)." from ".
-            pronoun(2, $rps->{$p1}{gender})." clock to $p2\'s. ".
+            "$p1 compresses ".duration($gain_p1)." from ".pronoun(2, $rps->{$p1}{gender}).
+            " clock to ".duration($gain_p2)." for $p2\'s. ".
             "$p1 reaches next level in\x033 ".duration($rps->{$p1}{next})."\x03. ".
             "$p2 reaches next level in\x035 ".duration($rps->{$p2}{next})."\x03.");
         if ($win == 2) {
-            $gain = int(0.05*$rps->{$p1}{next});
+            my $gain = int(0.05*$rps->{$p1}{next});
             $gain *= $rps->{$p1}{class}->{MOD_CRT};
             $gain = -$rps->{$p2}{class}->real_gain(-$gain);
             $rps->{$p1}{next} = $gain >= $rps->{$p1}{next} ? 0 : $rps->{$p1}{next} - $gain;
@@ -170,15 +173,18 @@ sub mystic_result {
     else {
         #my $gain = $rps->{$p2}{level}/10;
         #$gain = 5 if $gain < 5;
-        my $gain = perc_defeat($rps->{$p2}{level} - $rps->{$p1}{level})*0.60;
-        $gain *= 1.2 if ($wanted);
-        $gain = int(($gain/100)*$rps->{$p1}{next});
-        $gain = $rps->{$p1}{class}->real_gain($gain);
-        $rps->{$p1}{next} += $gain;
-        $rps->{$p2}{next} = $gain >= $rps->{$p2}{next} ? 0 : $rps->{$p2}{next} - $gain;
+        my $perc = perc_defeat($rps->{$p2}{level} - $rps->{$p1}{level})*0.60;
+        $perc *= 1.2 if ($wanted);
+        my $gain_p1 = int(($perc/100)*$rps->{$p1}{next});
+        my $gain_p2 = int(($perc/100)*$rps->{$p2}{next});
+        $gain_p1 = $rps->{$p1}{class}->real_gain($gain_p1);
+        $gain_p2 = $rps->{$p2}{class}->real_gain($gain_p2);
+        $rps->{$p1}{next} += $gain_p1;
+        $rps->{$p2}{next} = $gain_p2 >= $rps->{$p2}{next} ?
+                            0 : $rps->{$p2}{next} - $gain_p2;
         push(@queue,
-            "$p1 transfers ".duration($gain)." from ".
-            "${p2}'s clock to ".pronoun(2, $rps->{$p1}{gender})." own. ".
+            "$p1 expands ".duration($gain_p2)." from ${p2}'s clock to ".
+            duration($gain_p1)." on ".pronoun(2, $rps->{$p1}{gender})." own. ".
             "$p1 reaches next level in\x035 ".duration($rps->{$p1}{next})."\x03. ".
             "$p2 reaches next level in\x033 ".duration($rps->{$p2}{next})."\x03.");
     }
-- 
GitLab