From 186597aa666f73007b00555cedeafc303abf3c87 Mon Sep 17 00:00:00 2001
From: Malin Freeborn <malinfreeborn@posteo.net>
Date: Sat, 28 Sep 2024 08:20:55 +0200
Subject: [PATCH] stop magic users CR getting penalized for shit attack

---
 stats.sty | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/stats.sty b/stats.sty
index 29f8915..86d549c 100644
--- a/stats.sty
+++ b/stats.sty
@@ -580,7 +580,9 @@
     }{}
     \iftoggle{genExamples}{%
       \ifnum\value{Intelligence}>-1%
-        \Glsentrytext{weight}~held~\arabic{weight},%
+        \ifnum\value{weight}>0%
+          \Glsentrytext{weight}~held~\arabic{weight},%
+        \fi%
       \fi%
     }{}
     {\hfil\small\textcolor{\pageSideColor}{\calculateXP}}%
@@ -604,15 +606,21 @@
       \multiply\value{attackXPtotal} by \value{ap}%
       \divide\value{attackXPtotal} by 50%
       \addtocounter{attackXPtotal}{-\value{heft}}%
+      \ifnum\value{mp}>0%
+        \ifnum\value{attackXPtotal}<\value{mp}%
+          \setcounter{attackXPtotal}{\value{mp}}%
+        \else%
+          \setcounter{enc}{\value{mp}}%
+          \divide\value{enc} by 2%
+          \addtocounter{attackXPtotal}{\value{enc}}%
+        \fi%
+      \fi%
       \setcounter{defenceXPtotal}{\value{hp}}%
       \multiply\value{defenceXPtotal} by \value{dr}%
       \divide\value{defenceXPtotal} by 10%
-      \setcounter{enc}{\value{mp}}%
-      \divide\value{enc} by 2%
-      \addtocounter{defenceXPtotal}{\value{enc}}%
       \addtocounter{xp}{\value{attackXPtotal}}%
       \addtocounter{xp}{\value{defenceXPtotal}}%
-      \ifnum\value{xp}<0\setcounter{xp}{0}\fi
+      \ifnum\value{xp}<0\setcounter{xp}{0}\fi%
       \glsentrytext{cr}~\arabic{xp}%
     }%
   }%
-- 
GitLab