Skip to content

Card Search

Pablo Martínez López edited this page Nov 5, 2026 · 1 revision

Card Search

English · Español

The Search screen (src/features/buscar/) looks up any card with no deck involved: a name or Scryfall syntax, filters, sorted results and a details page. Adding to the deck is one button at the end, not the point of the screen; that is why it is a screen of its own and not a variation of the Add card dialog.

Files

File Responsibility
src-tauri/src/commands/buscar.rs cartas_buscar, carta_ficha, carta_aclaraciones; builds the query (consulta, parametros) and the details (ficha_de), with tests.
src-tauri/src/scryfall/client.rs Scryfall::buscar_pagina, Scryfall::aclaraciones.
src/stores/busqueda-store.ts useBusqueda: filters, results, page, open card. A store because changing tab unmounts the screen and the search must still be there on return.
src/features/buscar/buscar-screen.tsx The screen: field with suggestions, filters (side panel on desktop, HojaMenu otherwise), sort bar and results.
src/features/buscar/filtros-panel.tsx The filter controls.
src/features/buscar/ficha-carta.tsx The details dialog (DialogoAdaptable).
src/features/buscar/simbolos-mana.tsx Mana symbols drawn in CSS inside rules text and costs.
src/features/buscar/consulta.ts The pure part: factory filters, hayCriterio, cuantosFiltros, claveDeFiltros, partirSimbolos, with tests.

It reuses RejillaCartas and useSugerencias from features/variants/ and traerCarta to add a card.

Building the query

The query is built in Rust, as all heavy work is. FiltrosCartas carries what the screen asked for:

flowchart LR
  P[FiltrosCartas] --> C[consulta: the q parameter]
  P --> X[parametros: order, dir, unique, include_multilingual]
  C --> S[/cards/search + page/]
  X --> S
  S --> R[PaginaCartas: cartas, total, hayMas]
Loading
  • texto goes as written (it may be Scryfall syntax); with exacto, chosen from the suggestions, it becomes !"name".
  • Every other value goes through solo_alfanumerico, so a filter cannot smuggle in another query.
  • Colours: c>= (includes), c= (exactly) or id<= (identity within them, for a commander). Colourless with colours is meaningless, so the colours win.
  • include_multilingual=true is what makes "rayo" find the Spanish printed name; with no language filter results still come in English. It is dropped only for "all printings" with no language, which would list every printing in every language.

An empty query returns an empty page without calling Scryfall. A query with no matches (a 404 from Scryfall) is also an empty page, not an error.

Behaviour worth knowing

  • Filters search by themselves, the text does not. claveDeFiltros is the filters without the text: when it changes, a search runs after 350 ms (filters are often changed several in a row). The text waits for Enter, the button or a suggestion, to avoid a request per keystroke. Returning to the screen does not search again.
  • Paging. Scryfall gives up to 175 cards per page. A sentinel at the end of the grid (useVisible, with the ScrollArea viewport as root) asks for the next page; if that fails it stops asking and shows "Retry". Pages are not remembered in busquedas: the store already keeps them.
  • Stale answers. busqueda-store.ts numbers each request and drops the answer of any but the last.
  • Details. ficha_de gives one entry per face: split and adventure cards share one image and carry each face's text; double-faced cards have an image per face, and only they get the "other face" button. Printed text wins over Oracle text, so a card in Spanish reads in Spanish.
  • Prices. Scryfall gives no price to non-English printings, so carta_ficha asks for the same printing in English; if that fails the details still open, without a price. This is the same rule as Statistics.
  • Printings. card_prints with the language of the open card; Cockatrice rows are dropped because they have no details page. If it fails the details still work.
  • Rulings. They belong to the card, not to the printing, so they are asked for once per card name, not again when switching printing. Scryfall has them only in English, and the heading says so.
  • Adding. traerCarta plus insertar at the end of the open deck, with a toast as feedback: the deck is not on screen.

Where to start when extending

  • A new filter: a field in FiltrosCartas and its piece in consulta (with a test), then the control in filtros-panel.tsx and the count in cuantosFiltros.
  • A new detail: a field in FichaCarta/CaraFicha (ScryCard may already read it) and its line in ficha-carta.tsx.

See also

Documentation · Documentación

Language: English · Español

Use and build · Uso y desarrollo

Architecture · Arquitectura

Data · Datos

Getting cards · Conseguir cartas

Layout, images, PDF · Maquetación, imagen y PDF

Card designer · Diseñador de cartas

Game table · Mesa de juego

Mobile · Móvil

Frontend · Frontend

Reference · Referencia

Clone this wiki locally