diff --git a/.clj-kondo/config.edn b/.clj-kondo/config.edn index 4463aa8d4..1f0f82ccd 100644 --- a/.clj-kondo/config.edn +++ b/.clj-kondo/config.edn @@ -1,11 +1,46 @@ -{:linters {:shadowed-fn-param {:level :off} +{:output {:exclude-files [".*resources/public/js/compiled.*" + ".*docker/scripts/.*"]} + :linters {:shadowed-fn-param {:level :off} :shadowed-var {:level :off} - :if {:level :off} :unused-namespace {:level :off} :unused-binding {:level :off} + :missing-else-branch {:level :warning} + :clojure-lsp/unused-public-var + {:exclude [user ; REPL utilities + orcpub.styles.core/app + ;; LSP can't trace cross-file references to these — + ;; all are called from classes.cljc (live code) + orcpub.dnd.e5.options/monk-elemental-disciplines + orcpub.dnd.e5.options/spell-tags + orcpub.dnd.e5.options/potent-spellcasting + ;; Live callers exist but LSP can't trace them + orcpub.common/dissoc-in ; events.cljs + orcpub.dnd.e5.character/add-ability-namespaces ; test + ;; Cross-file refs: used in template.cljc but defined in spell_subs.cljs + orcpub.dnd.e5.spell-subs/sunlight-sensitivity + orcpub.dnd.e5.spell-subs/mask-of-the-wild-mod] + ;; re-frame event handlers are dispatched via keyword, not var reference. + ;; LSP can't connect reg-event-db registration to (dispatch [:keyword]). + :exclude-when-defined-by #{re-frame.core/reg-event-db + re-frame.core/reg-event-fx + re-frame.core/reg-sub + re-frame.core/reg-sub-raw}} + ;; garden.selectors vars are generated by macros (defselector, + ;; defpseudoclass, gen-pseudo-class-defs, etc.) at compile time. + ;; clj-kondo can't resolve macro-generated vars statically and + ;; garden doesn't ship a clj-kondo config. + :unresolved-var + {:exclude [garden.selectors + ;; errors.cljc macros behind #?(:clj) reader conditional — + ;; one kondo instance can't resolve them + orcpub.errors]} + ;; read-string is a valid cljs.core symbol that clj-kondo + ;; doesn't recognize in its ClojureScript analysis data. :unresolved-symbol {:exclude - [(clojure.core.match/match) + [read-string + (clojure.test.check.clojure-test/defspec) + (clojure.core.match/match) (cljs.core.match/match) (io.pedestal.interceptor.error/error-dispatch) (orcpub.modifiers/modifier) @@ -29,6 +64,11 @@ (orcpub.dnd.e5.modifiers/reaction) (orcpub.dnd.e5.modifiers/level-val) (orcpub.entity-spec/make-entity) - (orcpub.routes-test/with-conn)]}} - :lint-as {reagent.core/with-let clojure.core/let - hiccup.def/defhtml clojure.core/defn}} + (orcpub.routes-test/with-conn) + (orcpub.routes.folder-test/with-conn) + (user/with-db)]}} + :lint-as {reagent.core/with-let clojure.core/let + hiccup.def/defhtml clojure.core/defn + user/with-db clojure.core/let + clojure.test.check.clojure-test/defspec clojure.test/deftest} +} diff --git a/scripts/fix-missing-else.py b/scripts/fix-missing-else.py new file mode 100644 index 000000000..01fb4c47f --- /dev/null +++ b/scripts/fix-missing-else.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python3 +""" +Fix clj-kondo 'Missing else branch' warnings by replacing: + if -> when + if-let -> when-let + if-not -> when-not + +Reads kondo output from stdin, applies fixes to source files. +Usage: lein lint 2>&1 | grep 'Missing else branch' | python3 scripts/fix-missing-else.py +""" + +import sys +import re +from collections import defaultdict + +def parse_warnings(lines): + """Parse kondo output into {file: [(line, col), ...]} sorted by line desc.""" + by_file = defaultdict(list) + for line in lines: + # Format: src/clj/foo.clj:42:3: warning: Missing else branch. + m = re.match(r'^(.+?):(\d+):(\d+):', line.strip()) + if m: + by_file[m.group(1)].append((int(m.group(2)), int(m.group(3)))) + # Sort each file's locations by line descending (process bottom-up to avoid offset shifts) + for f in by_file: + by_file[f].sort(reverse=True) + return by_file + +def fix_at(source_line, col): + """Replace if/if-let/if-not with when/when-let/when-not at the given column (1-based).""" + idx = col - 1 # convert to 0-based + + # kondo column points to '(' — the 'if' token starts at idx+1 + if source_line[idx:idx+1] == '(': + idx += 1 + + rest = source_line[idx:] + + if rest.startswith('if-let'): + return source_line[:idx] + 'when-let' + source_line[idx + 6:] + elif rest.startswith('if-not'): + return source_line[:idx] + 'when-not' + source_line[idx + 6:] + elif rest.startswith('if-some'): + return source_line[:idx] + 'when-some' + source_line[idx + 7:] + elif rest.startswith('if-first'): + return source_line[:idx] + 'when-first' + source_line[idx + 8:] + elif rest.startswith('if'): + # Make sure it's standalone 'if', not 'if-' something else + after = source_line[idx + 2:idx + 3] if len(source_line) > idx + 2 else '' + if after in (' ', '\t', '\n', ''): + return source_line[:idx] + 'when' + source_line[idx + 2:] + else: + print(f" SKIP: unexpected token at col {col}: {rest[:20]}", file=sys.stderr) + return source_line + else: + print(f" SKIP: no if at col {col}: {rest[:20]}", file=sys.stderr) + return source_line + +def main(): + warnings = parse_warnings(sys.stdin) + total_fixed = 0 + total_skipped = 0 + + for filepath, locations in sorted(warnings.items()): + with open(filepath, 'r') as f: + lines = f.readlines() + + fixed = 0 + for line_num, col in locations: + if line_num > len(lines): + print(f" SKIP: {filepath}:{line_num} beyond file length", file=sys.stderr) + total_skipped += 1 + continue + + old = lines[line_num - 1] + new = fix_at(old, col) + if old != new: + lines[line_num - 1] = new + fixed += 1 + else: + total_skipped += 1 + + if fixed > 0: + with open(filepath, 'w') as f: + f.writelines(lines) + + total_fixed += fixed + print(f" {filepath}: {fixed} fixed" + (f", {len(locations) - fixed} skipped" if len(locations) > fixed else "")) + + print(f"\nTotal: {total_fixed} fixed, {total_skipped} skipped") + +if __name__ == '__main__': + main() diff --git a/src/clj/orcpub/email.clj b/src/clj/orcpub/email.clj index 8af50a0ea..cca67dad5 100644 --- a/src/clj/orcpub/email.clj +++ b/src/clj/orcpub/email.clj @@ -82,7 +82,7 @@ (str base-url (routes/path-for routes/reset-password-page-route) "?key=" reset-key))})) (defn send-error-email [context exception] - (if (not-empty (environ/env :email-errors-to)) + (when (not-empty (environ/env :email-errors-to)) (postal/send-message (email-cfg) {:from (str "OrcPub Errors <" (emailfrom) ">") :to (str (environ/env :email-errors-to)) diff --git a/src/clj/orcpub/index.clj b/src/clj/orcpub/index.clj index 867d29e8d..c7baa01cb 100644 --- a/src/clj/orcpub/index.clj +++ b/src/clj/orcpub/index.clj @@ -9,7 +9,7 @@ (def devmode? (env :dev-mode)) (defn meta-tag [property content] - (if content + (when content [:meta {:property property :content content}])) diff --git a/src/clj/orcpub/pdf.clj b/src/clj/orcpub/pdf.clj index 50788de24..c08465659 100644 --- a/src/clj/orcpub/pdf.clj +++ b/src/clj/orcpub/pdf.clj @@ -39,7 +39,7 @@ (let [field (.getField form (name k))] (when field - (if (and flatten (font-sizes k) (instance? PDTextField field)) + (when (and flatten (font-sizes k) (instance? PDTextField field)) (.setDefaultAppearance field (str "/Helv " " " (font-sizes k) " Tf 0 0 0 rg")) ;; this prints out weird boxes #_(.setDefaultAppearance field (str COSName/DA "/" (.getName font-name) " " (font-sizes k 8) " Tf 0 0 0 rg"))) @@ -132,7 +132,7 @@ current-line nil [next-word & remaining-words :as current-words] words] (if next-word - (let [line-with-word (str current-line (if current-line " ") next-word) + (let [line-with-word (str current-line (when current-line " ") next-word) new-width (string-width line-with-word font font-size)] (if (> new-width width) (recur (conj lines current-line) @@ -169,16 +169,16 @@ (.setNonStrokingColor cs r g b)) (defn draw-text [cs text font font-size x y & [color]] - (if text + (when text (let [units-x (* 72 x) units-y (* 72 y)] (.beginText cs) (.setFont cs font font-size) - (if color + (when color (apply set-text-color cs color)) (.moveTextPositionByAmount cs units-x units-y) (.drawString cs (if (keyword? text) (common/safe-name text) text)) - (if color + (when color (set-text-color cs 0 0 0)) (.endText cs)))) @@ -253,7 +253,7 @@ (subs s 0 len))) (defn abbreviate-duration [duration] - (if duration + (when duration (-> duration (s/replace #"Concentration,? up to " "Conc, ") abbreviate-times @@ -352,7 +352,7 @@ (for [j (range num-boxes-y) i (range (dec num-boxes-x) -1 -1) :let [spell-index (+ i (* j num-boxes-x))]] - (if-let [{:keys [class-nm dc attack-bonus spell] :as spell-data} + (when-let [{:keys [class-nm dc attack-bonus spell] :as spell-data} (get (vec spells) spell-index)] (let [{:keys [description casting-time @@ -385,7 +385,7 @@ (- 11.0 y 1.08) ;from the top down (- box-width 0.24) (- box-height 1.13))] - (if (:material-component components) + (when (:material-component components) (draw-text-to-box cs (str (s/capitalize (:material-component components))) (:italic fonts) @@ -426,7 +426,7 @@ (- 11.0 y 0.19) (- box-width 0.24) 0.25) - (if casting-time + (when casting-time (draw-spell-field cs document "magic-swirl" @@ -437,7 +437,7 @@ #",")))) (+ x 0.12) (- 11.0 y 0.45))) - (if range + (when range (draw-spell-field cs document "arrow-dunk" @@ -453,21 +453,21 @@ nil? (map (fn [[k v]] - (if (-> spell :components k) + (when (-> spell :components k) v)) {:verbal "V" :somatic "S" :material "M"}))) (+ x 1.12) (- 11.0 y 0.45)) - (if duration + (when duration (draw-spell-field cs document "sands-of-time" (abbreviate-duration duration) (+ x 1.62) (- 11.0 y 0.45))) - (if (seq remaining-desc-lines) + (when (seq remaining-desc-lines) (draw-imagex cs over-img (+ x 2.3) diff --git a/src/clj/orcpub/pedestal.clj b/src/clj/orcpub/pedestal.clj index 4e6733e85..6461e6483 100644 --- a/src/clj/orcpub/pedestal.clj +++ b/src/clj/orcpub/pedestal.clj @@ -47,7 +47,7 @@ {body :body {last-modified "Last-Modified" content-length "Content-Length"} :headers} response - old-etag (if if-none-match + old-etag (when if-none-match (-> if-none-match (s/split #"--gzip") first)) new-etag (or (parse-date last-modified content-length) (calculate-etag body)) not-modified? (and old-etag (= new-etag old-etag))] diff --git a/src/clj/orcpub/privacy.clj b/src/clj/orcpub/privacy.clj index 9d0360ec6..d4170e75d 100644 --- a/src/clj/orcpub/privacy.clj +++ b/src/clj/orcpub/privacy.clj @@ -81,7 +81,7 @@ :font-size 32 :paragraphs ["We may change this policy from time to time, and if we do we'll post any changes on this page. If you continue to use OrcPub after those changes are in effect, you agree to the revised policy. If the changes are significant, we may provide more prominent notice or get your consent as required by law."]} - (if (not (s/blank? (environ/env :email-access-key))) + (when (not (s/blank? (environ/env :email-access-key))) {:title "How can you contact us?" :font-size 32 :paragraphs diff --git a/src/clj/orcpub/routes.clj b/src/clj/orcpub/routes.clj index 6bf5ae706..160a20c2e 100644 --- a/src/clj/orcpub/routes.clj +++ b/src/clj/orcpub/routes.clj @@ -282,9 +282,9 @@ (defn register [{:keys [json-params db conn] :as request}] (let [{:keys [username email password send-updates?]} json-params - username (if username (s/trim username)) - email (if email (s/lower-case (s/trim email))) - password (if password (s/trim password)) + username (when username (s/trim username)) + email (when email (s/lower-case (s/trim email))) + password (when password (s/trim password)) validation (registration/validate-registration json-params (seq (d/q email-query db email)) @@ -496,10 +496,10 @@ (with-open [doc (PDDocument/load input)] (pdf/write-fields! doc fields (not chrome?) font-sizes) - (if (and print-spell-cards? (seq spells-known)) + (when (and print-spell-cards? (seq spells-known)) (add-spell-cards! doc spells-known spell-save-dcs spell-attack-mods custom-spells print-spell-card-dc-mod?)) - (if (and image-url + (when (and image-url (re-matches #"^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]" image-url) (not image-url-failed)) (case print-character-sheet-style? @@ -507,7 +507,7 @@ 2 (pdf/draw-image! doc (pdf/get-page doc 1) image-url 0.45 1.75 2.35 3.15) 3 (pdf/draw-image! doc (pdf/get-page doc 1) image-url 0.45 1.75 2.35 3.15) 4 (pdf/draw-image! doc (pdf/get-page doc 0) image-url 0.50 0.85 2.35 3.15))) - (if (and faction-image-url + (when (and faction-image-url (re-matches #"^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]" faction-image-url) (not faction-image-url-failed)) (case print-character-sheet-style? @@ -899,9 +899,9 @@ (defn character-summary-description [{:keys [::char5e/race-name ::char5e/subrace-name ::char5e/classes]}] (str race-name " " - (if subrace-name (str "(" subrace-name ") ")) + (when subrace-name (str "(" subrace-name ") ")) " " - (if (seq classes) + (when (seq classes) (s/join " / " (map diff --git a/src/cljc/orcpub/common.cljc b/src/cljc/orcpub/common.cljc index 16192ec04..460d32ced 100644 --- a/src/cljc/orcpub/common.cljc +++ b/src/cljc/orcpub/common.cljc @@ -6,7 +6,7 @@ (def dot-char "•") (defn- name-to-kw-aux [name ns] - (if (string? name) + (when (string? name) (as-> name $ (s/lower-case $) (s/replace $ #"'" "") @@ -20,7 +20,7 @@ (memoized-name-to-kw name ns)) (defn kw-to-name [kw & [capitalize?]] - (if (keyword? kw) + (when (keyword? kw) (as-> kw $ (name $) (s/split $ #"\-") @@ -41,7 +41,7 @@ (time ~body))) (defn bonus-str [val] - (str (if (pos? val) "+") val)) + (str (when (pos? val) "+") val)) (defn mod-str [val] (cond (pos? val) (str "+" val) @@ -79,7 +79,7 @@ (warn (str "non-keyword value passed to safe-name: " kw)))) (defn safe-capitalize [s] - (if (string? s) (s/capitalize s))) + (when (string? s) (s/capitalize s))) (defn safe-capitalize-kw [kw] (some-> kw @@ -87,11 +87,11 @@ safe-capitalize)) (defn sentensize [desc] - (if desc + (when desc (str (s/upper-case (subs desc 0 1)) (subs desc 1) - (if (not (s/ends-with? desc ".")) + (when (not (s/ends-with? desc ".")) ".")))) (def add-keys-xform @@ -143,7 +143,7 @@ (vec (keep-indexed (fn [i item] - (if (not= i index) + (when (not= i index) item)) v))) diff --git a/src/cljc/orcpub/components.cljc b/src/cljc/orcpub/components.cljc index 20c55a78a..d4971590d 100644 --- a/src/cljc/orcpub/components.cljc +++ b/src/cljc/orcpub/components.cljc @@ -6,7 +6,7 @@ [:i.fa.fa-check.f-s-14.bg-white.b-color-gray.orange-shadow.pointer.b-1 {:class-name (str (if selected? "black slight-text-shadow" "white transparent") " " - (if disable? + (when disable? "opacity-5"))}]) (defn labeled-checkbox [label selected? disabled? on-click] @@ -60,7 +60,7 @@ :on-change (fn [e] #?(:cljs (swap! state (fn [{:keys [timeout temp-val] :as s}] - (if timeout + (when timeout (js/clearTimeout timeout)) (let [v (.. e -target -value)] (assoc s @@ -77,7 +77,7 @@ value (fn [str-v] #?(:cljs - (let [v (if (not (s/blank? str-v)) + (let [v (when (not (s/blank? str-v)) (js/parseInt str-v))] (on-change v)))) (assoc attrs :type :number)]) diff --git a/src/cljc/orcpub/dice.cljc b/src/cljc/orcpub/dice.cljc index 553400ca5..bfd18d601 100644 --- a/src/cljc/orcpub/dice.cljc +++ b/src/cljc/orcpub/dice.cljc @@ -31,12 +31,12 @@ (def dice-regex #"(\d+)?d(\d+)\s?([+-])?\s?(\d+)?") (defn parse-int [s] - (if s + (when s #?(:cljs (js/parseInt s)) #?(:clj (Integer/valueOf s)))) (defn dice-roll-text [dice-text] - (if-let [[_ num-str sides-str plus-minus-str mod-str :as match] + (when-let [[_ num-str sides-str plus-minus-str mod-str :as match] (re-matches dice-regex dice-text)] (let [num (or (parse-int num-str) 1) sides (parse-int sides-str) @@ -54,7 +54,7 @@ :plus-minus plus-minus}))) (defn dice-roll-text-2 [dice-text] - (if-let [[_ num-str sides-str plus-minus-str mod-str :as match] + (when-let [[_ num-str sides-str plus-minus-str mod-str :as match] (re-matches dice-regex dice-text)] (let [num (or (parse-int num-str) 1) sides (parse-int sides-str) diff --git a/src/cljc/orcpub/dnd/e5/character.cljc b/src/cljc/orcpub/dnd/e5/character.cljc index 0b2dbf240..d0640b2cf 100644 --- a/src/cljc/orcpub/dnd/e5/character.cljc +++ b/src/cljc/orcpub/dnd/e5/character.cljc @@ -50,7 +50,7 @@ (if (map? values) values ;; some weird spec issue causes values to look like [:map values] - (if (and (vector? values) (= (first values) :map)) + (when (and (vector? values) (= (first values) :map)) (second values))))) (defn equipment-has-simple-keywords? [equipment] diff --git a/src/cljc/orcpub/dnd/e5/classes.cljc b/src/cljc/orcpub/dnd/e5/classes.cljc index c63b4410b..80747c56f 100644 --- a/src/cljc/orcpub/dnd/e5/classes.cljc +++ b/src/cljc/orcpub/dnd/e5/classes.cljc @@ -797,7 +797,7 @@ :duration (units5e/hours (int (/ (?class-level :druid) 2))) :summary (str "You can transform into a beast you have seen with CR " ?wild-shape-cr - (if ?wild-shape-limitation (str " and " ?wild-shape-limitation)))})]}} + (when ?wild-shape-limitation (str " and " ?wild-shape-limitation)))})]}} :selections [(opt5e/new-starting-equipment-selection :druid {:name "Druidic Focus" @@ -1663,14 +1663,14 @@ language-options (zipmap languages (repeat true))] (t/option-cfg {:name name - :selections (if (> (count languages) 1) + :selections (when (> (count languages) 1) [(opt5e/language-selection language-map {:choose 1 :options language-options})]) :modifiers (remove nil? - [(if (= 1 (count languages)) + [(when (= 1 (count languages)) (mod5e/language (first languages))) (mod/set-mod ?ranger-favored-enemies enemy-type)])}))) @@ -1806,7 +1806,7 @@ :page 91 :summary (let [favored-terrain ?ranger-favored-terrain one-terrain? (= 1 (count favored-terrain))] - (str "your favored terrain " (if one-terrain? "type is" "types are") " " (if (seq favored-terrain) (common/list-print (map #(common/kw-to-name % false) ?ranger-favored-terrain)) "not selected") ". Related to the terrain type" (if (not one-terrain?) "s") ": 2X proficiency bonus for INT and WIS checks for which you are proficient, difficult terrain doesn't slow your group, always alert for danger, can move stealthily alone at normal pace, 2x food when foraging, while tracking learn exact number, size, and when they passed through"))})] + (str "your favored terrain " (if one-terrain? "type is" "types are") " " (if (seq favored-terrain) (common/list-print (map #(common/kw-to-name % false) ?ranger-favored-terrain)) "not selected") ". Related to the terrain type" (when (not one-terrain?) "s") ": 2X proficiency bonus for INT and WIS checks for which you are proficient, difficult terrain doesn't slow your group, always alert for danger, can move stealthily alone at normal pace, 2x food when foraging, while tracking learn exact number, size, and when they passed through"))})] :selections [(opt5e/new-starting-equipment-selection :ranger {:name "Melee Weapon" diff --git a/src/cljc/orcpub/dnd/e5/display.cljc b/src/cljc/orcpub/dnd/e5/display.cljc index 53b751be9..4294ace60 100644 --- a/src/cljc/orcpub/dnd/e5/display.cljc +++ b/src/cljc/orcpub/dnd/e5/display.cljc @@ -81,7 +81,7 @@ (str (common/safe-name units)))))) (defn duration-description [{:keys [concentration] :as duration}] - (str (if concentration "conc. ") (unit-amount-description duration))) + (str (when concentration "conc. ") (unit-amount-description duration))) #_(defn get-source [source] (sources (or source :phb))) @@ -133,15 +133,15 @@ (defn action-description [{:keys [description summary source page duration range frequency qualifier]}] (str (or summary description) - (if (or range duration frequency) + (when (or range duration frequency) (str " (" (s/join ", " (remove nil? [qualifier - (if range (str "range " (unit-amount-description range))) - (if duration (str "lasts " (duration-description duration))) - (if frequency (str "use " (frequency-description frequency))) + (when range (str "range " (unit-amount-description range))) + (when duration (str "lasts " (duration-description duration))) + (when frequency (str "use " (frequency-description frequency))) #_(if page (source-description source page))])) ")")))) diff --git a/src/cljc/orcpub/dnd/e5/event_handlers.cljc b/src/cljc/orcpub/dnd/e5/event_handlers.cljc index 5c219e0c9..3bfcdf786 100644 --- a/src/cljc/orcpub/dnd/e5/event_handlers.cljc +++ b/src/cljc/orcpub/dnd/e5/event_handlers.cljc @@ -41,7 +41,7 @@ indicator-key true}}) (defn starting-equipment-entity-options [indicator-key key items] - (if items + (when items {key (mapv (partial starting-equipment-entity-option indicator-key) @@ -119,7 +119,7 @@ homebrew?) selectable?) (do - (if select-fn + (when select-fn (select-fn (entity/get-option-value-path built-template character @@ -142,4 +142,4 @@ (defn parse-name-query [search-text] (let [match (re-matches name-query-regex search-text)] - (if match (map #(common/name-to-kw % "orcpub.dnd.e5.character.random") (rest match))))) + (when match (map #(common/name-to-kw % "orcpub.dnd.e5.character.random") (rest match))))) diff --git a/src/cljc/orcpub/dnd/e5/magic_items.cljc b/src/cljc/orcpub/dnd/e5/magic_items.cljc index 7e2273850..d425849cf 100644 --- a/src/cljc/orcpub/dnd/e5/magic_items.cljc +++ b/src/cljc/orcpub/dnd/e5/magic_items.cljc @@ -291,7 +291,7 @@ ::description (str "You can use an action to blow this horn. In response, " die "d4 + " die " warrior spirits from the Valhalla appear within 60 feet of you. They use the statistics of a berserker. They return to Valhalla after 1 hour or when they drop to 0 hit points. Once you use the horn, it can’t be used again until 7 days have passed." - (if requirement + (when requirement (str " You must have proficiency with all " requirement @@ -2997,7 +2997,7 @@ The boots regain 2 hours of flying capability for every 12 hours they aren’t i (let [base-weapon-fn (make-base-weapon-fn item-subtype subtypes) of-type (filter base-weapon-fn (concat weapons5e/weapons weapons5e/ammunition))] - #?(:clj (if (empty? of-type) + #?(:clj (when (empty? of-type) (throw (IllegalArgumentException. (str "No base types matched for weapon item!: " (::name item)))))) (map (fn [weapon] @@ -3044,7 +3044,7 @@ The boots regain 2 hours of flying capability for every 12 hours they aren’t i of-type (filter base-armor-fn armor5e/armor)] - #?(:clj (if (empty? of-type) + #?(:clj (when (empty? of-type) (throw (IllegalArgumentException. "No base types matched for armor item!")))) (map (fn [armor] diff --git a/src/cljc/orcpub/dnd/e5/modifiers.cljc b/src/cljc/orcpub/dnd/e5/modifiers.cljc index 5854aa61c..0ea963232 100644 --- a/src/cljc/orcpub/dnd/e5/modifiers.cljc +++ b/src/cljc/orcpub/dnd/e5/modifiers.cljc @@ -472,7 +472,7 @@ (let [equipment-mod (equipment-mod-fn cfg)] (if (::char-equip/equipped? cfg) (let [mods (concat [equipment-mod] - (if (and include-magic-bonus? magical-ac-bonus) + (when (and include-magic-bonus? magical-ac-bonus) [(mods/cum-sum-mod ?magical-ac-bonus magical-ac-bonus)]) modifiers)] mods) @@ -651,7 +651,7 @@ (fn [{:keys [::mods/key ::mods/args]}] (let [raw-args (mods/raw-args args) mod-fn (mods-map key)] - (if mod-fn + (when mod-fn (apply mod-fn raw-args))))) (remove nil?)) mod-cfgs))) diff --git a/src/cljc/orcpub/dnd/e5/monsters.cljc b/src/cljc/orcpub/dnd/e5/monsters.cljc index c2ef537ef..2519228c7 100644 --- a/src/cljc/orcpub/dnd/e5/monsters.cljc +++ b/src/cljc/orcpub/dnd/e5/monsters.cljc @@ -16,10 +16,10 @@ (defn monster-subheader ([size type subtypes alignment] - (str (if size (common/safe-capitalize-kw size)) + (str (when size (common/safe-capitalize-kw size)) " " (common/kw-to-name type) - (if (seq subtypes) + (when (seq subtypes) (str " (" (s/join ", " (map common/kw-to-name subtypes)) ")")) ", " alignment)) diff --git a/src/cljc/orcpub/dnd/e5/options.cljc b/src/cljc/orcpub/dnd/e5/options.cljc index 2fdabfd98..a53923db5 100644 --- a/src/cljc/orcpub/dnd/e5/options.cljc +++ b/src/cljc/orcpub/dnd/e5/options.cljc @@ -410,11 +410,11 @@ (let [{:keys [verbal somatic material material-component]} components] (spell-field "Components" (str (s/join ", " (remove nil? - [(if verbal "V") - (if somatic "S") - (if material "M")])) - (if material-component (str " (" material-component ")")))))] - [:div.f-w-n (if (or description summary) + [(when verbal "V") + (when somatic "S") + (when material "M")])) + (when material-component (str " (" material-component ")")))))] + [:div.f-w-n (when (or description summary) (doall (map-indexed (fn [i p] @@ -459,12 +459,12 @@ (sort spells))) (defn spell-level-title [class-name level] - (str class-name (if (and level (zero? level)) " Cantrips Known" (str " Spells Known" (if level (str " " level)))))) + (str class-name (if (and level (zero? level)) " Cantrips Known" (str " Spells Known" (when level (str " " level)))))) (defn spell-selection [spell-lists spells-map {:keys [title class-key level spellcasting-ability class-name num prepend-level? spell-keys options min max exclude-ref? ref]}] (let [title (or title (spell-level-title class-name level)) kw (common/name-to-kw title) - ref (or ref (if (not exclude-ref?) [:class class-key kw]))] + ref (or ref (when (not exclude-ref?) [:class class-key kw]))] (t/selection-cfg {:name title :key kw @@ -649,7 +649,7 @@ (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 (when slot-schedule (slot-schedule cls-lvl)) (total-slots cls-lvl level-factor)) all-spells (select-keys (or spells (spell-lists (or spell-list-kw class-key))) (keys slots)) @@ -663,8 +663,8 @@ (fn [spell-key] (let [spell (spells-map spell-key)] #?@(:cljs - [(if (nil? spell) (js/console.warn (str "No spell found for key: " spell-key))) - (if (nil? (:name spell)) (js/console.warn (str "Spell is missing name: " spell-key)))]) + [(when (nil? spell) (js/console.warn (str "No spell found for key: " spell-key))) + (when (nil? (:name spell)) (js/console.warn (str "Spell is missing name: " spell-key)))]) (memoized-spell-option spells-map ability @@ -683,7 +683,7 @@ {:class-key class-key :class-name cls-nm :min num - :max (if (not acquire?) num) + :max (when (not acquire?) num) :options options}))]))) {} spells-known)) @@ -913,7 +913,7 @@ :help (proficiency-help (or num min) "a tool" "tools") :multiselect 2 :tags #{:tool-profs :profs}} - (if num {:min num :max num}) + (when num {:min num :max num}) cfg))) (defn tool-proficiency-selection [cfg] @@ -1975,15 +1975,15 @@ {:name name :edit-event edit-event :selections (concat - (if (seq skill-kws) + (when (seq skill-kws) [(skill-selection skill-kws (or skill-num 1))]) selections) :modifiers (concat [(modifiers/subrace name)] - (if (and speed + (when (and speed (not= speed (:speed race))) [(modifiers/speed (- speed (:speed race)))]) - (if (and darkvision + (when (and darkvision (not= darkvision (:darkvision race))) [(modifiers/darkvision darkvision)]) modifiers @@ -1995,7 +1995,7 @@ (modifiers/subrace-ability k v)) abilities) (traits-modifiers traits nil source) - (if source [(modifiers/used-resource source name)]))}))) + (when source [(modifiers/used-resource source name)]))}))) (defn ability-modifiers [abilities] (map @@ -2207,22 +2207,22 @@ :help help :edit-event edit-event :selections (concat - (if (seq skill-kws) + (when (seq skill-kws) [(skill-selection skill-kws (or skill-num 1))]) - (if (seq subraces) + (when (seq subraces) [(subrace-selection race spell-lists spells-map language-map weapon-map plugin? source subraces [:race key])]) - (if (seq language-options) [(language-selection language-map language-options)]) - (if (seq weapon-proficiency-options) + (when (seq language-options) [(language-selection language-map language-options)]) + (when (seq weapon-proficiency-options) [(weapon-proficiency-selection-2 weapon-map weapon-proficiency-options)]) selections) :modifiers (concat - (if (not plugin?) + (when (not plugin?) (remove nil? [(modifiers/race name) - (if size (modifiers/size size)) - (if speed (modifiers/speed speed))])) - (if darkvision + (when size (modifiers/size size)) + (when speed (modifiers/speed speed))])) + (when darkvision (darkvision-modifiers darkvision)) (map (fn [language] @@ -2237,7 +2237,7 @@ (traits-modifiers traits nil source) (armor-prof-modifiers armor-proficiencies) (weapon-prof-modifiers weapon-proficiencies) - (if source [(modifiers/used-resource source name)]))}))) + (when source [(modifiers/used-resource source name)]))}))) (defn add-sources [source background] (-> background @@ -2260,7 +2260,7 @@ (defn tool-prof-selection-aux [tool num & [key prereq-fn]] (t/selection-cfg {:name (str "Tool Proficiency: " (:name tool)) - :key (if key (keyword (str (name key) "--" (common/name-to-kw (:name tool))))) + :key (when key (keyword (str (name key) "--" (common/name-to-kw (:name tool))))) :help (str "Select " (s/lower-case (:name tool)) " for which you are proficient.") :options (map (fn [{:keys [name key icon]}] @@ -2314,7 +2314,7 @@ (t/option-cfg {:name "" :key :none})) - :prereq-fn (if class-kw (first-class? class-kw))}))) + :prereq-fn (when class-kw (first-class? class-kw))}))) (defn simple-weapon-selection [num class-kw weapon-map] (new-starting-equipment-selection @@ -2450,12 +2450,12 @@ (dispatch [:add-background-starting-equipment background])) :selections (concat selections - (if (seq tool-options) [(tool-prof-selection tool-options)]) + (when (seq tool-options) [(tool-prof-selection tool-options)]) (class-weapon-options weapon-choices nil weapon-map) (class-armor-options armor-choices nil) (class-equipment-options equipment-choices nil) - (if (seq skill-kws) [(skill-selection skill-kws skill-num)]) - (if (seq language-options) [(language-selection + (when (seq skill-kws) [(skill-selection skill-kws skill-num)]) + (when (seq language-options) [(language-selection language-map language-options)])) :modifiers (concat @@ -2572,24 +2572,24 @@ selections level-selections spell-selections - (if (seq tool-options) [(tool-prof-selection tool-options)]) - (if (seq skill-kws) [(skill-selection skill-kws skill-num)]) - (if (seq skill-expertise-kws) + (when (seq tool-options) [(tool-prof-selection tool-options)]) + (when (seq skill-kws) [(skill-selection skill-kws skill-num)]) + (when (seq skill-expertise-kws) [(skill-expertise-selection skill-expertise-kws (:choose skill-expertise-options))]) - (if (seq language-options) [(language-selection language-map language-options)]))) + (when (seq language-options) [(language-selection language-map language-options)]))) :modifiers (concat modifiers level-modifiers [(modifiers/subclass (:key cls) kw) (modifiers/subclass-name (:key cls) name)] - (if (:known-mode spellcasting) + (when (:known-mode spellcasting) [(modifiers/spells-known-mode name (:known-mode spellcasting))]) (armor-prof-modifiers armor-profs) (weapon-prof-modifiers weapon-profs) (tool-prof-modifiers tool-profs) (traits-modifiers traits (:key cls)) - (if level-factor [(modifiers/spell-slot-factor (:key cls) level-factor)]) - (if source [(modifiers/used-resource source name)]))}))) + (when level-factor [(modifiers/spell-slot-factor (:key cls) level-factor)]) + (when source [(modifiers/used-resource source name)]))}))) (defn level-key [index] (keyword (str "level-" index))) @@ -2751,7 +2751,7 @@ (concat (some-> levels (get i) :selections) (some-> spellcasting-template :selections (get i)) - (if (= i subclass-level) + (when (= i subclass-level) (let [subclass-selection-key (common/name-to-kw subclass-title)] [(t/selection-cfg {:name (or subclass-title (str name " Archetype")) @@ -2765,9 +2765,9 @@ #(subclass-option spell-lists spells-map language-map (assoc cls :key kw) %) (if source (map (fn [sc] (assoc sc :source source)) subclasses) subclasses)) (custom-subclass-option spell-lists spells-map weapon-map kw level-kw subclass-selection-key (some? spellcasting)))})])) - (if (and (not plugin?) (ability-inc-set i)) + (when (and (not plugin?) (ability-inc-set i)) [(ability-score-improvement-selection spell-lists spells-map name i)]) - (if (not plugin?) + (when (not plugin?) [(assoc (hit-points-selection hit-die name i) ::t/prereq-fn @@ -2781,7 +2781,7 @@ (= level i)) traits) kw) - (if (and (not plugin?) + (when (and (not plugin?) (= i 1)) [(mods/cum-sum-mod ?hit-point-level-increases @@ -2789,7 +2789,7 @@ nil nil [(= kw (first ?classes))])]) - (if (not plugin?) + (when (not plugin?) [(modifiers/level kw name i hit-die)]))}))) @@ -2867,18 +2867,18 @@ (update selection ::t/tags sets/union #{kw})) (concat selections - (if (seq tool-options) + (when (seq tool-options) [(tool-prof-selection tool-options :tool-selection first-class?)]) - (if (seq multiclass-tool-options) + (when (seq multiclass-tool-options) [(tool-prof-selection multiclass-tool-options :multiclass-tool-selection (fn [c] (not= kw (first (:classes c)))))]) - (if weapon-choices (class-weapon-options weapon-choices kw weapon-map)) - (if armor-choices (class-armor-options armor-choices kw)) - (if equipment-choices (class-equipment-options equipment-choices kw)) - (if skill-options + (when weapon-choices (class-weapon-options weapon-choices kw weapon-map)) + (when armor-choices (class-armor-options armor-choices kw)) + (when equipment-choices (class-equipment-options equipment-choices kw)) + (when skill-options [(class-skill-selection skill-options :skill-proficiency first-class?)]) - (if (seq skill-expertise-kws) + (when (seq skill-expertise-kws) [(skill-expertise-selection skill-expertise-kws (:choose skill-expertise-options))]) - (if multiclass-skill-options + (when multiclass-skill-options [(class-skill-selection multiclass-skill-options :multiclass-skill-proficiency (complement first-class?))]) [(t/selection-cfg {:name (str name " Levels") @@ -2901,9 +2901,9 @@ (class-starting-equipment-entity-options :equipment equipment)]) :modifiers (concat modifiers - (if (:prepares-spells? spellcasting) + (when (:prepares-spells? spellcasting) [(mods/map-mod ?prepares-spells name true)]) - (if (= :all (:known-mode spellcasting)) + (when (= :all (:known-mode spellcasting)) (let [spell-list (spell-lists kw)] (mapcat (fn [[lvl spell-keys]] @@ -2921,18 +2921,18 @@ (using-source? ?option-sources (:source spell)))])) spell-keys)) spell-list))) - (if armor-profs (armor-prof-modifiers armor-profs kw)) - (if weapon-profs (weapon-prof-modifiers weapon-profs kw)) - (if tool (tool-prof-modifiers tool kw)) - (if level-factor [(modifiers/spell-slot-factor kw level-factor)]) - (if (and source (not plugin?)) + (when armor-profs (armor-prof-modifiers armor-profs kw)) + (when weapon-profs (weapon-prof-modifiers weapon-profs kw)) + (when tool (tool-prof-modifiers tool kw)) + (when level-factor [(modifiers/spell-slot-factor kw level-factor)]) + (when (and source (not plugin?)) [(modifiers/used-resource source name)]) - (if (:known-mode spellcasting) + (when (:known-mode spellcasting) [(modifiers/spells-known-mode name (:known-mode spellcasting))]) (remove nil? [(modifiers/cls kw) - (if save-profs (apply modifiers/saving-throws kw save-profs))]))}))) + (when save-profs (apply modifiers/saving-throws kw save-profs))]))}))) #_(defn source-url [source] (some-> source disp/sources :url)) @@ -3159,7 +3159,7 @@ (map key)) race-prereqs)] - (if (seq race-keys) + (when (seq race-keys) (let [race-map @(subscribe [::races/race-map]) race-names (map (comp :name race-map) race-keys)] [(race-prereq race-names)]))))) @@ -3202,7 +3202,7 @@ (spell-sniper-option spells-map :wizard "Wizard" ::character/int spell-lists)]})) (defn make-feat-selections [language-map spells-map spell-lists proficiency-weapons k v] - (if v + (when v (case k :weapon-prof-choice [(weapon-proficiency-selection v proficiency-weapons)] :language-choice [(language-selection-aux (vals language-map) v)] @@ -3228,7 +3228,7 @@ m)) (defn make-feat-modifiers [k v option-key] - (if v + (when v (case k :initiative [(modifiers/initiative v)] :two-weapon-ac-1 [dual-wield-ac-mod] @@ -3243,14 +3243,14 @@ :flying-speed-equals-walking-speed [(modifiers/flying-speed-equal-to-walking)] :swimming-speed [(modifiers/swimming-speed-override v)] :saving-throw-advantage-traps [(modifiers/saving-throw-advantage [:traps])] - :lizardfolk-ac (if v + :lizardfolk-ac (when v [(mods/modifier ?natural-ac-bonus 3) (mods/modifier ?armor-class-with-armor (fn [armor & [shield]] (max (+ ?base-armor-class (if shield (?shield-ac-bonus shield) 0)) (?armor-class-with-armor armor shield))))]) - :tortle-ac (if v + :tortle-ac (when v [(mods/modifier ?natural-ac-bonus 7) (mods/modifier ?armor-class-with-armor (fn [armor & [shield]] diff --git a/src/cljc/orcpub/dnd/e5/template.cljc b/src/cljc/orcpub/dnd/e5/template.cljc index a6f6493fb..f26077385 100644 --- a/src/cljc/orcpub/dnd/e5/template.cljc +++ b/src/cljc/orcpub/dnd/e5/template.cljc @@ -66,7 +66,7 @@ Only used for `ability-icons` -- see body of function below." [k size theme] (let [light-theme? (= "light-theme" theme)] - [:img {:class-name (str "h-" size " w-" size (if light-theme? " opacity-7")) + [:img {:class-name (str "h-" size " w-" size (when light-theme? " opacity-7")) :src (str (if light-theme? "/image/black/" "/image/") (ability-icons k) ".svg")}])) (defn ability-modifier [v] @@ -142,11 +142,11 @@ [ability-component k v i app-state [:div.f-s-16 [:i.fa.fa-minus-circle.orange - {:class-name (if decrease-disabled? "opacity-5 cursor-disabled") - :on-click (fn [_] (if (not decrease-disabled?) (set-ability! app-state k (dec v))))}] + {:class-name (when decrease-disabled? "opacity-5 cursor-disabled") + :on-click (fn [_] (when (not decrease-disabled?) (set-ability! app-state k (dec v))))}] [:i.fa.fa-plus-circle.orange.m-l-5 - {:class-name (if increase-disabled? "opacity-5 cursor-disabled") - :on-click (fn [_] (if (not increase-disabled?) (set-ability! app-state k (inc v))))}]]])) + {:class-name (when increase-disabled? "opacity-5 cursor-disabled") + :on-click (fn [_] (when (not increase-disabled?) (set-ability! app-state k (inc v))))}]]])) abilities-vec))]])) (declare template-selections) @@ -1268,7 +1268,7 @@ (t/option-cfg {:name name :key key - :help (if (or description + :help (when (or description page) (inventory-help description page source)) :modifiers [(modifier-fn key item)]}))) diff --git a/src/cljc/orcpub/dnd/e5/template_base.cljc b/src/cljc/orcpub/dnd/e5/template_base.cljc index 362f6760e..9801bb143 100644 --- a/src/cljc/orcpub/dnd/e5/template_base.cljc +++ b/src/cljc/orcpub/dnd/e5/template_base.cljc @@ -294,7 +294,7 @@ (some-> ?spell-slot-factors first val)) :else {}) - (if ?pact-magic? + (when ?pact-magic? (warlock-spell-slot-schedule (?class-level :warlock)))) ?classes [] ?reactions [] diff --git a/src/cljc/orcpub/dnd/e5/templates/ua_options.cljc b/src/cljc/orcpub/dnd/e5/templates/ua_options.cljc index 4a4ecc0c3..88899b2bd 100644 --- a/src/cljc/orcpub/dnd/e5/templates/ua_options.cljc +++ b/src/cljc/orcpub/dnd/e5/templates/ua_options.cljc @@ -31,7 +31,7 @@ {:name "Arcane Shot: Banishing Arrow" :page 3 :source ua-revised-subclasses-kw - :summary (str "If the arrow hits, banish the creature until the end of it's next turn, it's speed becomes 0 and it is incapacitated unless it succeeds on a DC " (?spell-save-dc ::char5e/int) " CHA save. " (if (>= (?class-level :fighter) 18) " The target also takes 2d6 force damage."))}) + :summary (str "If the arrow hits, banish the creature until the end of it's next turn, it's speed becomes 0 and it is incapacitated unless it succeeds on a DC " (?spell-save-dc ::char5e/int) " CHA save. " (when (>= (?class-level :fighter) 18) " The target also takes 2d6 force damage."))}) (mod5e/dependent-trait {:name "Arcane Shot: Brute Bane Arrow" :page 3 diff --git a/src/cljc/orcpub/entity.cljc b/src/cljc/orcpub/entity.cljc index 571f7dcdd..4b3c1abe2 100644 --- a/src/cljc/orcpub/entity.cljc +++ b/src/cljc/orcpub/entity.cljc @@ -204,7 +204,7 @@ (let [new-path (conj path key)] (merge paths - (if homebrew? {new-path true}) + (when homebrew? {new-path true}) (option-homebrew-paths option new-path) (options-homebrew-paths options new-path)))) {} @@ -303,7 +303,7 @@ (let [[option option-i] (first (keep-indexed (fn [i s] - (if (= (::t/key s) f) + (when (= (::t/key s) f) [s i])) (selection-options selection))) next-path (vec (concat current-path [::t/options option-i]))] @@ -315,7 +315,7 @@ (let [[selection selection-i] (first (keep-indexed (fn [i s] - (if (= (::t/key s) f) + (when (= (::t/key s) f) [s i])) (::t/selections template))) next-path (vec (concat current-path [::t/selections selection-i]))] @@ -352,7 +352,7 @@ (first (keep-indexed (fn [i v] - (if (= option-key (::key v)) + (when (= option-key (::key v)) i)) selection))) @@ -360,7 +360,7 @@ (first (keep-indexed (fn [i s] - (if (= (::t/key s) item-key) + (when (= (::t/key s) item-key) [i s])) items))) @@ -368,7 +368,7 @@ (first (keep-indexed (fn [i s] - (if (and item-key + (when (and item-key (= (::key s) item-key)) [i s])) items))) @@ -385,7 +385,7 @@ selection-path (vec (concat current-path [::options selection-k])) entity-items (get-in entity selection-path) [entity-i _] (entity-item-with-key entity-items option-k) - path-i (if (and (or option-k entity-i) + path-i (when (and (or option-k entity-i) (or (nil? max) (> max 1) multiselect?)) @@ -420,11 +420,11 @@ (defn combine-ref-selections [selections] (let [first-selection (first selections)] - (if first-selection + (when first-selection (assoc first-selection ::t/min (apply + (map ::t/min selections)) - ::t/max (if (every? ::t/max selections) (apply + (map ::t/max selections))) + ::t/max (when (every? ::t/max selections) (apply + (map ::t/max selections))) ::t/options (into (sorted-set-by #(compare (::t/key %) (::t/key %2))) @@ -620,7 +620,7 @@ (declare merge-selections) (defn merge-options [options other-options] - (if (or options other-options) + (when (or options other-options) (let [opt-map (zipmap (map ::t/key options) options) other-opt-map (zipmap (map ::t/key other-options) other-options) merged (merge-with @@ -640,7 +640,7 @@ (vals (apply dissoc merged (map ::t/key options)))))))) (defn merge-selections [selections other-selections] - (if (or selections other-selections) + (when (or selections other-selections) (let [sel-map (zipmap (map ::t/key selections) selections) other-sel-map (zipmap (map ::t/key other-selections) other-selections) merged (merge-with @@ -743,7 +743,7 @@ (defn meets-prereqs? [option & [built-char]] (every? (fn [{:keys [::t/prereq-fn] :as prereq}] - (if prereq-fn + (when prereq-fn (prereq-fn built-char) #?(:cljs (js/console.warn "NO PREREQ_FN" (::t/name option) prereq)))) (::t/prereqs option))) diff --git a/src/cljc/orcpub/modifiers.cljc b/src/cljc/orcpub/modifiers.cljc index 013bed768..5f55d96ac 100644 --- a/src/cljc/orcpub/modifiers.cljc +++ b/src/cljc/orcpub/modifiers.cljc @@ -100,7 +100,7 @@ (defn apply-modifiers [entity modifiers] (reduce (fn [e {:keys [::key ::conditions] :as mod}] - (if (nil? mod) + (when (nil? mod) #?(:clj (prn "MODIFIER IS NULL!!!!!!!!!!!!!!")) #?(:cljs (js/console.warn "MODIFIER IS NULL!!!!!!!!!!"))) (let [passes-conds? (every? #(% e) conditions) diff --git a/src/cljc/orcpub/pdf_spec.cljc b/src/cljc/orcpub/pdf_spec.cljc index 4fed204be..75ffb5694 100644 --- a/src/cljc/orcpub/pdf_spec.cljc +++ b/src/cljc/orcpub/pdf_spec.cljc @@ -76,7 +76,7 @@ traits))) (defn actions-string [title actions] - (if (seq actions) + (when (seq actions) (str title "\n" @@ -88,7 +88,7 @@ actions))))) (defn vec-trait [nm items] - (if (seq items) (str nm ": " (s/join ", " items)))) + (when (seq items) (str nm ": " (s/join ", " items)))) (defn keyword-vec-trait [nm keywords] (vec-trait nm (map name keywords))) @@ -97,7 +97,7 @@ (map (fn [{:keys [value qualifier]}] (str (name value) - (if qualifier + (when qualifier (str "(" qualifier ")")))) resistances)) @@ -111,8 +111,8 @@ (s/join "\n" (remove nil? - [(if (and darkvision (pos? darkvision)) (str "Darkvision: " darkvision " ft.")) - (if (> (count crit-values) 1) (str "Critical Hits: " (char5e/crit-values-str built-char))) + [(when (and darkvision (pos? darkvision)) (str "Darkvision: " darkvision " ft.")) + (when (> (count crit-values) 1) (str "Critical Hits: " (char5e/crit-values-str built-char))) (vec-trait "Damage Resistances" (resistance-strings damage-resistances)) (vec-trait "Damage Immunities" (resistance-strings damage-immunities)) (vec-trait "Condition Immunities" (resistance-strings condition-immunities)) @@ -372,7 +372,7 @@ (fn [spell-index spell] {(keyword (str "spells-" level "-" (inc spell-index) suffix)) (str (:name (spells-map (:key spell))) (let [qualifier (:qualifier spell)] - (if qualifier + (when qualifier (str " (" qualifier ")"))))}) spells) {(keyword (str "spell-slots-" level suffix)) @@ -400,7 +400,7 @@ prepared-spells-by-class))) (defn profs-paragraph [profs prof-map title] - (if (seq profs) + (when (seq profs) (str title " Proficiencies: " @@ -428,7 +428,7 @@ (defn damage-str [die die-count mod damage-type] (str (dice/dice-string die-count die mod) - (if damage-type (str " " (name damage-type))))) + (when damage-type (str " " (name damage-type))))) (defn attacks-and-spellcasting-fields "For each weapon, we are creating a new map with the name, the attack bonus, and the damage. @@ -457,7 +457,7 @@ (remove nil? [normal - (if (:versatile weapon) + (when (:versatile weapon) {:name (str (:name weapon) " (two-handed)") :attack-bonus (char5e/weapon-attack-modifier built-char weapon false) :damage (damage-str (:damage-die versatile) (:damage-die-count versatile) normal-damage-modifier damage-type)})]))) @@ -522,12 +522,12 @@ subrace (char5e/subrace built-char) abilities (abilities-spec (char5e/ability-values built-char) - (if (not print-large-abilities?) + (when (not print-large-abilities?) "-mod") false) ability-bonuses (abilities-spec (char5e/ability-bonuses built-char) - (if print-large-abilities? + (when print-large-abilities? "-mod") true) saving-throws (set (char5e/saving-throws built-char)) @@ -556,7 +556,7 @@ (s/join "\n")) speed (speed built-char)] (merge - {:race (str race (if subrace (str "/" subrace))) + {:race (str race (when subrace (str "/" subrace))) :alignment (char5e/alignment built-char) :class-level (class-string classes levels) :background (char5e/background built-char) diff --git a/src/cljc/orcpub/registration.cljc b/src/cljc/orcpub/registration.cljc index a38538372..ae38ebf52 100644 --- a/src/cljc/orcpub/registration.cljc +++ b/src/cljc/orcpub/registration.cljc @@ -41,7 +41,7 @@ (fails-match? #"^[A-Za-z0-9]+$" username)) (defn bad-gmail? [email] - (if (some? email) + (when (some? email) (let [[_ bad-host] (re-matches #".*(gmial|gmal|gmil|gmai|gmaal|gmiil|gmaail|gmaiil)\.(.*)" email) [_ bad-domain] (re-matches #".*gmail\.(cm|co|coom)$" email)] (cond diff --git a/src/cljc/orcpub/template.cljc b/src/cljc/orcpub/template.cljc index 05e2a5c9d..b8ddffc80 100644 --- a/src/cljc/orcpub/template.cljc +++ b/src/cljc/orcpub/template.cljc @@ -44,7 +44,7 @@ ::options options ::help help ::min (or min 1) - ::max (or max (if (not multiselect?) (or min 1))) + ::max (or max (when (not multiselect?) (or min 1))) ::sequential? (boolean sequential?) ::multiselect? (or multiselect? (and (some? max) (> max 1))) ::ui-fn ui-fn diff --git a/src/cljc/orcpub/views_aux.cljc b/src/cljc/orcpub/views_aux.cljc index f2ec636e1..26a306214 100644 --- a/src/cljc/orcpub/views_aux.cljc +++ b/src/cljc/orcpub/views_aux.cljc @@ -55,7 +55,7 @@ :option-path new-option-path :multiselect? multiselect? :select-fn (fn [e] - (if (or multiselect? + (when (or multiselect? (not selected?)) (dispatch [:select-option {:option-path option-path :selected? selected? @@ -68,9 +68,9 @@ :built-template built-template :new-option-path new-option-path}])) (.stopPropagation e)) - :content (if (and (or selected? (= 1 (count options))) ui-fn) + :content (when (and (or selected? (= 1 (count options))) ui-fn) (ui-fn new-option-path built-template)) - :explanation-text (let [explanation-text (if (and (not meets-prereqs?) + :explanation-text (let [explanation-text (when (and (not meets-prereqs?) (not selected?)) (s/join ", " (map ::t/label failed-prereqs)))] explanation-text) @@ -112,7 +112,7 @@ {:title title :path actual-path :disable-select-new? disable-select-new? - :parent-title (if (not (s/blank? ancestor-names)) ancestor-names) + :parent-title (when (not (s/blank? ancestor-names)) ancestor-names) :name name :icon icon :help help diff --git a/src/cljs/orcpub/character_builder.cljs b/src/cljs/orcpub/character_builder.cljs index ae458db6d..c15dbe7d9 100644 --- a/src/cljs/orcpub/character_builder.cljs +++ b/src/cljs/orcpub/character_builder.cljs @@ -143,7 +143,7 @@ (map (fn [{:keys [::t/prereq-fn ::t/label] :as prereq}] (if prereq-fn - (if (not (prereq-fn)) + (when (not (prereq-fn)) label) (js/console.warn "NO PREREQ_FN" (::t/name option) prereq))) (::t/prereqs option)))) @@ -178,7 +178,7 @@ (def filter-classes (memoize filter-classes-fn)) -(def levels-selection #(if (= :levels (::t/key %)) %)) +(def levels-selection #(when (= :levels (::t/key %)) %)) (defn class-level-selector [] (let [expanded? (r/atom false)] @@ -187,7 +187,7 @@ class-template-option (options-map key) path [:class-levels key]] [:div.m-b-5 - {:class-name (if @expanded? "b-1 b-rad-5 p-5")} + {:class-name (when @expanded? "b-1 b-rad-5 p-5")} [:div.flex.align-items-c [:select.builder-option.builder-option-dropdown.flex-grow-1.m-t-0 {:value key @@ -195,18 +195,18 @@ (doall (map (fn [{:keys [::t/key ::t/name] :as option}] - (let [failed-prereqs (if (pos? i) (prereq-failures option))] + (let [failed-prereqs (when (pos? i) (prereq-failures option))] ^{:key key} [:option.builder-dropdown-item {:value key :disabled (seq failed-prereqs)} - (str name (if (seq failed-prereqs) (str " (" (s/join ", " failed-prereqs) ")")))])) + (str name (when (seq failed-prereqs) (str " (" (s/join ", " failed-prereqs) ")")))])) (sort-by ::t/name (filter (filter-classes key unselected-classes-set) options))))] - (if (::t/help class-template-option) + (when (::t/help class-template-option) [show-info-button expanded?]) (let [levels-selection (some levels-selection (::t/selections class-template-option)) available-levels (::t/options levels-selection) @@ -225,7 +225,7 @@ available-levels))]) [:i.fa.fa-minus-circle.orange.f-s-16.m-l-5.pointer {:on-click (delete-class key i options-map)}]] - (if @expanded? + (when @expanded? [:div.m-t-5.m-b-10 (::t/help class-template-option)])])))) (def select-template-key #(select-keys % [::t/key])) @@ -233,7 +233,7 @@ (defn class-level-data [option] (let [levels (some (fn [s] - (if (= :levels (::t/key s)) + (when (= :levels (::t/key s)) s)) (::t/selections option))] (assoc @@ -273,7 +273,7 @@ ^{:key key} [class-level-selector i key selected-class (map class-level-data options) unselected-classes-set]) selected-classes))] - (if (seq remaining-classes) + (when (seq remaining-classes) [:div.orange.p-5.underline.pointer [:i.fa.fa-plus-circle.orange.f-s-16] [:span.m-l-5 @@ -312,14 +312,14 @@ (set-custom-item-name selection-key i) {:class-name "input m-t-0"}] [:div.flex-grow-1 item-name]) - (if item-description [:div.w-60 [show-info-button expanded?]]) + (when item-description [:div.w-60 [show-info-button expanded?]]) [comps/int-field item-qty qty-change-fn {:class-name (str "input m-l-5 m-t-0 w-" (or qty-input-width 60))}] [:i.fa.fa-minus-circle.orange.f-s-16.m-l-5.pointer {:on-click remove-fn}]] - (if @expanded? [:div.m-t-5 item-description])]))) + (when @expanded? [:div.m-t-5 item-description])]))) (defn add-inventory-item-fn [key] (fn [e] @@ -445,7 +445,7 @@ magic-weapons (= key :magic-weapons)] [:div [inventory-adder key options selected-keys] - (if (seq selected-items) + (when (seq selected-items) [:div.flex.f-s-12.opacity-5.m-t-10.justify-cont-s-b [:div.m-r-10 "Carried?"] [:div.m-r-30 "Quantity"]]) @@ -454,7 +454,7 @@ (map-indexed (make-inventory-item key item-map qty-input-width) selected-items))] - (if custom-equipment-key + (when custom-equipment-key [:div [:div (doall @@ -472,29 +472,29 @@ (fn [{:keys [name key help selected? selectable? option-path select-fn content explanation-text icon classes multiselect? disable-checkbox? edit-event]}] [:div.p-10.b-1.b-rad-5.m-5.b-orange {:class-name (s/join " " (conj - (remove nil? [(if selected? "b-w-5") - (if selectable? "pointer hover-shadow") - (if (not selectable?) "opacity-5")]) + (remove nil? [(when selected? "b-w-5") + (when selectable? "pointer hover-shadow") + (when (not selectable?) "opacity-5")]) classes)) :on-click select-fn} [:div.flex.align-items-c [:div.flex-grow-1 [:div.flex.align-items-c - (if multiselect? + (when multiselect? [:span.m-r-5 (comps/checkbox selected? disable-checkbox?)]) - (if icon [:div.m-r-5 (views5e/svg-icon icon 24)]) + (when icon [:div.m-r-5 (views5e/svg-icon icon 24)]) [:span.f-w-b.f-s-1.flex-grow-1 name] - (if edit-event + (when edit-event [:span.orange.underline.pointer {:on-click (apply views5e/make-stop-prop-event-handler edit-event)} "edit"]) - (if help + (when help [show-info-button expanded?])] - (if (and help @expanded?) + (when (and help @expanded?) [help-section help]) - (if (and content selected?) + (when (and content selected?) content) - (if explanation-text + (when explanation-text [:div.i.f-s-12.f-w-n explanation-text])]]]))) @@ -517,11 +517,11 @@ (defn validate-selections [built-template character selections] (mapcat (fn [{:keys [::t/name ::t/tags] :as selection}] - (if (not (get tags :starting-equipment)) + (when (not (get tags :starting-equipment)) (let [remaining (entity/count-remaining built-template character selection)] (cond - (pos? remaining) [(str "You have " remaining " more '" name "' selection" (if (> remaining 1) "s") " to make.")] - (neg? remaining) [(str "You must remove " (Math/abs remaining) " '" name "' selection" (if (< remaining -1) "s") ".")] + (pos? remaining) [(str "You have " remaining " more '" name "' selection" (when (> remaining 1) "s") " to make.")] + (neg? remaining) [(str "You must remove " (Math/abs remaining) " '" name "' selection" (when (< remaining -1) "s") ".")] :else nil)))) (entity/combine-selections selections))) @@ -537,14 +537,14 @@ disable-select-new? homebrew? option)] - (if (not-any? ::t/hide-if-fail? failed-prereqs) + (when (not-any? ::t/hide-if-fail? failed-prereqs) ^{:key (::t/key option)} [option-selector-base (assoc data :help - (if (or help has-named-mods?) + (when (or help has-named-mods?) [:div - (if has-named-mods? [:div.i modifiers-str]) - [:div {:class-name (if has-named-mods? "m-t-5")} help]]) + (when has-named-mods? [:div.i modifiers-str]) + [:div {:class-name (when has-named-mods? "m-t-5")} help]]) :edit-event (::t/edit-event option))]))) (defn selection-section-title [title] @@ -597,17 +597,17 @@ (let [locked? @(subscribe [:locked path]) homebrew? @(subscribe [:homebrew? path])] [:div.p-5.m-b-20.m-b-0-last - (if (and (or title name) parent-title) + (when (and (or title name) parent-title) (selection-section-parent-title parent-title)) [:div.flex.align-items-c.w-100-p.justify-cont-s-b - (if icon (views5e/svg-icon icon 24)) + (when icon (views5e/svg-icon icon 24)) (if (or title name) (selection-section-title (or title name)) - (if parent-title + (when parent-title (selection-section-parent-title parent-title))) - (if (and path help) + (when (and path help) [show-info-button expanded?]) - (if (not hide-lock?) + (when (not hide-lock?) [tooltip (if locked? "Locked to prevent changes - click to unlock" @@ -615,18 +615,18 @@ [:i.fa.f-s-16.m-l-10.m-r-5.pointer {:class-name (if locked? "fa-lock" "fa-unlock-alt opacity-5 hover-opacity-full") :on-click (toggle-locked path)}]]) - (if (not hide-homebrew?) + (when (not hide-homebrew?) [:span.pointer - {:class-name (if (not homebrew?) "opacity-5 hover-opacity-full") + {:class-name (when (not homebrew?) "opacity-5 hover-opacity-full") :on-click (toggle-homebrew path)} [tooltip (if-not homebrew? (str "Homebrew is off for " title " - enabling this option allows you select options you would not normally have (turns on homebrew rules)") (str "Homebrew is on for " title " - you can select anything and make it homebrew")) (views5e/svg-icon "beer-stein" 18)]])] - (if (and help path @expanded?) + (when (and help path @expanded?) [help-section help]) - (if (int? min) + (when (int? min) [:div.p-5.f-s-16 [:div.flex.align-items-c.justify-cont-s-b [:span.i.m-r-10 (str "select " (cond @@ -738,7 +738,7 @@ ^{:key j} [:div selector]) part))] - (if (and item-adder (= i (dec (count parts)))) + (when (and item-adder (= i (dec (count parts)))) item-adder)]) parts))])) @@ -851,24 +851,24 @@ (not (pos? (ability-increases k))))] ^{:key k} [:div.t-a-c - {:class-name (if ability-disabled? "opacity-5 cursor-disabled")} + {:class-name (when ability-disabled? "opacity-5 cursor-disabled")} [:div - {:class-name (if (and (not ability-disabled?) + {:class-name (when (and (not ability-disabled?) (zero? (ability-increases k 0))) "opacity-5")} (ability-value (ability-increases k 0))] [:div.f-s-16 [:i.fa.fa-minus-circle.orange - {:class-name (if decrease-disabled? "opacity-5 cursor-disabled") + {:class-name (when decrease-disabled? "opacity-5 cursor-disabled") :on-click (stop-prop-fn (fn [] - (if (not decrease-disabled?) + (when (not decrease-disabled?) (dispatch [:decrease-ability-value increases-path k]))))}] [:i.fa.fa-plus-circle.orange.m-l-5 - {:class-name (if increase-disabled? "opacity-5 cursor-disabled") + {:class-name (when increase-disabled? "opacity-5 cursor-disabled") :on-click (stop-prop-fn (fn [] - (if (not increase-disabled?) + (when (not increase-disabled?) (dispatch [:increase-ability-value increases-path k]))))}]]])) ability-keys))]])) asi-selections))])) @@ -884,25 +884,25 @@ (fn [i k] ^{:key k} [:div.t-a-c - (if (seq race-ability-increases) + (when (seq race-ability-increases) [:div [:div.m-t-10.m-b-10 "+"] (ability-subtitle "race") (let [race-v (get race-ability-increases k 0)] [:div - {:class-name (if (zero? race-v) + {:class-name (when (zero? race-v) "opacity-5")} (ability-value race-v)])]) - (if (seq subrace-ability-increases) + (when (seq subrace-ability-increases) [:div [:div.m-t-10.m-b-10 "+"] (ability-subtitle "subrace") (let [subrace-v (get subrace-ability-increases k 0)] [:div - {:class-name (if (zero? subrace-v) + {:class-name (when (zero? subrace-v) "opacity-5")} (ability-value subrace-v)])]) - (if (seq ability-increases) + (when (seq ability-increases) [:div [:div.m-t-10.m-b-10 "+"] (ability-subtitle "other") @@ -910,7 +910,7 @@ (get race-ability-increases k 0) (get subrace-ability-increases k 0))] [:div - {:class-name (if (zero? other-v) + {:class-name (when (zero? other-v) "opacity-5")} (ability-value other-v)])])]) ability-keys))])) @@ -994,16 +994,16 @@ [:div.f-s-11.f-w-b (str "(" (score-costs v) " pts)")] [:div.f-s-16 [:i.fa.fa-minus-circle.orange - {:class-name (if decrease-disabled? "opacity-5 cursor-disabled") + {:class-name (when decrease-disabled? "opacity-5 cursor-disabled") :on-click (stop-prop-fn (fn [e] - (if (not decrease-disabled?) + (when (not decrease-disabled?) (set-abilities! (update abilities k dec)))))}] [:i.fa.fa-plus-circle.orange.m-l-5 - {:class-name (if increase-disabled? "opacity-5 cursor-disabled") + {:class-name (when increase-disabled? "opacity-5 cursor-disabled") :on-click (stop-prop-fn (fn [_] - (if (not increase-disabled?) (set-abilities! (update abilities k inc)))))}]]])) + (when (not increase-disabled?) (set-abilities! (update abilities k inc)))))}]]])) char5e/ability-keys))]]))) (defn abilities-standard [] @@ -1061,7 +1061,7 @@ {:value (k abilities) :type :number :on-change (fn [e] (let [value (.-value (.-target e)) - new-v (if (not (s/blank? value)) + new-v (when (not (s/blank? value)) (js/parseInt value))] (dispatch [:set-ability-score k new-v])))}]]) char5e/ability-keys))] @@ -1076,14 +1076,14 @@ [:div.m-t-10.m-b-10 "="] [:div.f-w-b "total"] [:input.input.b-3.f-s-18.m-b-5.p-l-0.w-100-p - {:value (if (abilities k) + {:value (when (abilities k) (total-abilities k)) :type :number :on-change (fn [e] (let [total (total-abilities k) value (.-value (.-target e)) diff (- total (abilities k)) - new-v (if (not (s/blank? value)) + new-v (when (not (s/blank? value)) (- (js/parseInt value) (or diff 0)))] (dispatch [:set-ability-score k new-v])))}]]) total-abilities))]])) @@ -1098,7 +1098,7 @@ :content content :select-fn (fn [_] (when (not= selected-key key) - (if select-fn (select-fn)) + (when select-fn (select-fn)) (dispatch [:set-ability-score-variant key])))}]) (def point-buy-starting-abilities-fn #(set-abilities! (char5e/abilities 8 8 8 8 8 8))) @@ -1114,7 +1114,7 @@ (= :asi-or-feat (::t/key s))) selections) character @(subscribe [:character])] - (if (seq asi-or-feat-selections) + (when (seq asi-or-feat-selections) [:div [:div.m-l-5 (selection-section-title "Ability Score Improvements")] (doall @@ -1208,13 +1208,13 @@ :selectable? allow-select? :option-path [:skill-profs key] :select-fn (fn [_] - (if allow-select? + (when allow-select? (dispatch [:select-skill path selected? key]))) - :explanation-text (if (and has-prof? + :explanation-text (when (and has-prof? (not selected?)) "You already have this skill proficiency") :icon icon - :classes (if bad-selection? "b-red") + :classes (when bad-selection? "b-red") :multiselect? true}])) skill5e/skills)))) @@ -1238,7 +1238,7 @@ (defn hit-points-entry [character selections built-template] (let [classes @(subscribe [::char5e/classes]) levels @(subscribe [::char5e/levels]) - first-class (if levels (levels (first classes))) + first-class (when levels (levels (first classes))) first-class-hit-die (:hit-die first-class) level-bonus @(subscribe [::char5e/hit-point-level-bonus]) con-bonus (::char5e/con @(subscribe [::char5e/ability-bonuses])) @@ -1283,14 +1283,14 @@ (let [entity-path (entity/get-entity-path built-template character (::entity/path selection))] (dispatch [:set-total-hps entity-path first-selection selection average-value remainder])))))}] total-hps)]] - (if (seq selections) + (when (seq selections) [:button.form-button.p-10 {:on-click (fn [_] (doseq [selection selections] (let [[_ class-kw :as path] (::entity/path selection)] (dispatch [:randomize-hit-points built-template path levels class-kw]))))} "Random"]) - (if (seq selections) + (when (seq selections) [:button.form-button.p-10 {:on-click (fn [_] (doseq [selection selections] @@ -1320,7 +1320,7 @@ [:table.w-100-p.striped [:tbody hit-points-headers - (if (zero? i) + (when (zero? i) [:tr [:td.p-5 1] [:td.p-5 first-class-hit-die] @@ -1336,7 +1336,7 @@ [:td.p-5 (:level level-value)] [:td.p-5 [:input.input.m-t-0 {:type :number - :class-name (if (or (nil? (:value level-value)) + :class-name (when (or (nil? (:value level-value)) (not (pos? (:value level-value)))) "b-red b-3") :on-change (fn [e] @@ -1360,7 +1360,7 @@ [:td.p-5 (+ total-base-hps total-con-bonus total-misc-bonus)] [:td.p-5]]]]])) classes)) - (if (> (count classes) 1) + (when (> (count classes) 1) [:div.m-t-20 [:div.f-s-16.m-l-5.f-w-b "Total"] [:table.w-100-p.striped @@ -1384,14 +1384,14 @@ (defn hit-points-editor [{:keys [character built-template option-paths selections]}] (let [num-selections (count selections)] - (if @(subscribe [::char5e/levels]) + (when @(subscribe [::char5e/levels]) [selection-section-base {:name "Hit Points" :hide-lock? true :hide-homebrew? true - :min (if (pos? num-selections) num-selections) - :max (if (pos? num-selections) num-selections) - :remaining (if (pos? num-selections) (sum-remaining built-template character selections)) + :min (when (pos? num-selections) num-selections) + :max (when (pos? num-selections) num-selections) + :remaining (when (pos? num-selections) (sum-remaining built-template character selections)) :body (hit-points-entry character selections built-template)}]))) (defn info-block [text] @@ -1408,7 +1408,7 @@ (map key) (map (fn [nm] (str nm "s")))) spells-known-modes)] - (if (seq any-mode-class-names) + (when (seq any-mode-class-names) (info-block (str "Except for cantrips, " (common/list-print any-mode-class-names) @@ -1559,12 +1559,12 @@ :on-click (fn [_] (dispatch [:set-page i]))} [:div {:class-name class-name} - (if (= :desktop device-type) + (when (= :desktop device-type) [:div.f-s-10.m-b-2 name]) [:div.t-a-c (views5e/svg-icon icon 32)]] - (if (not (zero? total-remaining)) + (when (not (zero? total-remaining)) [:div.flex.justify-cont-end.m-t--10.p-l-20 (remaining-indicator total-remaining 12 11)])])) pages))])) @@ -1576,7 +1576,7 @@ (defn matches-non-group-fn [key] (fn [{s-key ::t/key ref ::t/ref :as s}] - (let [v (if (or (= s-key key) + (let [v (when (or (= s-key key) (= ref [key])) s)] v))) @@ -1639,7 +1639,7 @@ (let [character @(subscribe [:character]) built-template @(subscribe [:built-template]) available-selections @(subscribe [:available-selections]) - _ (if print-enabled? (js/console.log "AVAILABLE SELECTIONS" available-selections)) + _ (when print-enabled? (js/console.log "AVAILABLE SELECTIONS" available-selections)) page @(subscribe [:page]) page-index (or page 0) option-paths @(subscribe [:option-paths]) @@ -1647,7 +1647,7 @@ selections (entity/tagged-selections available-selections tags) combined-selections (entity/combine-selections selections) final-selections combined-selections] - (if print-enabled? (js/console.log "FINAL SELECTIONS" final-selections)) + (when print-enabled? (js/console.log "FINAL SELECTIONS" final-selections)) [:div.w-100-p [:div#options-column.b-1.b-rad-5 [section-tabs available-selections built-template character page-index] @@ -1725,7 +1725,7 @@ (map (fn [{:keys [::t/min ::t/max ::t/show-if-zero?] :as selection}] (let [remaining (entity/count-remaining built-template character selection)] - (if (or (nil? max) + (when (or (nil? max) (pos? max) (not (zero? remaining)) show-if-zero?) @@ -1824,28 +1824,28 @@ [:span.personality-label.f-s-18 "Flaws"] [character-textarea entity-values ::char5e/flaws]] [:div.flex.align-items-c.w-100-p.m-t-30 - (if image-url + (when image-url [:img.m-r-10.image-character-thumbnail {:src image-url :on-error (image-error :failed-loading-image image-url) - :on-load (if image-url-failed image-loaded)}]) + :on-load (when image-url-failed image-loaded)}]) [:div.flex-grow-1 [:span.personality-label.f-s-18 "Image URL"] [character-input entity-values ::char5e/image-url nil set-image-url] - (if image-url-failed + (when image-url-failed [:div.red.m-t-5 "Image failed to load, please check the URL"])]] [:div.field [:span.personality-label.f-s-18 "Faction Name"] [character-input entity-values ::char5e/faction-name]] [:div.flex.align-items-c.w-100-p.m-t-30 - (if faction-image-url + (when faction-image-url [:img.m-r-10.image-faction-thumbnail {:src faction-image-url :on-error (image-error :failed-loading-faction-image faction-image-url) - :on-load (if faction-image-url-failed + :on-load (when faction-image-url-failed faction-image-loaded)}]) [:div.flex-grow-1 [:span.personality-label.f-s-18 "Faction Image URL"] [character-input entity-values ::char5e/faction-image-url nil set-faction-image-url] - (if faction-image-url-failed + (when faction-image-url-failed [:div.red.m-t-5 "Image failed to load, please check the URL"])]] [:div.field [:span.personality-label.f-s-18 "Description/Backstory"] @@ -1858,7 +1858,7 @@ (defn builder-tab [title key current-tab] [:span.builder-tab - {:class-name (if (= current-tab key) "selected-builder-tab") + {:class-name (when (= current-tab key) "selected-builder-tab") :on-click (set-builder-tab key)} [:span.builder-tab-text title]]) @@ -1976,7 +1976,7 @@ (if character-changed? (dispatch [:show-confirmation cfg]) (do - (if (:pre cfg) ((:pre cfg))) + (when (:pre cfg) ((:pre cfg))) (dispatch (:event cfg)))))) #_(def confirm-handler (memoize confirm-handler-fn)) @@ -2007,7 +2007,7 @@ (defn character-builder [] (let [character @(subscribe [:character]) - _ (if print-enabled? (cljs.pprint/pprint character)) + _ (when print-enabled? (cljs.pprint/pprint character)) option-paths @(subscribe [:option-paths]) built-template @(subscribe [:built-template]) built-char @(subscribe [:built-character]) @@ -2024,19 +2024,19 @@ locked-components @(subscribe [:locked-components]) character-map @(subscribe [::char5e/character-map]) character-id (:db/id character) - saved-character (if (and character-id + saved-character (when (and character-id character-map) (character-map character-id)) character-changed? (if character-id @(subscribe [::char5e/character-changed? character-id]) (not= db/default-character character))] - (if print-enabled? (print-char built-char)) - (if (not character-changed?) (js/window.scrollTo 0,0)) ;//Force a scroll to top of page only if we are not editing. + (when print-enabled? (print-char built-char)) + (when (not character-changed?) (js/window.scrollTo 0,0)) ;//Force a scroll to top of page only if we are not editing. [views5e/content-page "Character Builder" (remove nil? - [(if character-id [views5e/share-link character-id]) + [(when character-id [views5e/share-link character-id]) {:title "Random" :icon "random" :on-click (confirm-handler @@ -2066,9 +2066,9 @@ "Update Existing Character" "Save New Character") :icon "save" - :style (if character-changed? unsaved-button-style) + :style (when character-changed? unsaved-button-style) :on-click save-character} - (if (:db/id character) + (when (:db/id character) {:title "View" :icon "eye" :on-click (load-character-page (:db/id character))})]) @@ -2080,9 +2080,9 @@ ;[al-legality al-illegal-reasons used-resources]] [:div.flex [theme-toggle] - (if character-changed? [:div.red.f-w-b.m-r-10.m-l-10.flex.align-items-c + (when character-changed? [:div.red.f-w-b.m-r-10.m-l-10.flex.align-items-c (views5e/svg-icon "thunder-skull" 24 24) - (if (not mobile?) + (when (not mobile?) [:span "You have unsaved changes"])])]]]] [:div.flex.justify-cont-c.p-b-40 [:div.f-s-14.main-text-color.content diff --git a/src/cljs/orcpub/dnd/e5/db.cljs b/src/cljs/orcpub/dnd/e5/db.cljs index a3613ecf7..1fe517204 100644 --- a/src/cljs/orcpub/dnd/e5/db.cljs +++ b/src/cljs/orcpub/dnd/e5/db.cljs @@ -47,7 +47,7 @@ (def default-route route-map/dnd-e5-char-builder-route) (defn parse-route [] - (let [route (if js/window.location + (let [route (when js/window.location (bidi/match-route route-map/routes js/window.location.pathname))] (or route default-route))) @@ -148,84 +148,84 @@ (catch js/Object e (prn "FAILED SETTING LOCALSTORAGE ITEM")))) (defn character->local-store [character] - (if js/window.localStorage + (when js/window.localStorage (set-item local-storage-character-key (str (assoc (char5e/to-strict character) :changed (:changed character)))))) (defn user->local-store [user-data] - (if js/window.localStorage + (when js/window.localStorage (set-item local-storage-user-key (str user-data)))) (defn magic-item->local-store [magic-item] - (if js/window.localStorage + (when js/window.localStorage (set-item local-storage-magic-item-key (str magic-item)))) (defn spell->local-store [spell] - (if js/window.localStorage + (when js/window.localStorage (set-item local-storage-spell-key (str spell)))) (defn monster->local-store [monster] - (if js/window.localStorage + (when js/window.localStorage (set-item local-storage-monster-key (str monster)))) (defn encounter->local-store [encounter] - (if js/window.localStorage + (when js/window.localStorage (set-item local-storage-encounter-key (str encounter)))) (defn combat->local-store [combat] - (if js/window.localStorage + (when js/window.localStorage (set-item local-storage-combat-key (str combat)))) (defn background->local-store [background] - (if js/window.localStorage + (when js/window.localStorage (set-item local-storage-background-key (str background)))) (defn language->local-store [language] - (if js/window.localStorage + (when js/window.localStorage (set-item local-storage-language-key (str language)))) (defn invocation->local-store [invocation] - (if js/window.localStorage + (when js/window.localStorage (set-item local-storage-invocation-key (str invocation)))) (defn boon->local-store [boon] - (if js/window.localStorage + (when js/window.localStorage (set-item local-storage-boon-key (str boon)))) (defn selection->local-store [selection] - (if js/window.localStorage + (when js/window.localStorage (set-item local-storage-selection-key (str selection)))) (defn feat->local-store [feat] - (if js/window.localStorage + (when js/window.localStorage (set-item local-storage-feat-key (str feat)))) (defn race->local-store [race] - (if js/window.localStorage + (when js/window.localStorage (set-item local-storage-race-key (str race)))) (defn subrace->local-store [subrace] - (if js/window.localStorage + (when js/window.localStorage (set-item local-storage-subrace-key (str subrace)))) (defn subclass->local-store [subclass] - (if js/window.localStorage + (when js/window.localStorage (set-item local-storage-subclass-key (str subclass)))) (defn class->local-store [class] - (if js/window.localStorage + (when js/window.localStorage (set-item local-storage-class-key (str class)))) (defn plugins->local-store [plugins] - (if js/window.localStorage + (when js/window.localStorage (set-item local-storage-plugins-key (str plugins)))) (def tab-path [:builder :character :tab]) (defn get-local-storage-item [local-storage-key] - (if-let [stored-str (if js/window.localStorage + (when-let [stored-str (when js/window.localStorage (.getItem js/window.localStorage local-storage-key))] (try (reader/read-string stored-str) (catch js/Object e (prn "E" e) @@ -238,7 +238,7 @@ (fn [cofx _] (assoc cofx key - (if-let [stored-item (get-local-storage-item local-storage-key)] + (when-let [stored-item (get-local-storage-item local-storage-key)] (if (spec/valid? item-spec stored-item) (if item-fn (item-fn stored-item) diff --git a/src/cljs/orcpub/dnd/e5/equipment_subs.cljs b/src/cljs/orcpub/dnd/e5/equipment_subs.cljs index 375580bf4..cb505c704 100644 --- a/src/cljs/orcpub/dnd/e5/equipment_subs.cljs +++ b/src/cljs/orcpub/dnd/e5/equipment_subs.cljs @@ -159,7 +159,7 @@ (t/option-cfg {:name (or (:name item) name) :key item-key - :help (if (or description + :help (when (or description page) (t5e/inventory-help description page source)) :modifiers [(modifier-fn diff --git a/src/cljs/orcpub/dnd/e5/events.cljs b/src/cljs/orcpub/dnd/e5/events.cljs index fa147b328..b47067663 100644 --- a/src/cljs/orcpub/dnd/e5/events.cljs +++ b/src/cljs/orcpub/dnd/e5/events.cljs @@ -191,7 +191,7 @@ (defn backend-url [path] (if (and js/window.location (s/starts-with? js/window.location.href "http://localhost")) - (str "http://localhost:8890" (if (not (s/starts-with? path "/")) "/") path) + (str "http://localhost:8890" (when (not (s/starts-with? path "/")) "/") path) path)) (reg-event-fx @@ -767,7 +767,7 @@ (reg-event-fx ::party5e/add-character-remote-success (fn [_ [_ show-confirmation?]] - (if show-confirmation? + (when show-confirmation? {:dispatch [:show-message [:div "Character has been added to the party. View it on the " [:span.underline.pointer.orange @@ -1044,7 +1044,7 @@ {:dispatch [:update-value-field ::char5e/character-name (:name (char-rand5e/random-name-result {:race race-kw - :subrace (if (= ::char-rand5e/human race-kw) subrace-kw) + :subrace (when (= ::char-rand5e/human race-kw) subrace-kw) :sex sex-kw}))]}))) (reg-event-db :select-option @@ -1118,7 +1118,7 @@ [::entity/options :class] (fn [classes] (vec (remove #(= class-key (::entity/key %)) classes)))) new-first-class-key (get-in updated [::entity/options :class 0 ::entity/key]) - new-first-class-option (if new-first-class-key (options-map new-first-class-key))] + new-first-class-option (when new-first-class-key (options-map new-first-class-key))] (if (and (zero? i) new-first-class-option) (char5e/set-class updated new-first-class-key 0 new-first-class-option) @@ -1325,7 +1325,7 @@ character (entity/get-entity-path built-template character (:path level-value)) {::entity/key :manual-entry - ::entity/value (if (not (js/isNaN value)) value)})) + ::entity/value (when (not (js/isNaN value)) value)})) (reg-event-db :set-level-hit-points @@ -1340,7 +1340,7 @@ set-page) (defn make-url [protocol hostname path & [port]] - (str protocol "://" hostname (if port (str ":" port)) path)) + (str protocol "://" hostname (when port (str ":" port)) path)) (reg-event-fx :route @@ -1522,7 +1522,7 @@ (go (let [response (= (count text) 3) + top-spells (when (>= (count text) 3) (sequence filter-xform spells/spells)) - top-monsters (if (>= (count text) 3) + top-monsters (when (>= (count text) 3) (sequence filter-xform monsters/monsters))] @@ -2182,7 +2182,7 @@ (fn [level-slots-used] (let [first-empty-slot (some (fn [v] - (if (not (get level-slots-used v)) + (when (not (get level-slots-used v)) v)) (range))] (conj (or level-slots-used #{}) @@ -2212,7 +2212,7 @@ character [::entity/values ::char5e/xps] - (if (not (js/isNaN xps)) + (when (not (js/isNaN xps)) xps))) (defn set-notes [character notes] @@ -2522,7 +2522,7 @@ condition :duration (fn [{:keys [hours minutes rounds] :as duration}] - (if (not (zero-duration? condition)) + (when (not (zero-duration? condition)) (let [total-rounds (+ rounds (* common/rounds-per-minute minutes) (* common/rounds-per-hour hours)) @@ -2591,7 +2591,7 @@ true (assoc :current-initiative next-initiative) next-round? (assoc :round (inc round)) next-round? update-conditions) - removed-conditions (if next-round? + removed-conditions (when next-round? (filter (comp seq :removed-conditions) (flatten diff --git a/src/cljs/orcpub/dnd/e5/spell_subs.cljs b/src/cljs/orcpub/dnd/e5/spell_subs.cljs index 2014fe6a0..d2e12caed 100644 --- a/src/cljs/orcpub/dnd/e5/spell_subs.cljs +++ b/src/cljs/orcpub/dnd/e5/spell_subs.cljs @@ -93,7 +93,7 @@ (let [{:keys [ability key]} value] (mod5e/spells-known (or (:level value) 0) key - (if (keyword? ability) + (when (keyword? ability) (keyword "orcpub.dnd.e5.character" (name ability))) class-name level))) @@ -142,7 +142,7 @@ :spell (mod5e/spells-known (:level value) (:key value) (:ability value) - (if (keyword? class-key) + (when (keyword? class-key) (common/safe-capitalize-kw class-key))))) (defn eldritch-knight-spell? [s] @@ -357,9 +357,9 @@ (map (partial level-modifier class) level-modifiers))) (merge-levels selections-levels - (if add-spellcasting? + (when add-spellcasting? spellcaster-levels) - (if (and (= class :paladin) + (when (and (= class :paladin) (:paladin-spells option)) {1 {:modifiers (reduce-kv (fn [mods spell-level spells] @@ -373,16 +373,16 @@ [] (:paladin-spells option))}}) (let [cleric-spells (:cleric-spells option)] - (if (and (= class :cleric) + (when (and (= class :cleric) cleric-spells) (let [cleric-spell-mods (make-cleric-spell-mods cleric-spells)] {1 {:modifiers cleric-spell-mods}}))) - (if (and (= class :warlock) + (when (and (= class :warlock) (:warlock-spells option)) (reduce-kv (fn [levels spell-level spells] (let [level (to-class-level spell-level)] - (if (and spell-level (seq (vals spells))) + (when (and spell-level (seq (vals spells))) (assoc-in levels [level :selections] [(opt5e/warlock-subclass-spell-selection spell-lists spells-map (vals spells))])))) @@ -700,7 +700,7 @@ (merge breath-weapon {:name "Breath Weapon" - :summary (if damage-type + :summary (when damage-type (common/safe-capitalize-kw damage-type)) :attack-type :area :damage-die 6 diff --git a/src/cljs/orcpub/dnd/e5/subs.cljs b/src/cljs/orcpub/dnd/e5/subs.cljs index b66bfd809..28e13b854 100644 --- a/src/cljs/orcpub/dnd/e5/subs.cljs +++ b/src/cljs/orcpub/dnd/e5/subs.cljs @@ -336,7 +336,7 @@ (dispatch [:set-loading false]) (case (:status response) 200 (dispatch [::char5e/set-characters (:body response)]) - 401 (if (not login-optional?) + 401 (when (not login-optional?) (dispatch [:route-to-login])) 500 (dispatch (events/show-generic-error))))) (ra/make-reaction @@ -351,7 +351,7 @@ (dispatch [:set-loading false]) (case (:status response) 200 (dispatch [::party5e/set-parties (:body response)]) - 401 (if (not login-optional?) + 401 (when (not login-optional?) (dispatch [:route-to-login])) 500 (dispatch (events/show-generic-error))))) (ra/make-reaction @@ -360,16 +360,16 @@ (reg-sub-raw :user (fn [app-db [_ required?]] - (if (and (:user @app-db) (:token (:user @app-db))) ;;check if logged in, prevent unncessary calls + (when (and (:user @app-db) (:token (:user @app-db))) ;;check if logged in, prevent unncessary calls (go (let [hdrs (auth-headers @app-db) response ( attunement set :any not) + (when (-> attunement set :any not) (str " by a " (common/list-print (map @@ -1075,30 +1075,30 @@ ")")) (defn item-summary [{:keys [::mi/owner ::mi/name ::mi/type ::mi/item-subtype ::mi/rarity ::mi/attunement] :as item}] - (if item + (when item [:div.p-b-20.flex.align-items-c - (if owner + (when owner [:div.m-r-5 [svg-icon "beer-stein" 24]]) [:div [:span.f-s-24.f-w-b (or (:name item) name)] [:div.f-s-16.i.f-w-b.opacity-5 - (str (if type (common/safe-capitalize-kw type)) - (if (keyword? item-subtype) + (str (when type (common/safe-capitalize-kw type)) + (when (keyword? item-subtype) (str " (" (common/safe-capitalize-kw item-subtype) ")")) ", " (if (string? rarity) rarity (common/kw-to-name rarity)) - (if attunement + (when attunement (requires-attunement attunement)))]]])) (defn item-details [{:keys [::mi/summary ::mi/description ::mi/attunment]} single-column?] - (if (or summary description) + (when (or summary description) (paragraphs (or summary description) single-column?))) (defn item-component [item & [hide-summary? single-column?]] [:div.m-l-10.l-h-19 - (if (not hide-summary?) + (when (not hide-summary?) [:div [item-summary item]]) [:div [item-details item single-column?]]]) @@ -1112,21 +1112,21 @@ [:div.white [:span.f-s-24.f-w-b (:name result)] [:div - [:span.f-s-14.opacity-5.i (s/join " " (map (fn [k] (if k (name k))) [sex race subrace]))]]]) + [:span.f-s-14.opacity-5.i (s/join " " (map (fn [k] (when k (name k))) [sex race subrace]))]]]) (defn tavern-name-result [name] [:span.f-s-24.f-w-b.white name]) (defn spell-summary [name level school ritual include-name? & [subheader-size]] [:div.p-b-20 - (if include-name? [:span.f-s-24.f-w-b name]) + (when include-name? [:span.f-s-24.f-w-b name]) [:div.i.f-w-b.opacity-5 {:class-name (str "f-s-" (or subheader-size 18))} - (str (if (pos? level) + (str (when (pos? level) (str (common/ordinal level) "-level")) " " (str (common/safe-capitalize school) (if ritual " (can be cast as ritual)" "")) - (if (zero? level) + (when (zero? level) " cantrip"))]]) (defn spell-component [{:keys [name level school casting-time ritual range duration components description summary page source] :as spell} include-name? & [subheader-size]] @@ -1138,16 +1138,16 @@ (let [{:keys [verbal somatic material material-component]} components] (spell-field "Components" (str (s/join ", " (remove nil? - [(if verbal "V") - (if somatic "S") - (if material "M")])) - (if material-component + [(when verbal "V") + (when somatic "S") + (when material "M")])) + (when material-component (str " (" material-component ")"))))) [:div.m-t-10 (if description (paragraphs description) [:div - (if summary (paragraphs summary)) + (when summary (paragraphs summary)) #_[:span (str "(" (disp/source-description source page) " for more details)")]])]]) (defn spell-result [spell] @@ -1214,23 +1214,23 @@ (update legendary-actions :actions concat legendary) legendary-actions)] [:div.m-l-10.l-h-19 - (if (not @(subscribe [:mobile?])) {:style two-columns-style}) + (when (not @(subscribe [:mobile?])) {:style two-columns-style}) [:span.f-s-24.f-w-b name] [:div.f-s-18.i.f-w-b (monsters/monster-subheader size type subtypes alignment)] - (spell-field "Armor Class" (str armor-class (if armor-notes (str " (" armor-notes ")")))) + (spell-field "Armor Class" (str armor-class (when armor-notes (str " (" armor-notes ")")))) (let [{:keys [mean die-count die modifier]} hit-points] (spell-field "Hit Points" (str die-count "d" die - (if modifier (common/mod-str modifier)) + (when modifier (common/mod-str modifier)) (let [mean (or mean - (if (and die die-count) + (when (and die die-count) (dice/dice-mean-round-down die-count die (or modifier 0))))] - (if mean (str " (" mean ")")))))) + (when mean (str " (" mean ")")))))) (spell-field "Speed" speed) [:div.m-t-10.flex.justify-cont-s-a.m-b-10 {:style max-width-300} @@ -1243,16 +1243,16 @@ (let [ability-value (get monster ability-key)] [:div ability-value " (" (common/bonus-str (opt/ability-bonus ability-value)) ")"])]) [:str :dex :con :int :wis :cha]))] - (if (seq saving-throws) + (when (seq saving-throws) (spell-field "Saving Throws" (print-bonus-map saving-throws))) - (if skills (spell-field "Skills" (print-bonus-map skills))) - (if damage-vulnerabilities (spell-field "Damage Vulnerabilities" damage-vulnerabilities)) - (if damage-resistances (spell-field "Damage Resistances" damage-resistances)) - (if damage-immunities (spell-field "Damage Immunities" damage-immunities)) - (if condition-immunities (spell-field "Condition Immunities" condition-immunities)) - (if senses (spell-field "Senses" senses)) - (if languages (spell-field "Languages" languages)) - (if challenge (spell-field "Challenge" (str + (when skills (spell-field "Skills" (print-bonus-map skills))) + (when damage-vulnerabilities (spell-field "Damage Vulnerabilities" damage-vulnerabilities)) + (when damage-resistances (spell-field "Damage Resistances" damage-resistances)) + (when damage-immunities (spell-field "Damage Immunities" damage-immunities)) + (when condition-immunities (spell-field "Condition Immunities" condition-immunities)) + (when senses (spell-field "Senses" senses)) + (when languages (spell-field "Languages" languages)) + (when challenge (spell-field "Challenge" (str (case challenge 0.125 "1/8" 0.25 "1/4" @@ -1261,7 +1261,7 @@ " (" (monsters/challenge-ratings challenge) " XP)"))) - (if traits + (when traits [:div.m-t-20 (doall (map-indexed @@ -1269,7 +1269,7 @@ ^{:key i} [:div.m-t-10.wsp-prw (spell-field name description)]) traits))]) - (if actions + (when actions [:div.m-t-20 [:div.i.f-w-b.f-s-18 "Actions"] [:div @@ -1279,12 +1279,12 @@ ^{:key i} [:div.m-t-10.wsp-prw (spell-field (str name " " notes) description)]) actions))]]) - (if legendary-actions + (when legendary-actions [:div.m-t-20 [:div.i.f-w-b.f-s-18 "Legendary Actions"] - (if (:description legendary-actions) + (when (:description legendary-actions) [:div (:description legendary-actions)]) - (if (:actions legendary-actions) + (when (:actions legendary-actions) [:div (doall (map-indexed @@ -1292,7 +1292,7 @@ ^{:key i} [:div.m-t-10 (spell-field (str name " " notes) description)]) (:actions legendary-actions)))])]) - (if description + (when description [:div.m-t-10 (str description)])])) (defn monster-result [monster] @@ -1302,12 +1302,12 @@ [monster-component monster]]]) (defn search-results [] - (if-let [{{:keys [result] :as top-result} :top-result + (when-let [{{:keys [result] :as top-result} :top-result results :results :as search-results} @(subscribe [:search-results])] [:div - (if top-result + (when top-result [:div.p-20.m-b-20 (let [type (:type top-result)] (case type @@ -1318,7 +1318,7 @@ :name (name-result result) :tavern-name (tavern-name-result result) nil))]) - (if (seq results) + (when (seq results) (doall (map (fn [{:keys [type results]}] @@ -1484,7 +1484,7 @@ [:div.f-s-18.m-l-5 {:class-name text-classes} owner] - (if (and show-follow? username (not= username owner)) + (when (and show-follow? username (not= username owner)) [:button.form-button.m-l-10.p-6 {:on-click #(dispatch [(if following? :unfollow-user @@ -1515,10 +1515,10 @@ (let [username @(subscribe [:username])] [:div.flex.justify-cont-s-b.w-100-p.align-items-c [:div.flex.align-items-c.align-items-t - (if image-url + (when image-url [:img.m-r-20.m-t-10.m-b-10.image-character-thumbnail {:src image-url }]) [:div.flex.character-summary.m-t-20.m-b-20 - (if (and character-name include-name?) [:span.m-r-20.m-b-5 + (when (and character-name include-name?) [:span.m-r-20.m-b-5 [:span.character-name character-name] [:div.f-s-12.m-t-5.opacity-6.character-background background] [:div.f-s-12.m-t-5.opacity-6.character-alignment alignment] @@ -1532,7 +1532,7 @@ (when (not (s/blank? hair)) [:div.f-s-12.m-t-5.opacity-6.character-hair "Hair: " hair]) (when (not (s/blank? eyes)) [:div.f-s-12.m-t-5.opacity-6.character-eyes "Eyes: " eyes]) (when (not (s/blank? skin)) [:div.f-s-12.m-t-5.opacity-6.character-skin "Skin: " skin])] - (if (seq classes) + (when (seq classes) [:span.flex (map-indexed (fn [i v] @@ -1543,9 +1543,9 @@ (fn [{:keys [::char/class-name ::char/level ::char/subclass-name]}] [:span [:div.class-name (str class-name)] [:div.level (str "(" level ")")] - [:div.f-s-12.m-t-5.opacity-6.sub-class-name (if subclass-name subclass-name)]]) + [:div.f-s-12.m-t-5.opacity-6.sub-class-name (when subclass-name subclass-name)]]) classes)))])]] - (if (and show-owner? + (when (and show-owner? (some? owner) (some? username) (not= username owner)) @@ -1613,9 +1613,9 @@ [:div.m-t-20 [:div.flex.justify-cont-s-b [:div.flex.align-items-c - (if icon-name (svg-icon icon-name 32)) + (when icon-name (svg-icon icon-name 32)) [:span.m-l-5.f-s-16.f-w-600 title]] - (if (seq buttons) + (when (seq buttons) (apply conj [:div] @@ -1625,7 +1625,7 @@ value]]]) (defn list-display-section [title image-name values] - (if (seq values) + (when (seq values) (display-section title image-name @@ -1670,7 +1670,7 @@ [:span.f-w-b.f-s-16 "Total Spellcaster Levels: "] [:span.f-s-16.f-w-n total-spellcaster-levels]] (details-button @expanded? #(swap! expanded? not))] - (if @expanded? + (when @expanded? [:div:div.f-s-14 [:table.w-100-p.t-a-l.striped [:tbody @@ -1707,13 +1707,13 @@ checkboxes-expanded? (r/atom false)] (fn [id spell-slots spell-slot-factors total-spellcaster-levels levels mobile? pact-magic?] (let [multiclass? (> (count spell-slot-factors) 1) - first-factor-key (if spell-slot-factors (-> spell-slot-factors first key)) - first-class-level (if first-factor-key (-> levels first-factor-key :class-level))] + first-factor-key (when spell-slot-factors (-> spell-slot-factors first key)) + first-class-level (when first-factor-key (-> levels first-factor-key :class-level))] [:div.f-s-14.f-w-n [:div.flex.justify-cont-s-b [:div - [:span.f-w-b.f-s-16 (str "Slots" (if multiclass? " (Multiclass)"))]] - (if (not pact-magic?) + [:span.f-w-b.f-s-16 (str "Slots" (when multiclass? " (Multiclass)"))]] + (when (not pact-magic?) (details-button @expanded? #(swap! expanded? not)))] [:div.f-w-n.f-s-14 [:table.w-100-p.t-a-l.striped @@ -1743,9 +1743,9 @@ (= first-class-level lvl)))] ^{:key lvl} [:tr - {:class-name (if highlight? + {:class-name (when highlight? "f-w-b") - :style (if highlight? + :style (when highlight? highlight-spell-slot-row-style)} [:td.p-10 lvl] (let [total-slots (opt/total-slots lvl (if multiclass? 1 (-> spell-slot-factors first val)))] @@ -1770,7 +1770,7 @@ [:td.p-r-5 [:i.fa.orange {:class-name (if @checkboxes-expanded? "fa-caret-up" "fa-caret-down")}]]])]]] - (if @checkboxes-expanded? + (when @checkboxes-expanded? [:div.bg-light.p-5 (doall (map @@ -1850,8 +1850,8 @@ :on-change #(reset! selected-level (js/parseInt %))}]] [:div.m-l-5 [:button.form-button.p-10 - {:class-name (if (empty? usable-slot-levels) "disabled") - :on-click #(if (seq usable-slot-levels) + {:class-name (when (empty? usable-slot-levels) "disabled") + :on-click #(when (seq usable-slot-levels) (dispatch [::char/use-spell-slot id (or @selected-level (first usable-slot-levels))]))} "cast spell"]]])))) @@ -1868,13 +1868,13 @@ [[:tr.spell.pointer {:on-click on-click} [:td.p-l-10.p-b-5.p-t-5.f-w-b - (if (and (pos? lvl) + (when (and (pos? lvl) (get prepares-spells class)) [:span.m-r-5 - {:class-name (if always-prepared? + {:class-name (when always-prepared? "cursor-disabled") :on-click (fn [e] - (if (not always-prepared?) + (when (not always-prepared?) (dispatch [::char/toggle-spell-prepared id class key])) (.stopPropagation e))} (let [selected? (or always-prepared? @@ -1886,7 +1886,7 @@ (not (pos? remaining-preps))))))]) (:name spell)] [:td.p-l-10.p-b-5.p-t-5 class] - [:td.p-l-10.p-b-5.p-t-5 (if ability (s/upper-case (common/safe-name ability)))] + [:td.p-l-10.p-b-5.p-t-5 (when ability (s/upper-case (common/safe-name ability)))] [:td.p-l-10.p-b-5.p-t-5 (get cls-mods :spell-save-dc)] [:td.p-l-10.p-b-5.p-t-5 (common/bonus-str (get cls-mods :spell-attack-modifier))] [:td.p-l-10.p-b-5.p-t-5 @@ -1922,9 +1922,9 @@ [:span.f-w-b.i (if (pos? lvl) (str (common/ordinal lvl) " Level") "Cantrip")] - (if hide-unprepared? + (when hide-unprepared? [:span.i.opacity-5.m-l-5 "(unprepared hidden)"])] - (if (pos? lvl) + (when (pos? lvl) [:span.f-w-b (str @(subscribe [::char/spell-slots-remaining id lvl]) " remaining")])] [:table.w-100-p.t-a-l.striped [:tbody.spells @@ -1937,7 +1937,7 @@ [:th.p-l-10.p-b-5.p-t-5 (if mobile? "Aby" "Ability")] [:th.p-l-10.p-b-5.p-t-5 "DC"] [:th - {:class-name (if (not mobile?) "p-b-10 p-t-10")} + {:class-name (when (not mobile?) "p-b-10 p-t-10")} "Mod."] [:th.p-l-10.p-b-5.p-t-5 "Attack"] [:th.p-l-10.p-b-5.p-t-5]] @@ -1953,7 +1953,7 @@ count) 0) prepare-spell-count (prepare-spell-count-fn class)] - (if (char/spell-prepared? {:hide-unprepared? hide-unprepared? + (when (char/spell-prepared? {:hide-unprepared? hide-unprepared? :always-prepared? always-prepared? :lvl lvl :key key @@ -2037,10 +2037,10 @@ "Spells" "spell-book" [:div.m-t-20 - (if multiclass? + (when multiclass? [:div.m-b-20 [spellcaster-levels-table spell-slot-factors total-spellcaster-levels levels mobile?]]) - (if (or pact-magic? spell-slot-factors) + (when (or pact-magic? spell-slot-factors) [:div.m-b-20 [spell-slots-table id spell-slots spell-slot-factors total-spellcaster-levels levels mobile? pact-magic?]]) [:div.m-b-20 @@ -2114,7 +2114,7 @@ (defn weapon-attack-comp [weapon off-hand? weapon-attack-modifier weapon-damage-modifier] [attack-comp - (str (weapon-name weapon) (if off-hand? " (off hand)")) + (str (weapon-name weapon) (when off-hand? " (off hand)")) (weapon-attack-description weapon (weapon-damage-modifier weapon off-hand?) (weapon-attack-modifier weapon))]) @@ -2123,20 +2123,20 @@ (let [attacks @(subscribe [::char/attacks id]) all-weapons-map @(subscribe [::mi/all-weapons-map]) main-hand-weapon-kw @(subscribe [::char/main-hand-weapon id]) - main-hand-weapon (if main-hand-weapon-kw (all-weapons-map main-hand-weapon-kw)) + main-hand-weapon (when main-hand-weapon-kw (all-weapons-map main-hand-weapon-kw)) off-hand-weapon-kw @(subscribe [::char/off-hand-weapon id]) weapon-attack-modifier @(subscribe [::char/best-weapon-attack-modifier-fn id]) weapon-damage-modifier @(subscribe [::char/best-weapon-damage-modifier-fn id]) - off-hand-weapon (if off-hand-weapon-kw (all-weapons-map off-hand-weapon-kw))] - (if (or (seq attacks) + off-hand-weapon (when off-hand-weapon-kw (all-weapons-map off-hand-weapon-kw))] + (when (or (seq attacks) main-hand-weapon) (display-section "Attacks" "pointy-sword" [:div.f-s-14 - (if main-hand-weapon + (when main-hand-weapon [:div [weapon-attack-comp main-hand-weapon false weapon-attack-modifier weapon-damage-modifier]]) - (if off-hand-weapon + (when off-hand-weapon [:div [weapon-attack-comp off-hand-weapon true weapon-attack-modifier weapon-damage-modifier]]) [:div (doall @@ -2212,19 +2212,19 @@ (defn resistance-str [{:keys [value qualifier]}] (str (name value) - (if qualifier (str " (" qualifier ")")))) + (when qualifier (str " (" qualifier ")")))) (def no-https-images "Sorry, we don't currently support images that start with https") (defn default-image [race classes] - (if (and (or (= "Human" race) + (when (and (or (= "Human" race) (nil? race)) (= :barbarian (first classes))) "/image/barbarian.png")) (defn section-header-2 [title icon] [:div - (if icon (svg-icon icon 24)) + (when icon (svg-icon icon 24)) [:div.f-s-18.f-w-b.m-b-5 title]]) (defn armor-class-section-2 [id] @@ -2393,7 +2393,7 @@ (if speed-with-armor (speed-with-armor nil) speed)))] - (if (or unarmored-speed-bonus + (when (or unarmored-speed-bonus speed-with-armor) [:span.display-section-qualifier-text "(unarmored)"])]] (if speed-with-armor @@ -2409,23 +2409,23 @@ [:span (feet-str speed)]] [:span.display-section-qualifier-text (str "(" (:name armor) " armor)")]])) (dissoc all-armor :shield)))] - (if unarmored-speed-bonus + (when unarmored-speed-bonus [:div.f-s-18 [:span [:div.speed [:span (feet-str speed)]] [:span.display-section-qualifier-text "(armored)"]]])) - (if (and swim-speed (pos? swim-speed)) + (when (and swim-speed (pos? swim-speed)) [:div.f-s-18 [:div.speed [:span (feet-str swim-speed)]] [:span.display-section-qualifier-text "(swim)"]]) - (if (and flying-speed (pos? flying-speed)) + (when (and flying-speed (pos? flying-speed)) [:div.f-s-18 [:div.speed [:span (feet-str flying-speed)]] [:span.display-section-qualifier-text "(fly)"]])]])) (defn personality-section [title & descriptions] - (if (and (seq descriptions) + (when (and (seq descriptions) (some (complement s/blank?) descriptions)) [:div.m-t-20.t-a-l [:div.f-w-b.f-s-18 title] @@ -2532,7 +2532,7 @@ :x2 "20" :y2 "25" :style stroke-style}] - (if (not max-levels?) + (when (not max-levels?) [:line.stroke-color {:x1 "180" :y1 "10" :x2 "180" @@ -2543,7 +2543,7 @@ 20 0) (+ progress-length buffer 10))] - (if (and (not (js/isNaN x2)) + (when (and (not (js/isNaN x2)) (> x2 buffer)) [:line {:x1 (if (pos? current-level-xps) "10" @@ -2562,19 +2562,19 @@ :fill "white" :font-size "6"} current-level-xps] - (if (not max-levels?) + (when (not max-levels?) [:text.main-text-color {:x "165" :y "30" :fill "white" :font-size "8"} (str "Level " (inc total-levels))]) - (if (not max-levels?) + (when (not max-levels?) [:text.main-text-color {:x "165" :y "36" :fill "white" :font-size "6"} next-level-xps])]]] - (if (and (>= xps next-level-xps) + (when (and (>= xps next-level-xps) (= (or (:handler current-route) current-route) routes/dnd-e5-char-builder-route)) [:button.form-button @@ -2632,12 +2632,12 @@ (if magical-damage-type (weapon-details-field "Damage Type" (common/safe-name magical-damage-type)) (weapon-details-field "Damage Type" (common/safe-name damage-type))) - (if magical-damage-bonus + (when magical-damage-bonus (weapon-details-field "Magical Damage Bonus" magical-damage-bonus)) - (if magical-attack-bonus + (when magical-attack-bonus (weapon-details-field "Magical Attack Bonus" magical-attack-bonus)) (weapon-details-field "Melee/Ranged" (if melee? "melee" "ranged")) - (if range + (when range (weapon-details-field "Range" (str (::weapon/min range) "/" (::weapon/max range) " ft."))) (if magical-finesse? (weapon-details-field "Finesse?" (yes-no magical-finesse?)) @@ -2650,7 +2650,7 @@ (common/mod-str (damage-modifier-fn weapon false)) " damage") "no")) - (if description + (when description [:div.m-t-10 description])]) (defn armor-details-section [{:keys [type @@ -2666,30 +2666,30 @@ {shield-magic-bonus ::magical-ac-bonus :or {shield-magic-bonus 0} :as shield} expanded?] [:div - [:div (str (if type (str (common/safe-name type) ", ")) "base AC " (+ magical-ac-bonus shield-magic-bonus base-ac (if shield 2 0)) (if stealth-disadvantage? ", stealth disadvantage"))] - (if expanded? + [:div (str (when type (str (common/safe-name type) ", ")) "base AC " (+ magical-ac-bonus shield-magic-bonus base-ac (if shield 2 0)) (when stealth-disadvantage? ", stealth disadvantage"))] + (when expanded? [:div [:div.m-t-10.i - (if type + (when type (weapon-details-field "Type" (common/safe-name type))) (weapon-details-field "Base AC" base-ac) - (if (not= magical-ac-bonus 0) + (when (not= magical-ac-bonus 0) (weapon-details-field "Magical AC Bonus" magical-ac-bonus)) - (if shield + (when shield (weapon-details-field "Shield Base AC Bonus" 2)) - (if (and shield + (when (and shield (not= shield-magic-bonus 0)) (weapon-details-field "Shield Magical AC Bonus" shield-magic-bonus)) - (if max-dex-mod + (when max-dex-mod (weapon-details-field "Max DEX AC Bonus" max-dex-mod)) - (if min-str + (when min-str (weapon-details-field "Min Strength" min-str)) (weapon-details-field "Stealth Disadvantage?" (yes-no stealth-disadvantage?)) - (if weight + (when weight (weapon-details-field "Weight" (str weight " lbs."))) - (if description + (when description [:div.m-t-10 (str "Armor: " description)]) - (if (:description shield) + (when (:description shield) [:div.m-t-10 (str "Shield: " (:description shield))])]])]) (defn boolean-icon [v] @@ -2720,9 +2720,9 @@ [:table.w-100-p.t-a-l.striped [:tbody.armor [:tr.f-w-b - {:class-name (if mobile? "f-s-12")} + {:class-name (when mobile? "f-s-12")} [:th.p-10 "Name"] - (if (not mobile?) [:th.p-10 "Proficient?"]) + (when (not mobile?) [:th.p-10 "Proficient?"]) [:th.p-10 "Details"] [:th.p-10 "AC"] [:th.p-10]] @@ -2743,8 +2743,8 @@ [:tr.item.pointer {:on-click (toggle-details-expanded-handler expanded-details k)} [:td.p-10.f-w-b (str (or (::mi/name armor) (:name armor) "unarmored") - (if shield (str " + " (:name shield))))] - (if (not mobile?) + (when shield (str " + " (:name shield))))] + (when (not mobile?) [:td.p-10 (boolean-icon proficient?)]) [:td.p-10.w-100-p [:div @@ -2780,9 +2780,9 @@ [:table.w-100-p.t-a-l.striped [:tbody.weapons [:tr.f-w-b - {:class-name (if mobile? "f-s-12")} + {:class-name (when mobile? "f-s-12")} [:th.p-10 "Name"] - (if (not mobile?) [:th.p-10 "Proficient?"]) + (when (not mobile?) [:th.p-10 "Proficient?"]) [:th.p-10 "Details"] [:th.t-a-c (if mobile? "Atk" [:div.w-60 "Attack"])] [:th.t-a-c (if mobile? "Dmg" [:div.w-60 "Damage"])] @@ -2791,7 +2791,7 @@ (map (fn [[weapon-key {:keys [equipped?]}]] (let [{:keys [name description ranged? ::weapon/type ::weapon/damage-die-count ::weapon/damage-die ::weapon/versatile] :as weapon} (all-weapons-map weapon-key) - proficient? (if has-weapon-prof (has-weapon-prof weapon)) + proficient? (when has-weapon-prof (has-weapon-prof weapon)) expanded? (@expanded-details weapon-key) damage-modifier (weapon-damage-modifier weapon) versatile-damage-die-count (:orcpub.dnd.e5.weapons/damage-die-count versatile) @@ -2852,7 +2852,7 @@ [:span.underline (if expanded? "less" "more")]) [:i.fa.m-l-5 {:class-name (if expanded? "fa-caret-up" "fa-caret-down")}]]]] - (if expanded? + (when expanded? [:tr [:td.p-10 {:col-span 3} @@ -2877,7 +2877,7 @@ [:table.w-100-p.t-a-l.striped [:tbody.other-magic-items [:tr.f-w-b - {:class-name (if mobile? "f-s-12")} + {:class-name (when mobile? "f-s-12")} [:th.p-10 "Name"] [:th.p-10 "Details"] [:th]] @@ -2907,7 +2907,7 @@ [:table.w-100-p.t-a-l.striped [:tbody.equipment [:tr.f-w-b - {:class-name (if mobile? "f-s-12")} + {:class-name (when mobile? "f-s-12")} [:th.p-10 "Name"] [:th.p-10 "Qty."] [:th.p-10 "Details"] @@ -2926,7 +2926,7 @@ [:td.p-10 [:div [:div - (str (if cost + (str (when cost (str (:num cost) " " (common/safe-name (:type cost)) @@ -2949,7 +2949,7 @@ [:table.w-100-p.t-a-l.striped [:tbody [:tr.f-w-b - {:class-name (if mobile? "f-s-12")} + {:class-name (when mobile? "f-s-12")} [:th.p-10 "Name"] [:th.p-10 "Qty."] [:th]] @@ -2981,12 +2981,12 @@ [:table.w-100-p.t-a-l.striped [:tbody [:tr.f-w-b - {:class-name (if mobile? "f-s-12")} + {:class-name (when mobile? "f-s-12")} [:th.p-5 "Name"] [:th.p-5 (if mobile? "Prof?" "Proficient?")] - (if skill-expertise + (when skill-expertise [:th.p-5 "Expertise?"]) - [:th.p-5 (if (not mobile?) [:div.w-40 "Bonus"])]] + [:th.p-5 (when (not mobile?) [:div.w-40 "Bonus"])]] (doall (map (fn [{:keys [key name]}] @@ -2996,7 +2996,7 @@ [:tr [:td.p-5.f-w-b name] [:td.p-5 (boolean-icon proficient?)] - (if skill-expertise + (when skill-expertise [:td.p-5 (boolean-icon expertise?)]) [:td.p-5.f-s-18.f-w-b (roll-button (str name " check: ") @@ -3012,7 +3012,7 @@ tool-bonus-fn @(subscribe [::char/tool-bonus-fn id]) device-type @(subscribe [:device-type]) mobile? (= :mobile device-type)] - (if (seq tool-profs) + (when (seq tool-profs) [:div [:div.flex.align-items-c (svg-icon "stone-crafting" 32) @@ -3021,12 +3021,12 @@ [:table.w-100-p.t-a-l.striped [:tbody [:tr.f-w-b - {:class-name (if mobile? "f-s-12")} + {:class-name (when mobile? "f-s-12")} [:th.p-10 "Name"] [:th.p-10 (if mobile? "Prof?" "Proficient?")] - (if tool-expertise + (when tool-expertise [:th.p-10 "Expertise?"]) - [:th.p-10 (if (not mobile?) [:div.w-40 "Bonus"])]] + [:th.p-10 (when (not mobile?) [:div.w-40 "Bonus"])]] (doall (map (fn [[kw]] @@ -3037,7 +3037,7 @@ [:tr [:td.p-10.f-w-b name] [:td.p-10 (boolean-icon proficient?)] - (if tool-expertise + (when tool-expertise [:td.p-10 (boolean-icon expertise?)]) [:td.p-10.f-s-18.f-w-b (common/bonus-str (tool-bonus-fn kw))] [:td (roll-button (str name " check: ") (str "1d20" (common/mod-str (tool-bonus-fn kw))))]])) @@ -3048,9 +3048,9 @@ (let [ability-bonuses @(subscribe [::char/ability-bonuses id]) language-map @(subscribe [::langs/language-map])] [:div.details-columns - {:class-name (if (= 2 num-columns) "flex")} + {:class-name (when (= 2 num-columns) "flex")} [:div.flex-grow-1.details-column-2 - {:class-name (if (= 2 num-columns) "w-50-p m-l-20")} + {:class-name (when (= 2 num-columns) "w-50-p m-l-20")} [skill-details-section-2 id] [:div.m-t-20 [tool-prof-details-section-2 id]] @@ -3136,7 +3136,7 @@ carried-weapons)) :value main-hand-weapon-kw :on-change (wield-handler ::char/wield-main-hand-weapon id)}] - (if (or (equipped? off-hand-weapon-kw) + (when (or (equipped? off-hand-weapon-kw) (and (equipped? main-hand-weapon-kw) (dual-wield-weapon? main-hand-weapon))) [equipped-section-dropdown @@ -3197,7 +3197,7 @@ [hit-points-section-2 id] [speed-section-2 id] [initiative-section-2 id]] - (if (or non-standard-crits? + (when (or non-standard-crits? non-standard-attack-number?) [:div.flex.justify-cont-s-a.t-a-c [critical-hits-section-2 id] @@ -3222,7 +3222,7 @@ [:div.m-t-30 [armor-section-2 id]] [:div - {:class-name (if (= 2 num-columns) "w-50-p m-l-20")} + {:class-name (when (= 2 num-columns) "w-50-p m-l-20")} [list-item-section "Weapon Proficiencies" "bowman" weapon-profs (partial prof-name @(subscribe [::mi/custom-and-standard-weapons-map]))] [list-item-section "Armor Proficiencies" "mailed-fist" armor-profs (partial prof-name armor/armor-map)]]])) @@ -3248,27 +3248,27 @@ all-traits (concat actions bonus-actions reactions traits attacks) freqs (set (map has-frequency-units? all-traits))] [:div.details-columns - {:class-name (if (= 2 num-columns) "flex")} + {:class-name (when (= 2 num-columns) "flex")} [:div.flex-grow-1.details-column-2 - {:class-name (if (= 2 num-columns) "w-50-p m-l-20")} + {:class-name (when (= 2 num-columns) "w-50-p m-l-20")} [list-item-section "Damage Resistances" "surrounded-shield" resistances resistance-str] [list-item-section "Damage Vulnerabilities" nil damage-vulnerabilities resistance-str] [list-item-section "Damage Immunities" nil damage-immunities resistance-str] [list-item-section "Condition Immunities" nil condition-immunities resistance-str] [list-item-section "Immunities" nil immunities resistance-str] [:div.flex.justify-cont-end.align-items-c - (if (or (freqs ::units/long-rest) + (when (or (freqs ::units/long-rest) (freqs ::units/rest)) [finish-long-rest-button id]) - (if (or (freqs ::units/short-rest) + (when (or (freqs ::units/short-rest) (freqs ::units/rest)) [finish-short-rest-button id]) - (if (freqs ::units/round) + (when (freqs ::units/round) [:button.form-button.p-5.m-l-5 {:on-click (make-event-handler ::char/new-round id)} "new round"]) - (if (freqs ::units/turn) + (when (freqs ::units/turn) [:button.form-button.p-5.m-l-5 {:on-click (make-event-handler ::char/new-turn id)} "new turn"])] @@ -3286,10 +3286,10 @@ total-spellcaster-levels @(subscribe [::char/total-spellcaster-levels id]) levels @(subscribe [::char/levels id])] [:div.details-columns - {:class-name (if (= 2 num-columns) "flex")} + {:class-name (when (= 2 num-columns) "flex")} [:div.flex-grow-1.details-column-2 - {:class-name (if (= 2 num-columns) "w-50-p m-l-20")} - (if (seq spells-known) [spells-known-section + {:class-name (when (= 2 num-columns) "w-50-p m-l-20")} + (when (seq spells-known) [spells-known-section id spells-known spell-slots @@ -3318,9 +3318,9 @@ {:class-name (if selected? "b-orange" "b-gray") :on-click on-select} [:div.hover-opacity-full - {:class-name (if (not selected?) "opacity-5")} + {:class-name (when (not selected?) "opacity-5")} [:div (svg-icon icon 24)] - (if (= device-type :desktop) + (when (= device-type :desktop) [:div.uppercase.f-s-10 title])]]) @@ -3347,7 +3347,7 @@ (defn option-display [{:keys [::entity/key ::entity/options]}] [:div [:span (option-title key)] - (if (seq options) + (when (seq options) [:div.p-l-20 [options-display options]])]) @@ -3389,11 +3389,11 @@ "summary"))] [:div.w-100-p [:div - (if show-summary? + (when show-summary? [:div.f-s-24.f-w-600.m-b-16.m-l-20.text-shadow.flex [character-summary id true true]]) [:div.flex.w-100-p - (if two-columns? + (when two-columns? [:div.w-50-p [summary-details num-columns id]]) [:div @@ -3422,7 +3422,7 @@ "show selections")] [:i.fa.m-l-5 {:class-name (if @show-selections? "fa-caret-up" "fa-caret-down")}]] - (if @show-selections? + (when @show-selections? [character-selections id])]]])))) (defn share-link [id] @@ -3447,9 +3447,9 @@ [:div.flex [:select.builder-option.builder-option-dropdown {:on-change (fn [e] (let [value (event-value e) - id (if (not (s/blank? value)) + id (when (not (s/blank? value)) (js/parseInt value))] - (if id + (when id (reset! party-id id))))} [:option.builder-dropdown-item ""] @@ -3544,7 +3544,7 @@ [labeled-checkbox "Print Abilities Large (and Bonuses Small)" print-large-abilities?]]]] - (if has-spells? + (when has-spells? [:div.m-b-2 [:div.flex [:div @@ -3552,7 +3552,7 @@ [labeled-checkbox "Print Spell Cards" print-spell-cards?]]]]) - (if print-spell-cards? + (when print-spell-cards? [:div.m-b-2 [:div.flex [:div @@ -3560,7 +3560,7 @@ [labeled-checkbox "Print Spell DC and MOD" print-spell-card-dc-mod?]]]]) - (if has-spells? + (when has-spells? [:div.m-b-10 [:div.m-b-10 [:span.f-w-b "Spells Printed"]] @@ -3610,7 +3610,7 @@ device-type @(subscribe [:device-type]) username @(subscribe [:username])] [content-page - (if (not frame?) + (when (not frame?) "Character Page") (remove nil? @@ -3618,7 +3618,7 @@ [:div.m-l-5.hover-shadow.pointer {:on-click #(swap! expanded? not)} [:img.h-32 {:src "/image/world-anvil.jpeg"}]] - (if (and username + (when (and username owner (= owner username)) {:title "Edit" @@ -3627,15 +3627,15 @@ {:title "Print" :icon "print" :on-click (make-print-handler id built-character)} - (if (and username owner (not= owner username)) + (when (and username owner (not= owner username)) [add-to-party-component id])]) [:div.p-10.main-text-color - (if @expanded? + (when @expanded? (let [url js/window.location.href] [:div.p-10.flex.justify-cont-end [:input.input.w-500.bg-white.black {:value (str url - (if (not (s/ends-with? url "?frame=true")) + (when (not (s/ends-with? url "?frame=true")) "?frame=true"))}]])) [character-display id true (if (= :mobile device-type) 1 2)]] :frame? frame?])))) @@ -3670,11 +3670,11 @@ "Item Page" (remove nil? - [(if owner? + [(when owner? {:title "Delete" :icon "trash" :on-click (delete-item-handler item-key)}) - (if owner? + (when owner? {:title "Edit" :icon "pencil" :on-click (make-event-handler ::mi/edit-custom-item item)})]) @@ -3727,7 +3727,7 @@ value (fn [v] (on-change - (if (re-matches #"\d+" v) (js/parseInt v)))) + (when (re-matches #"\d+" v) (js/parseInt v)))) {:class-name "input" :type :number}]) @@ -3744,7 +3744,7 @@ {:on-click (make-event-handler ::mi/toggle-attunement)} (comps/checkbox attunement false) [:span.f-s-24.f-w-b.m-l-5 "Attunement"]] - (if attunement + (when attunement [:div [labeled-checkbox "Any" (= #{:any} (set attunement))] [:div.flex.flex-wrap @@ -3897,7 +3897,7 @@ [4 6 8 10 12 20 100]) :value @(subscribe [::mi/item-damage-die]) :on-change (make-arg-event-handler ::mi/set-item-damage-die js/parseInt)}]] - (if versatile? + (when versatile? [:div.m-l-10.m-t-10 [labeled-dropdown "Versatile Damage Die Number" @@ -3906,7 +3906,7 @@ (range 1 10)) :value @(subscribe [::mi/item-versatile-damage-die-count]) :on-change (make-arg-event-handler ::mi/set-item-versatile-damage-die-count js/parseInt)}]]) - (if versatile? + (when versatile? [:div.m-l-10.m-t-10 [labeled-dropdown "Versatile Damage Die" @@ -3935,13 +3935,13 @@ :title "Ranged"}] :value melee-ranged :on-change (make-arg-event-handler ::mi/set-item-melee-ranged)}]] - (if (= :ranged melee-ranged) + (when (= :ranged melee-ranged) [:div.m-l-10.m-t-10 [:div.f-w-b.m-b-5 "Range Min"] [number-field {:value @(subscribe [::mi/item-range-min]) :on-change (make-arg-event-handler ::mi/set-item-range-min)}]]) - (if (= :ranged melee-ranged) + (when (= :ranged melee-ranged) [:div.m-l-10.m-t-10 [:div.f-w-b.m-b-5 "Range Max"] [number-field @@ -4030,7 +4030,7 @@ (conj items {:value :equals-walking-speed :title "Equals Walking Speed"})))}]] - (if (not= :equals-walking-speed speed-mod-type) + (when (not= :equals-walking-speed speed-mod-type) [:div.w-60.m-l-5 [number-field {:value @(subscribe [::mi/speed-mod-value type-kw]) @@ -4086,13 +4086,13 @@ [:div.m-b-10 [:span.f-s-24.f-w-b "Item Properties"]] [:div.flex.m-b-20 - (if (= type :weapon) + (when (= type :weapon) [:div [:div.f-w-b.m-b-5 "Magical Damage Bonus"] [number-field {:value magical-damage-bonus :on-change #(dispatch [::mi/set-item-damage-bonus %])}]]) - (if (= type :weapon) + (when (= type :weapon) [:div.m-l-20.m-r-20 [:div.f-w-b.m-b-5 "Magical Attack Bonus"] [number-field @@ -4572,7 +4572,7 @@ #(dispatch [::feats/toggle-feat-ability-increase :saves?])]] [:div (let [increases (:ability-increases feat) non-save (disj increases :saves?)] - (if (seq non-save) + (when (seq non-save) (str "= \"Increase your " (common/list-print (map @@ -4580,7 +4580,7 @@ non-save) "or") " score by 1, to a maximum of 20." - (if (increases :saves?) + (when (increases :saves?) " You gain proficiency in the saves using the chosen ability.\""))))]]) (defn feat-skill-proficiency [feat] @@ -4635,7 +4635,7 @@ [:div.m-r-20.m-b-10 (let [kw :armor-prof] [comps/labeled-checkbox - (str "You gain proficiency with " (name armor-type) (if (not= armor-type :shields) " armor")) + (str "You gain proficiency with " (name armor-type) (when (not= armor-type :shields) " armor")) (get-in option [:props kw armor-type]) false #(dispatch [toggle-map-prop-event kw armor-type])])]) @@ -4652,7 +4652,7 @@ [:div.m-r-20.m-b-10 (let [kw :armor-prof] [comps/labeled-checkbox - (str "You gain proficiency with " (name armor-type) (if (not= armor-type :shields) " armor")) + (str "You gain proficiency with " (name armor-type) (when (not= armor-type :shields) " armor")) (get-in feat [:props kw armor-type]) false #(dispatch [::feats/toggle-feat-map-prop kw armor-type])])]) @@ -4873,14 +4873,14 @@ name #(dispatch [edit-trait-name-event i %]) {:class-name "input h-40"}]] - (if types + (when types [:div.flex-grow-1.m-l-5 [labeled-dropdown "Type" {:items types :value type :on-change #(dispatch [edit-trait-type-event i (keyword %)])}]]) - (if edit-trait-level-event + (when edit-trait-level-event [:div.m-l-5 [labeled-dropdown "Unlocked at Level" @@ -5096,7 +5096,7 @@ selections)) :value (get selection-cfg :key) :on-change #(dispatch [value-change-event index (assoc selection-cfg :key (keyword %))])}]] - (if (:key selection-cfg) + (when (:key selection-cfg) [:div [labeled-dropdown "Amount to Select" @@ -5260,10 +5260,10 @@ :on-change #(if (= "new-selection" %) (dispatch [::selections/new-selection]) (dispatch [edit-selection-type-event index (keyword %)]))}]] - (if type + (when type [:div.m-t-10.m-l-5 [modifier-level-selector index level edit-selection-level-event]]) - (if type + (when type [:div.m-t-10.m-l-5 [labeled-dropdown "Amount to Select at this Level" @@ -5272,7 +5272,7 @@ (range 1 11)) :value (or num 1) :on-change #(dispatch [edit-selection-num-event index (js/parseInt %)])}]]) - (if (or type level num) + (when (or type level num) [:div.m-t-10 [:button.form-button.m-l-5 {:on-click #(dispatch [delete-selection-event index])} @@ -5285,7 +5285,7 @@ edit-modifier-level-event delete-modifier-event] (let [mod-values (modifier-values) - {:keys [name values component value-fn]} (if type (mod-values type))] + {:keys [name values component value-fn]} (when type (mod-values type))] [:div [:div.flex.flex-wrap.align-items-end.m-b-20 [:div.m-t-10 @@ -5302,7 +5302,7 @@ mod-values))) :value (if type (clojure.core/name type) :select) :on-change #(dispatch [edit-modifier-type-event index (keyword %)])}]] - (if type + (when type [:div.m-t-10.m-l-5 [modifier-level-selector index level edit-modifier-level-event]]) (if (and type values) @@ -5316,9 +5316,9 @@ values) :value (or value :select) :on-change #(dispatch [edit-modifier-value-event index (value-fn %)])}]] - (if component + (when component [:div.m-l-5 [component index value edit-modifier-value-event]])) - (if (or type level value) + (when (or type level value) [:div.m-t-10 [:button.form-button.m-l-5 {:on-click #(dispatch [delete-modifier-event index])} @@ -5367,7 +5367,7 @@ {:on-click #(swap! expanded? not)} [:i.fa.fa-question-circle.m-r-2] [:i.fa {:class-name (if @expanded? "fa-caret-up" "fa-caret-down")}]]] - (if @expanded? + (when @expanded? [:div.bg-light.f-s-18 help])]))) @@ -5531,12 +5531,12 @@ :value spellcaster? :on-change #(dispatch [::classes/set-class-prop :spellcasting - (if (= "true" %) + (when (= "true" %) {:level-factor 3 :known-mode :schedule :ability ::char/cha :spells-known classes/third-caster-spells-known-schedule})])}] - (if spellcaster? + (when spellcaster? [:div.m-l-5 [labeled-dropdown "What spell list does this class use?" @@ -5551,9 +5551,9 @@ spell-lists)) :value (get-in class [:spellcasting :spell-list-kw]) :on-change #(dispatch [::classes/set-class-path-prop - [:spellcasting :spell-list-kw] (if (not= "custom" %) + [:spellcasting :spell-list-kw] (when (not= "custom" %) (keyword %))])}]]) - (if spellcaster? + (when spellcaster? [:div.m-l-5 [labeled-dropdown "Spellcasting ability" @@ -5565,7 +5565,7 @@ opt/abilities)) :value (get-in class [:spellcasting :ability]) :on-change #(dispatch [::classes/set-class-path-prop [:spellcasting :ability] (keyword "orcpub.dnd.e5.character" %)])}]]) - (if spellcaster? + (when spellcaster? [:div.m-l-5 [labeled-dropdown "At what level does this class first gain spell slots?" @@ -5580,7 +5580,7 @@ 1 classes/full-caster-spells-known-schedule 2 classes/half-caster-spells-known-schedule 3 classes/third-caster-spells-known-schedule)]))}]])] - (if (and spellcaster? + (when (and spellcaster? (not (get-in class [:spellcasting :spell-list-kw]))) (let [cantrips? (get-in class [:spellcasting :cantrips?])] [:div @@ -5597,7 +5597,7 @@ :on-change #(dispatch [::classes/set-class-path-prop [:spellcasting :cantrips?] (= % "true")])}]] - (if cantrips? + (when cantrips? [:div.m-l-5 [labeled-dropdown "How many cantrips does this class know at first level?" @@ -5610,7 +5610,7 @@ :on-change #(dispatch [::classes/set-class-path-prop [:spellcasting :cantrips-known 1] (js/parseInt %)])}]])] - (if cantrips? + (when cantrips? [:div.m-b-20 [:div.f-s-18.f-w-b.m-b-5 "At what other levels does this class gain cantrips?"] (let [cantrips-known (get-in class [:spellcasting :cantrips-known])] @@ -5758,7 +5758,7 @@ ::classes/set-subclass-prop ] ] - (if (#{:fighter :rogue :warlock :cleric :paladin} class-key) + (when (#{:fighter :rogue :warlock :cleric :paladin} class-key) (let [spellcasting (get subclass :spellcasting) spellcasting? (some? spellcasting)] [:div.m-b-20 @@ -5843,7 +5843,7 @@ index value set-spell-value-event]] - (if (or level value) + (when (or level value) [:div.m-t-10 [:button.form-button.m-l-5 {:on-click #(dispatch [delete-spell-event index])} @@ -6385,7 +6385,7 @@ value-to-item (range 1 36))) :value (get hit-points :die-count) - :on-change #(let [v (js/parseInt %)] (dispatch [::monsters/set-monster-path-prop [:hit-points :die-count] (if (not (js/isNaN v)) v)]))}]] + :on-change #(let [v (js/parseInt %)] (dispatch [::monsters/set-monster-path-prop [:hit-points :die-count] (when (not (js/isNaN v)) v)]))}]] [:div.m-l-5.m-b-20 [labeled-dropdown "HP Die" @@ -6396,13 +6396,13 @@ dice/dice-sides)) :value (get hit-points :die) :on-change #(let [v (js/parseInt %)] - (dispatch [::monsters/set-monster-path-prop [:hit-points :die] (if (not (js/isNaN v)) v)]))}]] + (dispatch [::monsters/set-monster-path-prop [:hit-points :die] (when (not (js/isNaN v)) v)]))}]] [:div.m-l-5.m-b-20 [input-builder-field [:span.f-w-b.m-b-5.f-s-16 "HP Modifier"] (get hit-points :modifier 0) #(let [v (js/parseInt %)] - (dispatch [::monsters/set-monster-path-prop [:hit-points :modifier] (if (not (js/isNaN v)) v)])) + (dispatch [::monsters/set-monster-path-prop [:hit-points :modifier] (when (not (js/isNaN v)) v)])) {:class-name "input h-40"}]] [monster-input-field "Speed" @@ -6444,7 +6444,7 @@ value-to-item (range 0 18))) :value (get saving-throws simple-kw) - :on-change #(dispatch [::monsters/set-monster-path-prop [:saving-throws simple-kw] (let [parsed (js/parseInt %)] (if (not (js/isNaN parsed)) parsed))])}])]) + :on-change #(dispatch [::monsters/set-monster-path-prop [:saving-throws simple-kw] (let [parsed (js/parseInt %)] (when (not (js/isNaN parsed)) parsed))])}])]) opt/abilities))]] [:div.m-b-20 [:div.f-s-24.f-w-b. "Skills"] @@ -6530,7 +6530,7 @@ monsters)) :value monster :on-change on-key-change}] - (if monster + (when monster [:div.m-l-5.m-b-10 [labeled-dropdown "Number" @@ -6679,7 +6679,7 @@ remaining-conditions (remove (comp (disj used-conditions type) :key) opt/conditions)] - (if (seq remaining-conditions) + (when (seq remaining-conditions) [:div.flex.align-items-end [:div.m-r-5 w-155 @@ -6692,12 +6692,12 @@ remaining-conditions)) :value type :on-change #(dispatch [::combat/set-monster-condition-type monster individual-index index (keyword %)])}]] - (if type + (when type [:div.flex.flex-wrap [duration-selector "Hours" :hours 24 monster individual-index duration index] [duration-selector "Minutes" :minutes 60 monster individual-index duration index] [duration-selector "Rounds" :rounds 10 monster individual-index duration index]]) - (if deletable? + (when deletable? [:button.form-button.f-s-14 {:on-click #(dispatch [::combat/delete-monster-condition monster individual-index index])} [:i.fa.fa-trash]])]))) @@ -6852,13 +6852,13 @@ [:button.form-button.m-l-5.m-b-10 {:on-click #(dispatch [::combat/next-initiative monster-map])} [:i.fa.fa-play] - (if (not mobile?) + (when (not mobile?) [:span.m-l-5 "next initiative"])] [:button.form-button.m-l-5.m-b-10 {:on-click #(dispatch [::combat/set-combat-prop :ordered? true])} [:i.fa.fa-arrow-down] - (if (not mobile?) + (when (not mobile?) [:span.m-l-5 "order"])]]] [:div.flex.flex-wrap [:div.m-b-20.m-r-20.t-a-c @@ -6888,7 +6888,7 @@ [:div.flex.justify-cont-s-b.align-items-c [:div.f-s-18.f-w-b.flex.flex-wrap.align-items-c.pointer.w-100-p {:on-click #(swap! expanded-rows update path not)} - (if (and current-initiative + (when (and current-initiative (= current-initiative initiative)) [:i.fa.fa-play.f-s-24.m-r-10]) [input-builder-field @@ -6938,7 +6938,7 @@ [:i.fa {:class-name (if (get @expanded-rows path) "fa-caret-up" "fa-caret-down")}]] - (if (get @expanded-rows path) + (when (get @expanded-rows path) (if character [character-display (:db/id character) false (if mobile? 1 2)] [:div.p-t-10.p-b-10 @@ -6972,7 +6972,7 @@ [:div.f-s-16.f-w-b w-160 "Conditions"] - (if (seq conditions) + (when (seq conditions) [:div.f-s-16.f-w-b.m-l-60 "Duration"])] (doall (map-indexed @@ -7187,9 +7187,9 @@ [:div.m-b-40 (base-builder-field "Description" [textarea-field {:value description :on-change #(dispatch [::mi/set-item-description %])}])] - (if (= :armor type) + (when (= :armor type) [:div.m-b-40 [base-armor-selector]]) - (if (= :weapon type) + (when (= :weapon type) [:div.m-b-40 [base-weapon-selector]]) [:div.m-b-40 [attunement-selector attunement]] @@ -7234,13 +7234,13 @@ [:span.m-l-10.f-s-24 (let [num (count items) final-type-name (if plural (if (not= 1 num) plural type-name) - (str type-name (if (not= 1 num) "s")))] + (str type-name (when (not= 1 num) "s")))] (str num " " (capitalize-words final-type-name)))]] [:div.orange.pointer [:i.fa.m-r-5 {:class-name (if @expanded? "fa-caret-up" "fa-caret-down")}] [:span.underline (if @expanded? "collapse" "expand")]]] - (if @expanded? + (when @expanded? [:div.bg-lighter.p-10 [:div.flex.justify-cont-end [:button.form-button.m-l-5 @@ -7434,7 +7434,7 @@ [:i.fa.m-r-5 {:class-name (if @expanded? "fa-caret-up" "fa-caret-down")}] [:span.pointer.underline (if @expanded? "collapse" "expand")]]] - (if @expanded? + (when @expanded? [:div.bg-lighter.p-10 [:div.flex.justify-cont-end.uppercase.align-items-c.m-b-10 [:button.form-button.m-l-5 @@ -7468,7 +7468,7 @@ {:on-click (make-event-handler ::e5/export-all-plugins)} "Export All"]] [:div.flex.justify-cont-end - (if @(subscribe [::char/delete-plugin-confirmation-shown?]) + (when @(subscribe [::char/delete-plugin-confirmation-shown?]) [:div.p-20.flex.justify-cont-end [:div [:div.m-b-10 "Are you sure you want to delete ALL Option sources?"] @@ -7551,12 +7551,12 @@ "View Character"]]) [:div.m-t-20 [:button.link-button - {:class-name (if (not has-history?) "disabled") - :on-click #(if has-history? (dispatch [::char/previous-question]))} + {:class-name (when (not has-history?) "disabled") + :on-click #(when has-history? (dispatch [::char/previous-question]))} "Back"] [:button.form-button - {:on-click #(if current-answer (dispatch [::char/next-question])) - :class-name (if (nil? current-answer) "disabled")} + {:on-click #(when current-answer (dispatch [::char/next-question])) + :class-name (when (nil? current-answer) "disabled")} "Next"]]]) :hide-header-message? true]) @@ -7709,11 +7709,11 @@ {:style character-display-style} [:div.flex.justify-cont-end.uppercase.align-items-c [share-link id] - (if (= username owner) + (when (= username owner) [:button.form-button {:on-click (make-event-handler :edit-character @(subscribe [::char/character id]))} "edit"]) - (if (= username owner) + (when (= username owner) [:button.form-button.m-l-5 {:on-click (make-event-handler ::char/save-character id)} "save"]) @@ -7730,7 +7730,7 @@ :print-character-sheet-style? 1 :print-spell-card-dc-mod? true})} "print"] - (if (and (= username owner) (seq folders)) + (when (and (= username owner) (seq folders)) [:select.form-button.m-l-5.builder-dropdown {:value (or current-folder-id "") :on-change (fn [e] @@ -7745,11 +7745,11 @@ ^{:key (:db/id f)} [:option.builder-dropdown-item {:value (:db/id f)} (::folder/name f)]) (sort-by ::folder/name folders)))]) - (if (= username owner) + (when (= username owner) [:button.form-button.m-l-5 {:on-click (make-event-handler ::char/show-delete-confirmation id)} "delete"])] - (if @(subscribe [::char/delete-confirmation-shown? id]) + (when @(subscribe [::char/delete-confirmation-shown? id]) [:div.p-20.flex.justify-cont-end [:div [:div.m-b-10 "Are you sure you want to delete this character?"] @@ -7785,12 +7785,12 @@ [:div.list-character-summary [character-summary-2 summary true owner false]]]] [:div.orange.pointer.m-r-10 - (if (not= @(subscribe [:device-type]) :mobile) [:span.underline (if expanded? + (when (not= @(subscribe [:device-type]) :mobile) [:span.underline (if expanded? "collapse" "open")]) [:i.fa.m-l-5 {:class-name (if expanded? "fa-caret-up" "fa-caret-down")}]]] - (if expanded? + (when expanded? [expanded-character-list-item id owner username char-page-route])]])) (defn folder-item [f expanded-characters selected-ids username filtered-char-ids] @@ -7869,7 +7869,7 @@ (.stopPropagation e) (dispatch [::folder/delete-folder folder-id]))} "delete"]]]]) - (if folder-expanded? + (when folder-expanded? [:div.item-list (doall (map @@ -8006,8 +8006,8 @@ :on-click #(dispatch [:new-character])} {:title "Make Party" :icon "users" - :class-name (if (not has-selected?) "opacity-5 cursor-disabled") - :on-click (if has-selected? (make-event-handler ::party/make-party selected-ids))} + :class-name (when (not has-selected?) "opacity-5 cursor-disabled") + :on-click (when has-selected? (make-event-handler ::party/make-party selected-ids))} {:title "New Folder" :icon "folder" :on-click #(dispatch [::folder/create-folder])}] @@ -8156,16 +8156,16 @@ [:div.list-character-summary [character-summary-2 summary true owner true false]]]] [:div.orange.pointer.m-r-10 - (if (not= device-type :mobile) [:span.underline (if expanded? + (when (not= device-type :mobile) [:span.underline (if expanded? "collapse" "open")]) [:i.fa.m-l-5 {:class-name (if expanded? "fa-caret-up" "fa-caret-down")}]]] - (if expanded? + (when expanded? [:div {:style character-display-style} [:div.flex.justify-cont-end.uppercase.align-items-c - (if (= username owner) + (when (= username owner) [:button.form-button {:on-click #(dispatch [:edit-character @(subscribe [::char/character character-id])])} "edit"]) @@ -8206,11 +8206,11 @@ [:button.form-button.m-l-5 {:on-click #(dispatch [:route (routes/match-route (routes/path-for routes/dnd-e5-monster-page-route :key key))])} "view"] - (if homebrew? + (when homebrew? [:button.form-button.m-l-5 {:on-click (make-event-handler ::monsters/edit-monster monster)} "edit"]) - (if homebrew? + (when homebrew? [:button.form-button.m-l-5 {:on-click (make-event-handler ::monsters/delete-monster monster)} "delete"])] @@ -8341,27 +8341,27 @@ {:on-click (make-event-handler :toggle-spell-expanded name)} [:div.m-l-10 [:div.f-s-24.f-w-600.p-t-20.flex - (if homebrew? + (when homebrew? [:div.m-r-10 (svg-icon "beer-stein" 24 @(subscribe [:theme]))]) [spell-summary name level school ritual true 12]]] [:div.orange.pointer.m-r-10 - (if (not= device-type :mobile) [:span.underline (if expanded? + (when (not= device-type :mobile) [:span.underline (if expanded? "collapse" "open")]) [:i.fa.m-l-5 {:class-name (if expanded? "fa-caret-up" "fa-caret-down")}]]] - (if expanded? + (when expanded? [:div.p-10 {:style character-display-style} [:div.flex.justify-cont-end.uppercase.align-items-c [:button.form-button.m-l-5 {:on-click (make-event-handler :route spell-page-route)} "view"] - (if homebrew? + (when homebrew? [:button.form-button.m-l-5 {:on-click (make-event-handler ::spells/edit-spell spell)} "edit"]) - (if homebrew? + (when homebrew? [:button.form-button.m-l-5 {:on-click (make-event-handler ::spells/delete-spell spell)} "delete"]) @@ -8408,27 +8408,27 @@ [:div.f-s-24.f-w-600.p-t-20 [item-summary item]]] [:div.orange.pointer.m-r-10 - (if (not= device-type :mobile) [:span.underline (if expanded? + (when (not= device-type :mobile) [:span.underline (if expanded? "collapse" "open")]) [:i.fa.m-l-5 {:class-name (if expanded? "fa-caret-up" "fa-caret-down")}]]] - (if expanded? + (when expanded? [:div.p-10 {:style character-display-style} [:div.flex.justify-cont-end.uppercase.align-items-c [:button.form-button.m-l-5 {:on-click (make-event-handler :route item-page-route)} "view"] - (if (= username owner) + (when (= username owner) [:button.form-button.m-l-5 {:on-click (make-event-handler ::mi/edit-custom-item @(subscribe [::mi/custom-item id]))} "edit"]) - (if (= username owner) + (when (= username owner) [:button.form-button.m-l-5 {:on-click (make-event-handler ::mi/show-delete-confirmation id)} "delete"])] - (if @(subscribe [::mi/delete-confirmation-shown? id]) + (when @(subscribe [::mi/delete-confirmation-shown? id]) [:div.p-20.flex.justify-cont-end [:div [:div.m-b-10 "Are you sure you want to delete this item?"]