Skip to content

Commit

Permalink
fix: special validation case for precious memento
Browse files Browse the repository at this point in the history
  • Loading branch information
fspoettel committed Feb 18, 2025
1 parent b109801 commit b9b04fc
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 1 deletion.
41 changes: 41 additions & 0 deletions src/store/lib/deck-validation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import parallelRolandValid from "@/test/fixtures/decks/validation/parallel_rolan
import parallelWendy from "@/test/fixtures/decks/validation/parallel_wendy.json";
import parallelWendyInvalid from "@/test/fixtures/decks/validation/parallel_wendy_invalid.json";
import parallelWendyValidSignatures from "@/test/fixtures/decks/validation/parallel_wendy_valid_signatures.json";
import preciousMemento from "@/test/fixtures/decks/validation/precious_memento_valid.json";
import promoMarie from "@/test/fixtures/decks/validation/promo_marie.json";
import rbwInvalidMissing from "@/test/fixtures/decks/validation/rbw_invalid_missing.json";
import rbwValidChoice from "@/test/fixtures/decks/validation/rbw_valid_choice.json";
Expand Down Expand Up @@ -1364,5 +1365,45 @@ describe("deck validation", () => {
const result = validate(store, vinnyBMaxXP);
expect(result.valid).toBeTruthy();
});

it("handles case: precious memento, valid", () => {
const result = validate(store, preciousMemento);
expect(result.valid).toBeTruthy();

Check failure on line 1371 in src/store/lib/deck-validation.spec.ts

View workflow job for this annotation

GitHub Actions / Test

src/store/lib/deck-validation.spec.ts > deck validation > corner cases > handles case: precious memento, valid

AssertionError: expected false to be truthy - Expected + Received - true + false ❯ src/store/lib/deck-validation.spec.ts:1371:28
});

it("handles case: precious memento, invalid", () => {
const deck = structuredClone(preciousMemento);
deck.slots["08114"] = 2;
deck.slots["08115"] = 2;
const result = validate(store, deck);
expect(result.valid).toBeFalsy();
expect(result.errors).toMatchInlineSnapshot(`
[
{
"details": {
"count": 4,
"countRequired": 30,
"target": "slots",
},
"type": "TOO_FEW_CARDS",
},
{
"details": [
{
"code": "08114",
"limit": 1,
"quantity": 2,
},
{
"code": "08115",
"limit": 1,
"quantity": 2,
},
],
"type": "INVALID_CARD_COUNT",
},
]
`);
});
});
});
5 changes: 4 additions & 1 deletion src/store/lib/deck-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,10 @@ class DeckLimitsValidator implements SlotValidator {

add(card: Card, quantity: number) {
if (card.xp == null) return;
const name = card.real_name;
const name = SPECIAL_CARD_CODES.PRECIOUS_MEMENTOS.includes(card.code)
? `${card.real_name} (${card.real_subname})`
: card.real_name;

const limit = card.myriad ? 3 : cardLimit(card, this.limitOverride);

// some copies of this card might be ignored, e.g. for parallel Agnes and TCU "Ace of Rods".
Expand Down
30 changes: 30 additions & 0 deletions src/test/fixtures/decks/validation/precious_memento_valid.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"id": "gLoZyLdqnApJFFM",
"date_creation": "2025-02-18T12:04:57.442Z",
"date_update": "2025-02-18T12:13:24.076Z",
"description_md": "",
"meta": "{}",
"ignoreDeckLimitSlots": {},
"sideSlots": {},
"next_deck": null,
"previous_deck": null,
"tags": "",
"version": "0.1",
"taboo_id": 8,
"xp": null,
"xp_spent": null,
"exile_string": null,
"xp_adjustment": null,
"investigator_code": "07005",
"investigator_name": "Silas Marsh",
"name": "Silas Marsh on the Road",
"slots": {
"01000": 1,
"07014": 1,
"07015": 1,
"07016": 1,
"08114": 1,
"08115": 1
},
"problem": "too_few_cards"
}
2 changes: 2 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ export const SPECIAL_CARD_CODES = {
PARALLEL_ROLAND: "90024",
/** Parallel front has deckbuilding impact. */
PARALLEL_WENDY: "90037",
/** Special case for deck limit (considers subname). */
PRECIOUS_MEMENTOS: ["08114", "08115"],
/** Random basic weakness placeholder. */
RANDOM_BASIC_WEAKNESS: "01000",
/** Separate upgrade path. */
Expand Down

0 comments on commit b9b04fc

Please sign in to comment.