Skip to content

Commit a157c04

Browse files
authored
Merge pull request #8142 from mtgred/revert-8012-alt-art-grouping
Revert "Alt art grouping"
2 parents 46ce3ca + 29672b4 commit a157c04

File tree

3 files changed

+10
-29
lines changed

3 files changed

+10
-29
lines changed

src/clj/tasks/images.clj

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,10 @@
4343
(println "Removing old images from db cards")
4444
(mc/update db card-collection {} {$unset {:faces 1}} {:multi true})
4545
(mc/update db card-collection {} {$unset {:images 1}} {:multi true}))
46-
;; note: this should select a period, perhaps preceeded by an alphabetic string,
47-
;; so long as it either has front,back,or some numbers behind it
48-
;; the excess dots are because the lookbehind needs to be fixed width
49-
;; but this ensures we don't split on "front.", and instead split on "." for multi-faced cards
50-
(def ^:cost image-select-regex #"(?<=(.tank|house|ewery|front|.back|....[0123456789]))[a-zA-Z]*\.")
5146

5247
(defn- add-flip-card-image
5348
[db base-path lang resolution art-set filename]
54-
(let [code-face (first (str/split filename image-select-regex))
49+
(let [code-face (first (str/split filename #"\."))
5550
code-face-split (str/split code-face #"-")
5651
code (first code-face-split)
5752
face (second code-face-split)
@@ -71,14 +66,14 @@
7166
(let [filename (.getName f)]
7267
(if (str/includes? filename "-")
7368
(add-flip-card-image db base-path lang resolution art-set filename)
74-
(let [code (first (str/split filename image-select-regex))
69+
(let [code (first (str/split filename #"\."))
7570
k (str/join "." ["images" (name lang) (name resolution) (name art-set)])
7671
prev-k-root (if (= :stock art-set) code (name art-set))
7772
prev-k (str/join "." ["images" (name lang) (name resolution) prev-k-root])
7873
path (str/join "/" [base-path (name lang) (name resolution) (name art-set) filename])]
7974
(when-not (some #(= % code) cards-to-skip)
80-
(mc/update db card-collection {:code code} {$addToSet {k path}})
81-
(mc/update db card-collection {:previous-versions {$elemMatch {:code code}}} {$addToSet {prev-k path}})))))))
75+
(mc/update db card-collection {:code code} {$set {k path}})
76+
(mc/update db card-collection {:previous-versions {$elemMatch {:code code}}} {$set {prev-k path}})))))))
8277

8378
(defn- add-alt-images
8479
"All all images in the specified alt directory"

src/cljs/nr/cardbrowser.cljs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -199,24 +199,15 @@
199199
[card]
200200
(let [lang (get-in @app-state [:options :language] "en")
201201
res (get-in @app-state [:options :card-resolution] "default")
202-
art (if (keyword? (:art card)) (:art card) :stock)
203-
art-index (get card :art-index 0)]
204-
[(nth (get-image-path (:images card) (keyword lang) (keyword res) art) art-index)]))
202+
art (if (keyword? (:art card)) (:art card) :stock)]
203+
(get-image-path (:images card) (keyword lang) (keyword res) art)))
205204

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

212-
(defn- card-arts-for-key
213-
[card key]
214-
(let [lang (get-in @app-state [:options :language] "en")
215-
res (get-in @app-state [:options :card-resolution] "default")]
216-
(if-let [arts (get-in card [:images (keyword lang) (keyword res) key])]
217-
(vec (map-indexed (fn [idx item] (assoc card :art key :art-index idx)) arts))
218-
[(assoc card :art "" :art-index 0)])))
219-
220211
(defn- expand-alts
221212
[only-version acc card]
222213
(let [lang (get-in @app-state [:options :language] "en")
@@ -234,7 +225,7 @@
234225
(show-alt-art? true))
235226
(->> filtered-images
236227
(concat [""])
237-
(mapcat #(card-arts-for-key card %))
228+
(map #(if % (assoc card :art %) card))
238229
(map #(if (not= "" (:art %)) (dissoc % :previous-versions) %))
239230
(concat acc))
240231
(conj acc card))))
@@ -295,11 +286,10 @@
295286
art (:art card)
296287
code-kw (keyword (:future-version card (:code card)))
297288
alts (:alt-arts (:options @app-state))
298-
alt-index (get card :art-index 0)
299289
new-alts (cond
300-
(keyword? art) (assoc alts code-kw [(name art) alt-index])
290+
(keyword? art) (assoc alts code-kw (name art))
301291
is-old-card (assoc alts code-kw (:code card))
302-
:else (dissoc alts code-kw))]
292+
:else (dissoc alts code-kw))] ; remove the key entirely if the newest card is selected
303293
(swap! app-state assoc-in [:options :alt-arts] new-alts)
304294
(nr.account/post-options (partial post-response))))
305295

src/cljs/nr/gameboard/board.cljs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,7 @@
6060
"stock")
6161
card (if (or (:face card) (:images card)) card (get @all-cards (get-title card)))
6262
images (image-or-face card)]
63-
(if (sequential? art)
64-
(let [art-urls (get-image-path images (keyword lang) (keyword res) (keyword (first art)))
65-
chosen-art (nth art-urls (second art))]
66-
[chosen-art])
67-
(get-image-path images (keyword lang) (keyword res) (keyword art)))))
63+
(get-image-path images (keyword lang) (keyword res) (keyword art))))
6864

6965

7066
(defonce button-channel (chan))

0 commit comments

Comments
 (0)