Skip to content

Revert "Alt art grouping" #8142

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions src/clj/tasks/images.clj
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,10 @@
(println "Removing old images from db cards")
(mc/update db card-collection {} {$unset {:faces 1}} {:multi true})
(mc/update db card-collection {} {$unset {:images 1}} {:multi true}))
;; note: this should select a period, perhaps preceeded by an alphabetic string,
;; so long as it either has front,back,or some numbers behind it
;; the excess dots are because the lookbehind needs to be fixed width
;; but this ensures we don't split on "front.", and instead split on "." for multi-faced cards
(def ^:cost image-select-regex #"(?<=(.tank|house|ewery|front|.back|....[0123456789]))[a-zA-Z]*\.")

(defn- add-flip-card-image
[db base-path lang resolution art-set filename]
(let [code-face (first (str/split filename image-select-regex))
(let [code-face (first (str/split filename #"\."))
code-face-split (str/split code-face #"-")
code (first code-face-split)
face (second code-face-split)
Expand All @@ -71,14 +66,14 @@
(let [filename (.getName f)]
(if (str/includes? filename "-")
(add-flip-card-image db base-path lang resolution art-set filename)
(let [code (first (str/split filename image-select-regex))
(let [code (first (str/split filename #"\."))
k (str/join "." ["images" (name lang) (name resolution) (name art-set)])
prev-k-root (if (= :stock art-set) code (name art-set))
prev-k (str/join "." ["images" (name lang) (name resolution) prev-k-root])
path (str/join "/" [base-path (name lang) (name resolution) (name art-set) filename])]
(when-not (some #(= % code) cards-to-skip)
(mc/update db card-collection {:code code} {$addToSet {k path}})
(mc/update db card-collection {:previous-versions {$elemMatch {:code code}}} {$addToSet {prev-k path}})))))))
(mc/update db card-collection {:code code} {$set {k path}})
(mc/update db card-collection {:previous-versions {$elemMatch {:code code}}} {$set {prev-k path}})))))))

(defn- add-alt-images
"All all images in the specified alt directory"
Expand Down
20 changes: 5 additions & 15 deletions src/cljs/nr/cardbrowser.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -199,24 +199,15 @@
[card]
(let [lang (get-in @app-state [:options :language] "en")
res (get-in @app-state [:options :card-resolution] "default")
art (if (keyword? (:art card)) (:art card) :stock)
art-index (get card :art-index 0)]
[(nth (get-image-path (:images card) (keyword lang) (keyword res) art) art-index)]))
art (if (keyword? (:art card)) (:art card) :stock)]
(get-image-path (:images card) (keyword lang) (keyword res) art)))

(defn- alt-version-from-string
"Given a string name, get the keyword version or nil"
[setname]
(when-let [alt (find-first #(= setname (:name %)) (:alt-info @app-state))]
(keyword (:version alt))))

(defn- card-arts-for-key
[card key]
(let [lang (get-in @app-state [:options :language] "en")
res (get-in @app-state [:options :card-resolution] "default")]
(if-let [arts (get-in card [:images (keyword lang) (keyword res) key])]
(vec (map-indexed (fn [idx item] (assoc card :art key :art-index idx)) arts))
[(assoc card :art "" :art-index 0)])))

(defn- expand-alts
[only-version acc card]
(let [lang (get-in @app-state [:options :language] "en")
Expand All @@ -234,7 +225,7 @@
(show-alt-art? true))
(->> filtered-images
(concat [""])
(mapcat #(card-arts-for-key card %))
(map #(if % (assoc card :art %) card))
(map #(if (not= "" (:art %)) (dissoc % :previous-versions) %))
(concat acc))
(conj acc card))))
Expand Down Expand Up @@ -295,11 +286,10 @@
art (:art card)
code-kw (keyword (:future-version card (:code card)))
alts (:alt-arts (:options @app-state))
alt-index (get card :art-index 0)
new-alts (cond
(keyword? art) (assoc alts code-kw [(name art) alt-index])
(keyword? art) (assoc alts code-kw (name art))
is-old-card (assoc alts code-kw (:code card))
:else (dissoc alts code-kw))]
:else (dissoc alts code-kw))] ; remove the key entirely if the newest card is selected
(swap! app-state assoc-in [:options :alt-arts] new-alts)
(nr.account/post-options (partial post-response))))

Expand Down
6 changes: 1 addition & 5 deletions src/cljs/nr/gameboard/board.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@
"stock")
card (if (or (:face card) (:images card)) card (get @all-cards (get-title card)))
images (image-or-face card)]
(if (sequential? art)
(let [art-urls (get-image-path images (keyword lang) (keyword res) (keyword (first art)))
chosen-art (nth art-urls (second art))]
[chosen-art])
(get-image-path images (keyword lang) (keyword res) (keyword art)))))
(get-image-path images (keyword lang) (keyword res) (keyword art))))


(defonce button-channel (chan))
Expand Down
Loading