Skip to content

Commit

Permalink
Fixes Issue Orcpub#249, Fixes Orcpub#514;
Browse files Browse the repository at this point in the history
* Fixed Dueling style not applying +2 bonus to one handed melee weapons.
    + Properly checks for weapons in only one hand
    + Properly only applies to non-two handed melee weapons

* Commented out melee- and ranged- specific damage bonus methods. Weird front end issues occurred when `apply` was... applied to those maps plus the map for the generic `damage-bonus-fns`
    * Properly utilizing the passed functions and conditions should eliminate the need for those other two methods.

* Fixed Bracers of Archery applying attack bonus instead of damage bonus
    * Added new method `weapon-damage-bonus-mod` which duplicates almost all the code from `weapon-attack-bonus-mod`. Combining them may be worthwhile, using a third parameter to set which bonus we want, or even both.
  • Loading branch information
codeGlaze committed Feb 28, 2021
1 parent db48dc8 commit 8a7ccce
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/cljc/orcpub/dnd/e5/magic_items.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ The bowl is about 1 foot in diameter and half as deep. It weighs 3 pounds and ho
::attunement [:any]
::modifiers [(mod5e/weapon-proficiency :longbow)
(mod5e/weapon-proficiency :shortbow)
(mod5e/weapon-attack-bonus-mod #{:longbow :shortbow} 2)]
(mod5e/weapon-damage-bonus-mod #{:longbow :shortbow} 2)]
::description "While wearing these bracers, you have proficiency with the longbow and shortbow, and you gain a +2 bonus to damage rolls on ranged attacks made with such weapons."
}{
name-key "Bracers of Defense"
Expand Down
22 changes: 20 additions & 2 deletions src/cljc/orcpub/dnd/e5/modifiers.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,13 @@
(defn attack-modifier-fn [bonus-fn]
(mods/vec-mod ?attack-modifier-fns bonus-fn))

(defn
^{:doc "For applying generic damage bonuses from various sources, to various sources. Controlled by functions to filter or specify conditions"
:user/comment "May be best to keep this and remove melee-damage-bonus-fn (and never add the ranged-damage-bonus-fn). Undecided."}

damage-bonus-fn [bonus-fn]
(mods/vec-mod ?damage-bonus-fns bonus-fn))

(defn melee-damage-bonus-fn [bonus-fn]
(mods/vec-mod ?melee-damage-bonus-fns bonus-fn))

Expand Down Expand Up @@ -590,8 +597,8 @@
`(condp <= ~level ~@flat-mappings)))

(defn
^{:doc "Function that allows application of bonuses to specific weapons."
:user/comment "Moved from commented-out UA namespace."}
^{:doc "Function that allows application of attack modifiers to specific weapons."
:user/comment "Moved from a disused, soon to be trimmed, namespace."}

weapon-attack-bonus-mod [weapons bonus]
(attack-modifier-fn
Expand All @@ -600,6 +607,17 @@
bonus
0))))

(defn
^{:doc "Function that allows application of damage bonuses to specific weapons."
:user/comment "Duplicated from weapon-attack-bonus-mod. May be better to combine the two with a third arg to differentiate"}

weapon-damage-bonus-mod [weapons bonus]
(damage-bonus-fn
(fn [{kw :key base-kw :base-key}]
(if (weapons kw)
bonus
0))))

(def mods-map
{:ability ability
:ability-override ability-override
Expand Down
7 changes: 3 additions & 4 deletions src/cljc/orcpub/dnd/e5/options.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -1706,10 +1706,9 @@
{:name "Dueling Fighting Style"
:page 72
:description "When you are wielding a melee weapon in one hand and no other weapons, you gain a +2 bonus to damage rolls with that weapon."})
;(mods/vec-mod ?ac-bonus-fns
;(mods/vec-mod ?attack-modifier-fns
(mods/vec-mod ?melee-damage-bonus-fns ;vec-mod prop
(fn [_ _] 5) ;vec-mod val ... maybe?
(mods/vec-mod ?damage-bonus-fns ;vec-mod prop
(fn [weapon _] (if (or (weapon ::weapons/two-handed?)
(weapon ::weapons/ranged?)) 0 2)) ;vec-mod val ... maybe?
nil ;vec-mod nm
nil ;vec-mod value ... maybe?
[(let [main-hand-weapon ?orcpub.dnd.e5.character/main-hand-weapon
Expand Down
18 changes: 10 additions & 8 deletions src/cljc/orcpub/dnd/e5/template_base.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,16 @@
(apply +
(+ (or (::mi5e/magical-damage-bonus weapon) 0)
(?weapon-ability-damage-modifier weapon definitely-finesse? off-hand?))
(if melee?
(map
#(% weapon)
?melee-damage-bonus-fns)
(map
#(% weapon)
?ranged-damage-bonus-fns)) ;any non-melee is assumed to be ranged/finesse/dex
)))
;(if melee?
; (map
; #(% weapon)
; ?melee-damage-bonus-fns)
; (map
; #(% weapon)
; ?ranged-damage-bonus-fns)) ;any non-melee is assumed to be ranged/finesse/dex
(map
#(% weapon)
?damage-bonus-fns))))
?best-weapon-damage-modifier (fn [weapon & [off-hand?]]
(max (?weapon-damage-modifier weapon false off-hand?)
(?weapon-damage-modifier weapon true off-hand?)))
Expand Down

0 comments on commit 8a7ccce

Please sign in to comment.