Skip to content

Commit

Permalink
Merge pull request #291 from datdamnzotz/265-short-rest-button-missin…
Browse files Browse the repository at this point in the history
…g-warlocks

Added finish short rest button for warlock
  • Loading branch information
datdamnzotz authored Dec 28, 2019
2 parents a39a66a + 23dae8e commit 29b7912
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/cljc/orcpub/dnd/e5/units.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,8 @@
(units ::long-rest amount))

(def long-rests-1 (long-rests 1))

(defn short-rests [amount]
(units ::short-rest amount))

(def short-rests-1 (short-rests 1))
13 changes: 13 additions & 0 deletions src/cljs/orcpub/dnd/e5/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2166,6 +2166,19 @@
::units5e/long-rest
::units5e/rest)))

(reg-event-fx
::char5e/finish-short-rest-warlock
(fn [{:keys [db]} [_ id]]
(clear-period db
id
(fn [character]
(update
character
::entity/values
dissoc
::spells/slots-used))
::units5e/rest)))

(reg-event-fx
::char5e/finish-short-rest
(fn [{:keys [db]} [_ id]]
Expand Down
30 changes: 25 additions & 5 deletions src/cljs/orcpub/dnd/e5/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2059,19 +2059,40 @@
(defn finish-long-rest-fn [id]
#(dispatch [::char/finish-long-rest id]))

(defn finish-short-rest-fn [id]
#(dispatch [::char/finish-short-rest id]))

(defn finish-short-rest-warlock-fn [id]
#(dispatch [::char/finish-short-rest-warlock id]))

(def finish-long-rest-handler (memoize finish-long-rest-fn))

(def finish-short-rest-handler (memoize finish-short-rest-fn))

(def finish-short-rest-handler-warlock (memoize finish-short-rest-warlock-fn))

(defn finish-long-rest-button [id]
[:button.form-button.p-5
{:on-click (finish-long-rest-handler id)}
"finish long rest"])

(defn finish-short-rest-button [id]
[:button.form-button.p-5.m-l-5
{:on-click (finish-short-rest-handler id)}
"finish short rest"])

(defn finish-short-rest-button-warlock [id]
[:button.form-button.p-5.m-l-5
{:on-click (finish-short-rest-handler-warlock id)}
"finish short rest"])

(defn spells-known-section [id spells-known spell-slots spell-modifiers spell-slot-factors total-spellcaster-levels levels]
(let [mobile? @(subscribe [:mobile?])
multiclass? (> (count spell-slot-factors) 1)
prepares-spells @(subscribe [::char/prepares-spells id])
pact-magic? @(subscribe [::char/pact-magic? id])
prepare-spell-count-fn @(subscribe [::char/prepare-spell-count-fn id])]
prepare-spell-count-fn @(subscribe [::char/prepare-spell-count-fn id])
classes (set @(subscribe [::char/classes id]))]
[display-section
"Spells"
"spell-book"
Expand Down Expand Up @@ -2102,7 +2123,8 @@
[:div.m-b-20
[spells-tables id spells-known spell-slots spell-modifiers]]]
nil
[[finish-long-rest-button id]]]))
[[finish-long-rest-button id]
(when (contains? classes :warlock) [finish-short-rest-button-warlock id])]]))

(defn equipment-section [title icon-name equipment equipment-map]
[list-display-section title icon-name
Expand Down Expand Up @@ -3248,9 +3270,7 @@
[finish-long-rest-button id])
(if (or (freqs ::units/short-rest)
(freqs ::units/rest))
[:button.form-button.p-5.m-l-5
{:on-click (make-event-handler ::char/finish-short-rest id)}
"finish short rest"])
[finish-short-rest-button id])
(if (freqs ::units/round)
[:button.form-button.p-5.m-l-5
{:on-click (make-event-handler ::char/new-round id)}
Expand Down

0 comments on commit 29b7912

Please sign in to comment.