Printing tracking for owned copies and deck art, and an outdated-card-data notice
Owned copies can now be pinned to a printing + finish (nonfoil / foil / etched), activating the long-dormant library_card_copies table as groups of identical copies. library_cards.quantity_owned stays authoritative: groups are a subset of it, and the rest are "unspecified". Tracking more copies than are unspecified grows ownership to fit; lowering ownership trims the most recently added groups first. Migration 0006 adds the group quantity, a unique (card, printing, finish) index, and deck_cards.preferred_scryfall_id. A deck slot can show a chosen printing's art, both faces from that printing, falling back to the default when the id no longer resolves. It survives quantity/board changes and is kept by duplicate_deck. UI: the click preview's info tile gets a Printings section when opened from the Library or a deck (copy groups with steppers, "Add a printing…", and "Shown in this deck" with Change…/Default), backed by a printing picker grid. The picker takes Escape in the capture phase so it closes without closing the preview under it. Sync: CardEntry.printings (keyed "<scryfall_id>/<finish>") and DeckCardEntry.printing. Cards now merge field by field with groups per key, so a quantity edit and a printing added on another device both survive; merged groups are clamped deterministically. A document is written as version 2 only once it holds printing data, so older builds and servers refuse it instead of dropping the data and syncing the loss. Decklists: "(SET) NUM", optionally "*F*"/"*E*", round-trips through deck and library export/import. Library export writes a line per group plus one for unspecified copies. reference.db printings gain lang and released_at for picker labels and ordering. When the installed card data lacks any column this build's reference schema has (found by diffing against the schema applied in-memory, so no list to maintain), a notice under the top bar offers Update card data (and Import card data… on phones); "Not now" is remembered until something more goes missing.
This commit is contained in:
@@ -210,6 +210,43 @@ pub struct DeckEntry {
|
||||
pub is_maybeboard: bool,
|
||||
/// Copies owned in the library (0 if the card isn't in the library).
|
||||
pub quantity_owned: i64,
|
||||
/// The printing whose art this deck slot shows, if one was chosen. The
|
||||
/// card's `image_uri`/`back_image_uri` already reflect it (falling back
|
||||
/// to the default when the id no longer resolves).
|
||||
pub preferred_scryfall_id: Option<String>,
|
||||
}
|
||||
|
||||
/// One printing of a card, for the printing picker and copy labels.
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PrintingRef {
|
||||
pub scryfall_id: String,
|
||||
/// Scryfall's set code, lowercase (e.g. "2x2").
|
||||
pub set_code: String,
|
||||
pub collector_number: String,
|
||||
/// Language code ("en", "ja", ...); empty on an older reference.db.
|
||||
pub lang: String,
|
||||
/// The finishes this printing exists in: "nonfoil", "foil", "etched".
|
||||
pub finishes: Vec<String>,
|
||||
pub rarity: String,
|
||||
pub image_uri: String,
|
||||
pub back_image_uri: String,
|
||||
/// Scryfall's `prices.usd` for this printing, 0 if unknown.
|
||||
pub price_usd: f64,
|
||||
/// Release date as YYYY-MM-DD; empty on an older reference.db.
|
||||
pub released_at: String,
|
||||
}
|
||||
|
||||
/// A group of identical owned copies pinned to one printing + finish. Groups
|
||||
/// are a subset of the card's `quantity_owned`; copies not in any group are
|
||||
/// simply unspecified.
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct LibraryCopy {
|
||||
pub scryfall_id: String,
|
||||
pub finish: String,
|
||||
pub quantity: i64,
|
||||
/// The printing's details, or `None` when the id no longer resolves in
|
||||
/// the reference db (e.g. after a re-ingest dropped it).
|
||||
pub printing: Option<PrintingRef>,
|
||||
}
|
||||
|
||||
impl LibraryCard {
|
||||
|
||||
Reference in New Issue
Block a user