Brick Work

0027. Build Scout: percent available counts a set's own parts, figures apart

Context

Build Scout ranks every catalogue set by how much of it the loose stock already makes, and its Build it action moves those parts into a copy. The scoring engine (ADR 0026) counts a minifigure twice, as its component parts folded into the set's own (part, colour) lines and as a whole-figure line, and counts that whole figure as one piece of the set. That is right for finding where a pile came from; for "how complete would this set be" it would show a set as missing parts of a figure you hold whole, and count a figure as a piece.

Options considered

  1. The engine's numbers. Covered quantity over the set quantity. Rejected: a held figure would read as missing parts, and a figure would be one "part".
  2. Parts and figure components together, a loose figure covering its components. Closest to a physical set. Rejected for a first version: it needs the figure inventories in the index and a rule for loose parts of the same figure; the copy it makes would need the same rule.
  3. Own parts only, figures apart (chosen). The percentage is over the set's own part lines; the whole figures are a separate "n of m figures".

Decision

Option 3. parts_available = sum over the set's part lines of min(have, need), percent = parts_available / parts_total, missing_parts = parts_total - parts_available, where the part lines are the set's own parts with spares left out (ADR 0011) and the parts of sub-sets expanded with their quantity; a minifigure's components are not part lines. figures_available = sum over the whole-figure lines of min(have, need) and a loose whole figure counts. Swaps (ADR 0026) stay apart and enter no number. The two indexes are built with the engine's build_index from the engine's load_rows, so sub-sets and spares are handled by the same code.

The stock is one eligibility rule shared by the ranking and by Build it: live loose parts and minifigures, with the quantity workbench.available gives (damaged off unless asked for, a figure with defective parts none).

Build it makes a copy of the catalogue's latest Rebrickable part list (the list the numbers came from) and moves exactly what the percentage counted, as one event whose Undo archives the copy and puts the stock back. A set made of other sets is not built, because a copy's part list does not expand sub-sets.

Cost to complete uses the current prices of the missing lines, in the one currency most are priced in; a line without a price is counted, never guessed.

Consequences

Issue #9; ADR 0026; ADR 0011; the reference page Set scoring (docs/reference/set-scoring.md).