Skip to content
Merged
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
27 changes: 14 additions & 13 deletions src/cljs/orcpub/character_builder.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,17 @@
(defn character-textarea [entity-values prop-name & [cls-str]]
[character-field-50000 entity-values prop-name :textarea cls-str])

(defn prereq-failures [option]
(remove
nil?
(map
(fn [{:keys [::t/prereq-fn ::t/label] :as prereq}]
(if prereq-fn
(when (not (prereq-fn))
label)
(js/console.warn "NO PREREQ_FN" (::t/name option) prereq)))
(::t/prereqs option))))
(defn prereq-failures [option built-char]
(when built-char
(remove
nil?
(map
(fn [{:keys [::t/prereq-fn ::t/label] :as prereq}]
(if prereq-fn
(when (not (prereq-fn built-char))
label)
(js/console.warn "NO PREREQ_FN" (::t/name option) prereq)))
(::t/prereqs option)))))

(defn set-class-fn [i options-map]
(fn [e] (let [new-key (keyword (.. e -target -value))]
Expand Down Expand Up @@ -195,7 +196,7 @@

(defn class-level-selector []
(let [expanded? (r/atom false)]
(fn [i key selected-class options unselected-classes-set]
(fn [i key selected-class options unselected-classes-set built-char]
(let [options-map (make-options-map options)
class-template-option (options-map key)
path [:class-levels key]]
Expand All @@ -208,7 +209,7 @@
(doall
(map
(fn [{:keys [::t/key ::t/name] :as option}]
(let [failed-prereqs (when (pos? i) (prereq-failures option))]
(let [failed-prereqs (when (pos? i) (prereq-failures option built-char))]
^{:key key}
[:option.builder-dropdown-item
{:value key
Expand Down Expand Up @@ -285,7 +286,7 @@
(map-indexed
(fn [i [key selected-class]]
^{:key key}
[class-level-selector i key selected-class (map class-level-data options) unselected-classes-set])
[class-level-selector i key selected-class (map class-level-data options) unselected-classes-set built-char])
selected-classes))]
(when (seq remaining-classes)
[:div.orange.p-5.underline.pointer
Expand Down
24 changes: 20 additions & 4 deletions src/cljs/orcpub/dnd/e5/content_reconciliation.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,25 @@

(def ^:private builtin-races
#{:dwarf :elf :halfling :human :dragonborn :gnome
:half-elf :half-orc :tiefling :hill-dwarf :mountain-dwarf
:high-elf :wood-elf :drow :lightfoot :stout :forest-gnome
:rock-gnome})
:half-elf :half-orc :tiefling})

;; Built-in subraces: PHB subrace keys auto-generated from their names via
;; common/name-to-kw. Human cultural variants (Calishite etc.) are defined
;; in spell_subs.cljs with only :name, so their keys are derived from the name.
(def ^:private builtin-subraces
#{;; Dwarf
:hill-dwarf :mountain-dwarf
;; Elf
:high-elf :wood-elf :drow
;; Halfling
:lightfoot :stout
;; Gnome
:forest-gnome :rock-gnome
;; Human cultural variants (spell_subs.cljs human-option-cfg :subraces)
:calishite :chondathan :damaran :illuskan
:mulan :rashemi :shou :tethyrian :turami
;; Human variant selection options
:standard-human :variant-human})

;; Only Acolyte is hardcoded (spell_subs.cljs:538).
(def ^:private builtin-backgrounds #{:acolyte})
Expand All @@ -188,7 +204,7 @@
:class (contains? builtin-classes k)
:subclass (contains? builtin-subclasses k)
:race (contains? builtin-races k)
:subrace (contains? builtin-races k)
:subrace (contains? builtin-subraces k)
:background (contains? builtin-backgrounds k)
:feat (contains? builtin-feats k)
false))
Expand Down
Loading