|
190 | 190 | ([card allow-all-users] |
191 | 191 | (let [lang (get-in @app-state [:options :card-language] "en") |
192 | 192 | res (get-in @app-state [:options :card-resolution] "default") |
193 | | - art (if (show-alt-art? allow-all-users) |
194 | | - (get-in @app-state [:options :alt-arts (keyword (:code card))] "stock") |
195 | | - "stock") |
| 193 | + alt-art (if (show-alt-art? allow-all-users) |
| 194 | + (get-in @app-state [:options :alt-arts (keyword (:code card))] "stock") |
| 195 | + "stock") |
| 196 | + art (if (sequential? alt-art) (first alt-art) alt-art) |
| 197 | + art-index (if (sequential? alt-art) (second alt-art) 0) |
196 | 198 | images (image-or-face card)] |
197 | | - (get-image-path images (keyword lang) (keyword res) (keyword art))))) |
| 199 | + (nth (get-image-path images (keyword lang) (keyword res) (keyword art)) art-index)))) |
198 | 200 |
|
199 | 201 | (defn- base-image-url |
200 | 202 | "The default card image. Displays an alternate image if the card is specified as one." |
|
284 | 286 | selected-art (get selected-alts (keyword (:code card)))] |
285 | 287 | (nil? selected-art))) |
286 | 288 |
|
| 289 | +(defn- card-image-properties [card] |
| 290 | + (let [base-card-art (:art card) |
| 291 | + card-art (if (= "" base-card-art) :stock base-card-art) |
| 292 | + art-index (:art-index card)] |
| 293 | + [card-art art-index])) |
| 294 | + |
| 295 | +(defn- desired-card-image-properties [code] |
| 296 | + (let [selected-alts (:alt-arts (:options @app-state)) |
| 297 | + selected-alt (get selected-alts code [:stock 0])] |
| 298 | + (if (sequential? selected-alt) |
| 299 | + [(keyword (first selected-alt)) (second selected-alt)] |
| 300 | + [(keyword selected-alt) 0]))) |
| 301 | + |
| 302 | +;; Alts can be defined in a few different ways |
| 303 | +;; Either as a string for legacy cards |
| 304 | +;; Or as [alt-set index] for more recent alts |
287 | 305 | (defn- selected-alt-art [card] |
288 | 306 | (cond (contains? card :future-version) (future-selected-alt-art card) |
289 | 307 | (contains? card :previous-versions) (previous-selected-alt-art card) |
290 | 308 | :else |
291 | | - (let [code (keyword (:code card)) |
292 | | - selected-alts (:alt-arts (:options @app-state)) |
293 | | - selected-art (keyword (get selected-alts code)) |
294 | | - card-art (:art card)] |
295 | | - (or (and card-art (nil? selected-art) (= "" card-art)) |
296 | | - (and selected-art (= card-art selected-art)))))) |
297 | | - |
298 | | -;; Alts can only be set on th most recent version of a card |
| 309 | + (let [curr-card-properties (card-image-properties card) |
| 310 | + code (keyword (:code card)) |
| 311 | + desired-card-properties (desired-card-image-properties code)] |
| 312 | + (= curr-card-properties desired-card-properties)))) |
| 313 | + |
| 314 | +;; Alts can only be set on the most recent version of a card |
299 | 315 | ;; So if the card has a :future-version key, we apply the alt to |
300 | 316 | ;; that card, setting the alt to the code of the old card. |
301 | 317 | (defn- select-alt-art [card] |
|
0 commit comments