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 | |
| parent | e032790aec01f9893dfd094feb30f0555a307a32 (diff) | |
added anti weapon ability and corrected wounds logic
| -rw-r--r-- | src/votann_battle_simulator/battle_round.clj | 8 | ||||
| -rw-r--r-- | src/votann_battle_simulator/weapon_abilities.clj | 24 |
2 files changed, 28 insertions, 4 deletions
diff --git a/src/votann_battle_simulator/battle_round.clj b/src/votann_battle_simulator/battle_round.clj index b351faa..1e7806a 100644 --- a/src/votann_battle_simulator/battle_round.clj +++ b/src/votann_battle_simulator/battle_round.clj @@ -26,18 +26,20 @@ (filter #(>= % 6) rolls)))) (defn resolve-saving-throw-roll [rolls ap save] - (vec (filter #(< % (+ ap save)) rolls))) + (let [saves (vec (filter #(< % (+ ap save)) rolls))] + (println (str "ap: -" ap " sv: " save " Saves before " rolls " after " saves)) + saves)) (defn resolve-damage [^Integer unit-size ^Weapon weapon ^Integer target-size ^Model target battle-modifiers] (let [rolls (util/roll-d6 (weapon-abilities/resolve-attack-abilities weapon unit-size target-size)) rolls (weapon-abilities/resolve-hit-dice-abilities weapon rolls) rolls (weapon-abilities/resolve-hit-modifier-abilities weapon (:hit battle-modifiers) rolls) hits (resolve-hit-roll rolls (:bs weapon)) - wounds (weapon-abilities/resolve-wound-dice-abilites weapon (util/roll-d6 (count hits)) (:s weapon) (:t target)) + wounds (weapon-abilities/resolve-wound-dice-abilites weapon (util/roll-d6 (count hits)) (:s weapon) (:t target) (:model (:keywords target))) mortal-wounds (count (filter #(= 99 %) wounds)) wounds (vec (filter #(not= 99 %) wounds)) wounds (weapon-abilities/resolve-wound-modifier-abilites weapon (:wound battle-modifiers) wounds) - wounds (resolve-wound-roll (util/roll-d6 (count wounds)) (:s weapon) (:t target)) + wounds (resolve-wound-roll wounds (:s weapon) (:t target)) non-saves (count (resolve-saving-throw-roll (util/roll-d6 (count wounds)) (:ap weapon) (:sv target))) damage (* (util/resolve-stat-count (:d weapon)) (+ mortal-wounds non-saves))] damage)) 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)) |