Skip to content

Commit

Permalink
Merge pull request #7829 from heyshiloh/nr-7493
Browse files Browse the repository at this point in the history
Issue 7493: Add credit cost of cards alongside their names and influence in deck builder
  • Loading branch information
NoahTheDuke authored Oct 29, 2024
2 parents eb00a55 + 9136104 commit 863467f
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 4 deletions.
39 changes: 35 additions & 4 deletions src/cljs/nr/deckbuilder.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
[nr.utils :refer [alliance-dots banned-span cond-button
deck-points-card-span dots-html format->slug format-date-time
influence-dot influence-dots mdy-formatter non-game-toast num->percent
restricted-span rotated-span set-scroll-top slug->format store-scroll-top]]
restricted-span rotated-span set-scroll-top slug->format store-scroll-top render-message]]
[nr.ws :as ws]
[reagent-modals.modals :as reagent-modals]
[reagent.core :as r]
Expand Down Expand Up @@ -387,6 +387,19 @@
(set-deck-on-state s deck)
(put! select-channel (:deck @s)))))))

(defn card-cost-html
[s card]
(let [show-credit-cost (:show-credit-cost @s)
show-mu-cost (:show-mu-cost @s)
is-edit (:edit @s)]
(when (or show-credit-cost show-mu-cost)
[:div.card-cost-wrapper
[:span.card-cost {:class (when is-edit "edit")}
(when show-mu-cost
(when-let [mu (:memoryunits card)] [:div.cost-item (render-message (str mu "[mu] "))]))
(when show-credit-cost
(when-let [cost (:cost card)] [:div.cost-item (render-message (str cost "[credit]"))]))]])))

(defn card-influence-html
"Returns hiccup-ready vector with dots for influence as well as rotated / restricted / banned symbols"
[format card qty in-faction allied?]
Expand Down Expand Up @@ -697,7 +710,7 @@
(not valid) " invalid"))
:on-mouse-enter #(when (:setname card) (put! zoom-channel line))
:on-mouse-leave #(put! zoom-channel false)} name]
(card-influence-html format card modqty infaction allied)])
[card-influence-html format card modqty infaction allied]])
card)])

(defn- build-deck-points-tooltip [deck]
Expand Down Expand Up @@ -800,7 +813,8 @@
:card (:card line)})
:type "button"} "+"]
[line-name-span deck line]]
[line-span deck line])]))]))])
[line-span deck line])
[card-cost-html s (:card line)]]))]))])

(defn decklist-notes
[deck]
Expand Down Expand Up @@ -850,6 +864,20 @@
;; (tr [:deck-builder.create-game "Create Game"])])
])

(defn view-toggles
[s deck]
[:div.decklist-view-options
[:h4 "View Options"]
(when (= (:side (:identity deck)) "Runner")
[:div
[:input {:type "checkbox" :checked (:show-mu-cost @s)
:on-change #(swap! s assoc :show-mu-cost (.. % -target -checked))}]
[:span "Show Memory Cost"]])
[:div
[:input {:type "checkbox" :checked (:show-credit-cost @s)
:on-change #(swap! s assoc :show-credit-cost (.. % -target -checked))}]
[:span "Show Credit Cost"]]])

(defn selected-panel
[s]
[:div.decklist
Expand All @@ -863,6 +891,7 @@
:else [view-buttons s deck])
[:h3 (:name deck)]
[decklist-header deck cards]
[view-toggles s deck]
[decklist-contents s deck cards]
(when-not (:edit @s)
[decklist-notes deck])]))])
Expand Down Expand Up @@ -1050,7 +1079,9 @@
:deck nil
:side-filter all-sides-filter
:faction-filter all-factions-filter
:format-filter all-formats-filter})
:format-filter all-formats-filter
:show-credit-cost false
:show-mu-cost false})
decks (r/cursor app-state [:decks])
user (r/cursor app-state [:user])
decks-loaded (r/cursor app-state [:decks-loaded])
Expand Down
34 changes: 34 additions & 0 deletions src/css/deckbuilder.styl
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@
overflow: auto
-webkit-overflow-scrolling: touch

.decklist-view-options
margin-top: 1rem;

.button-bar
padding-bottom: 8px

Expand All @@ -121,11 +124,42 @@
margin-top: 10px
columns(2, 5px)

.line:hover
background: rgba(19 26 35 .46)

.line
position: relative
overflow: visible
line-height: 20px
white-space:pre
columns(2, 1rem)

.card-cost-wrapper
display: flex;
position:relative;
overflow: visible;
width: auto;
justify-content flex-end;

.card-cost
line-height: .75rem;
margin-top: .25rem;
margin-right: 2rem;
display: inline-flex;
position: absolute;
justify-content: left;

.edit
line-height: .75rem;
margin-top: .35rem;
margin-right: .5rem;
.cost-item
display: inline-flex;
margin-inline: .1rem;

.credit
margin-left: .1rem


button.small
margin: 3px 6px 3px 0
Expand Down

0 comments on commit 863467f

Please sign in to comment.