diff options
| author | 0xNul <57599792+0xNul@users.noreply.github.com> | 2023-07-24 18:16:15 -0700 |
|---|---|---|
| committer | 0xNul <57599792+0xNul@users.noreply.github.com> | 2023-07-24 18:16:15 -0700 |
| commit | 67f18732cf31a9779cac5d7bd6e8c14de51ff6b0 (patch) | |
| tree | 3e91ecd2d00154122002da187b852736f58e2d79 /src/votann_battle_simulator/weapon_abilities.clj | |
| parent | e032790aec01f9893dfd094feb30f0555a307a32 (diff) | |
added anti weapon ability and corrected wounds logic
Diffstat (limited to 'src/votann_battle_simulator/weapon_abilities.clj')
| -rw-r--r-- | src/votann_battle_simulator/weapon_abilities.clj | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/votann_battle_simulator/weapon_abilities.clj b/src/votann_battle_simulator/weapon_abilities.clj index 317d422..2fb681f 100644 --- a/src/votann_battle_simulator/weapon_abilities.clj +++ b/src/votann_battle_simulator/weapon_abilities.clj @@ -11,6 +11,21 @@ (println "Dice count before " dice " after " blast-added) blast-added))) +(defn resolve-anti [stat] + (let [keyword (re-find #"Anti-(\w+)" stat) + modifier (Integer/parseInt (re-find #"\d+" stat))] + {:keyword (second keyword) + :modifier modifier})) + +(defn anti [dice type target-keywords] + (let [resolved-type (resolve-anti type)] + (if (contains? (set target-keywords) (:keyword resolved-type)) + (map (fn [roll] + (if (>= roll (:modifier resolved-type)) + 6 + roll)) dice) + dice))) + (defn devastating-wounds [dice] (let [mortal-added (vec (map #(if (= 6 %) 99 @@ -137,7 +152,7 @@ (recur (rest abilities) modifier)))))) -(defn resolve-wound-dice-abilites [^Weapon weapon dice strength toughness] +(defn resolve-wound-dice-abilites [^Weapon weapon dice strength toughness keywords] (loop [abilities (:abilities weapon) dice-rolls dice modifier 0] @@ -145,6 +160,13 @@ dice-rolls (let [ability (first abilities)] (cond + (not (nil? (re-find #"Anti-" ability))) + (do + (println "Applied Anti wound ability for " (:name weapon)) + (recur (rest abilities) + (anti dice ability keywords) + modifier)) + (not (nil? (re-find #"Devastating Wounds" ability))) (do (println "Applied Devastating Wounds wound ability for " (:name weapon)) |