Treat a typed main kind as no kind so recommendations still fall back to size.
A custom kind no longer empties a job of eligible cards, and other catalog kinds stay ranking hints instead of becoming the main kind.
This commit is contained in:
1 parent
dad8661268
commit
f795951443
5 files changed
+116
-16
No files matched your search
@@ -12,6 +12,7 @@ import jobsFile from "../../data/create/customRule/_jobs.json";
|
||||
import membershipFacets from "../../data/create/customRule/membership.json";
|
||||
import type {
|
||||
CardEngineEntry,
|
||||
CardFacets,
|
||||
DeckEngine,
|
||||
DeckId,
|
||||
DeckRecommendation,
|
||||
@@ -53,20 +54,24 @@ interface Evaluated {
|
||||
otherKindHits: number;
|
||||
}
|
||||
|
||||
/** Normalizes setup answers. A group with other kinds and no main kind gets the first as main. */
|
||||
/** A typed or missing main kind stays unset so eligibility falls back to size. */
|
||||
export function normalizeAnswers(answers: GroupAnswers): Required<GroupAnswers> {
|
||||
const others = [...(answers.otherKinds ?? [])];
|
||||
const mainKind = answers.mainKind ?? others.shift() ?? null;
|
||||
const mainKind = answers.mainKind ?? null;
|
||||
return {
|
||||
size: answers.size ?? null,
|
||||
mainKind,
|
||||
otherKinds: others.filter((k) => k !== mainKind),
|
||||
otherKinds: [...(answers.otherKinds ?? [])].filter((k) => k !== mainKind),
|
||||
scale: [...new Set(answers.scale ?? [])],
|
||||
stage: answers.stage ?? null,
|
||||
traits: answers.traits ?? {},
|
||||
};
|
||||
}
|
||||
|
||||
function kindFits(orgType: CardFacets["orgType"], kind: Kind | null): boolean {
|
||||
if (!kind || !(kind in orgType)) return true;
|
||||
return orgType[kind];
|
||||
}
|
||||
|
||||
function sizeBandOf(size: string | null, data: DeckData): SizeBand | null {
|
||||
if (!size) return null;
|
||||
const band = data.config.sizeAnswers[size];
|
||||
@@ -86,7 +91,7 @@ function evaluate(
|
||||
if (!f || !entry) throw new Error(`Card ${id} is missing from the facet or jobs file`);
|
||||
const traits = entry.traits ?? {};
|
||||
const fitsSize = band ? f.size[band] : true;
|
||||
const fitsKind = a.mainKind ? f.orgType[a.mainKind] : true;
|
||||
const fitsKind = kindFits(f.orgType, a.mainKind);
|
||||
const openedBy = (traits.opens ?? []).find((k) => ticked.has(k));
|
||||
const isBeside = (traits.beside ?? []).length > 0;
|
||||
// Each facet group counts once. Scale earns its point only if the card fits
|
||||
@@ -96,7 +101,7 @@ function evaluate(
|
||||
const fitsAnswer = (traits.fits ?? []).find((k) => ticked.has(k));
|
||||
const matched: MatchedFacet[] = [];
|
||||
if (band && fitsSize) matched.push("size");
|
||||
if (a.mainKind && fitsKind) matched.push("kind");
|
||||
if (a.mainKind && a.mainKind in f.orgType && fitsKind) matched.push("kind");
|
||||
if (fitsScale) matched.push("scale");
|
||||
if (fitsStage) matched.push("stage");
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user