From 9fa53d2d9dedc2af0c062bca2ad07f3d626dd6c3 Mon Sep 17 00:00:00 2001
From: Malin Freeborn <malinfreeborn@posteo.net>
Date: Fri, 3 May 2024 18:56:32 +0200
Subject: [PATCH] refactor statblock wounds

---
 docs.tex  |  6 ++++--
 stats.sty | 11 ++++++++---
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/docs.tex b/docs.tex
index 251ba179..5225712c 100644
--- a/docs.tex
+++ b/docs.tex
@@ -69,6 +69,7 @@ Individual characters can be created by using the \verb"\npc" command then the \
 
 \end{verbatim}
 
+\set{wounds}{1}
 
 \Person{\npc{\M}{Alice}}%
   {{0}{1}{-1}}% BODY
@@ -78,13 +79,14 @@ Individual characters can be created by using the \verb"\npc" command then the \
     \set{Academics}{1}
     \set{Wyldcrafting}{1}
     %\greatsword
-    \longsword
-    \completeleather
+    \shortsword
   }% SKILLS
   {}% KNACKS
   {\rations, \lootSmall}% EQUIPMENT
   {}% ABILITIES
 
+free: \arabic{freeHP}
+
 \showNumbers
 
 \subsubsection{Bestiary with monstrous ghouls, and ghoulish monsters}
diff --git a/stats.sty b/stats.sty
index 19fc3236..cf4b157d 100644
--- a/stats.sty
+++ b/stats.sty
@@ -230,9 +230,10 @@
 
 \newcounter{wounds}
 \setcounter{wounds}{0}
+\newcounter{freeHP}
+\setcounter{freeHP}{0}
 
 \newcommand\boxStat[1]{%
-  \addtocounter{#1}{-\value{wounds}}%
   \Repeat{\value{wounds}}{\CheckedBox}%
   \Repeat{\value{#1}}{\Square}%
 }
@@ -242,7 +243,7 @@
   \hiderowcolors%
     HP \arabic{hp}~%
     \Repeat{\value{noAppearing}}{%
-    \boxStat{hp} \\%
+    \boxStat{freeHP} \\%
     }%
   \end{tabular}%
 }
@@ -794,7 +795,7 @@
 \newcommand\computeStats{
   \setcounter{hp}{6}%
   \addtocounter{hp}{\value{Strength}}%
-  \addtocounter{hp}{\value{wounds}}%
+  \addtocounter{hp}{-\value{wounds}}%
   % Stats for allies don't need to show Combat +1 as 'TN 8 to hit', they just need to show '+1'.
   \ifnum\value{weaponBonus}>0\set{att}{Combat}\else\set{att}{Brawl}\fi%
   \addtocounter{att}{\value{Dexterity}}%
@@ -841,6 +842,10 @@
   \ifnum\value{weight}>\value{hp}%
     \addtocounter{encumbrance}{\value{weight}}%
     \addtocounter{encumbrance}{-\value{hp}}%
+    \setcounter{freeHP}{0}%
+  \else%
+    \setcounter{freeHP}{\value{hp}}%
+    \addtocounter{freeHP}{-\value{weight}}%
   \fi%
   \addtocounter{ap}{-\value{encumbrance}}%
   \addtocounter{toHit}{-\value{encumbrance}}%
-- 
GitLab