Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Artificer Spells Known #273

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/cljc/orcpub/dnd/e5/classes.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -1737,6 +1737,18 @@
17 1
19 1})

(def artificer-spells-known-schedule
{1 2
3 1
5 1
7 1
9 1
11 1
13 1
15 1
17 1
19 1})

(def full-caster-spells-known-schedule
{1 2
2 1
Expand Down
23 changes: 18 additions & 5 deletions src/cljc/orcpub/dnd/e5/options.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,8 @@
:max (or max num)
:tags #{:spells}})))

(defn spell-slot-schedule [level-factor]
(case level-factor
(defn spell-slot-schedule [slot-factor]
(case slot-factor
1 {1 {1 2}
2 {1 1}
3 {1 1
Expand Down Expand Up @@ -523,10 +523,22 @@
13 {3 2}
16 {3 1}
19 {4 1}}
4 {1 {1 2}
3 {1 1}
5 {1 1
2 2}
7 {2 1}
9 {3 2}
11 {3 1}
13 {4 1}
15 {4 1}
17 {4 1
5 1}
19 {5 1}}
{}))

(defn total-slots [level level-factor]
(let [schedule (spell-slot-schedule level-factor)]
(defn total-slots [level slot-factor]
(let [schedule (spell-slot-schedule slot-factor)]
(reduce
(fn [m lvl]
(merge-with + m (schedule lvl)))
Expand Down Expand Up @@ -594,12 +606,13 @@
known-mode
spells
ability
slot-factor
slot-schedule] :as cfg}
cls-cfg]
(reduce
(fn [m [cls-lvl v]]
(let [[num restriction] (if (number? v) [v] ((juxt :num :restriction) v))
slots (or (if slot-schedule (slot-schedule cls-lvl)) (total-slots cls-lvl level-factor))
slots (or (if slot-schedule (slot-schedule cls-lvl)) (total-slots cls-lvl slot-factor))
all-spells (select-keys
(or spells (spell-lists (or spell-list-kw class-key)))
(keys slots))
Expand Down
7 changes: 4 additions & 3 deletions src/cljs/orcpub/dnd/e5/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2505,10 +2505,11 @@
(reg-event-db
::class5e/set-class-path-prop
class-interceptors
(fn [class [_ prop-path prop-value prop-path-2 prop-value-2]]
(fn [class [_ prop-path-1 prop-value-1 prop-path-2 prop-value-2 prop-path-3 prop-value-3]]
(-> class
(assoc-in prop-path prop-value)
(assoc-in prop-path-2 prop-value-2))))
(assoc-in prop-path-1 prop-value-1)
(assoc-in prop-path-2 prop-value-2)
(assoc-in prop-path-3 prop-value-3))))

(reg-event-db
::selections5e/set-selection-path-prop
Expand Down
32 changes: 22 additions & 10 deletions src/cljs/orcpub/dnd/e5/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5408,10 +5408,11 @@
:on-change #(dispatch [::classes/set-class-prop
:spellcasting
(if (= "true" %)
{:level-factor 3
{:level-factor 1
:slot-factor 1
:known-mode :schedule
:ability ::char/cha
:spells-known classes/third-caster-spells-known-schedule})])}]
:spells-known classes/full-caster-spells-known-schedule})])}]
(if spellcaster?
[:div.m-l-5
[labeled-dropdown
Expand Down Expand Up @@ -5445,17 +5446,28 @@
[:div.m-l-5
[labeled-dropdown
"At what level does this class first gain spell slots?"
{:items (map
value-to-item
(range 1 4))
:value (get-in class [:spellcasting :level-factor] 1)
:on-change #(let [level-factor (js/parseInt %)]
{:items [{:title "1 - Full Caster"
:value 1}
{:title "2 - Half Caster"
:value 2}
{:title "3 - Third Caster"
:value 3}
{:title "2 - Artificer"
:value 4}]
:value (get-in class [:spellcasting :slot-factor] 1)
:on-change #(let [slot-factor (js/parseInt %)]
(dispatch [::classes/set-class-path-prop
[:spellcasting :level-factor] level-factor
[:spellcasting :spells-known] (case level-factor
[:spellcasting :slot-factor] slot-factor
[:spellcasting :spells-known] (case slot-factor
1 classes/full-caster-spells-known-schedule
2 classes/half-caster-spells-known-schedule
3 classes/third-caster-spells-known-schedule)]))}]])]
3 classes/third-caster-spells-known-schedule
4 classes/artificer-spells-known-schedule)
[:spellcasting :level-factor] (case slot-factor
1 1
2 2
3 3
4 2)]))}]])]
(if (and spellcaster?
(not (get-in class [:spellcasting :spell-list-kw])))
(let [cantrips? (get-in class [:spellcasting :cantrips?])]
Expand Down