From fa7999a5cb81654bfa7dedd4fd7e4478e447d905 Mon Sep 17 00:00:00 2001
From: Malin Freeborn <malinfreeborn@posteo.net>
Date: Wed, 8 Nov 2023 07:23:18 +0100
Subject: [PATCH] spell functions for range and targets

---
 magic.sty | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/magic.sty b/magic.sty
index 574157fb..419b3ea7 100644
--- a/magic.sty
+++ b/magic.sty
@@ -18,10 +18,16 @@
 \newcommand\spellSum{}
 \newcommand\spellNotes{}
 
+\newcounter{spellTargets}
+\setcounter{spellTargets}{1}
+
 \newcommand\calcSpell[7]{%
+  \togglefalse{distant}%
   \renewcommand\spellName{#1}%
   \setcounter{spellCost}{1}%
   \foreach \d in {#2}{%
+    \ifdefstring{\d}{distant}{\global\toggletrue{distant}}{\global\togglefalse{distant}}%
+    \ifdefstring{\d}{duplicated}{\global\toggletrue{duplicated}}{\global\togglefalse{duplicated}}%
     \stepcounter{spellCost}%
   }%
   \renewcommand\spellEnhancements{#2}%
@@ -30,9 +36,11 @@
   \renewcommand\spellResistance{#5}
   \renewcommand\spellSum{#6}
   \renewcommand\spellNotes{#7}
+  \setRange%
+  \foreach \x in {1,...,\arabic{spellCost}}%
+    {\multiply\value{spellTargets} by 10\addtocounter{spellTargets}{0}}
 }
 
-
 \newcommand\fullSpell{%
   \paragraph{\spellName}
 
@@ -41,14 +49,18 @@
   \spellAction~
   \spellSphere
 
-  Resisted by: \spellResistance
+  Resisted by: \spellResistance,
+  Range: \spellRange
+  \ifnum\value{spellTargets}>1%
+    , Targets: \arabic{spellTargets}
+  \fi
 
   \spellSum \ 
   \spellNotes
 }
 
 
-\newcommand\spellIndex{\index[spells]{\textbf{\spellName} Cost: \arabic{spellCost}, \spellEnhancements, \spellAction~\spellSphere Resisted by: \detokenize{\spellResistance} \spellSum \spellNotes }}
+\newcommand\spellIndex{\index[spells]{\textbf{\spellName} Cost: \arabic{spellCost}, \spellEnhancements, \spellAction~\spellSphere, Range: \spellRange, \ifnum\value{spellTargets}>1 Targets: \arabic{spellTargets}, \fi Resisted by: \detokenize{\spellResistance}, \spellSum \spellNotes }}
 
 
 \newcommand\shortSpell{%
-- 
GitLab