-
-
Notifications
You must be signed in to change notification settings - Fork 153
feat(engine,client): show the marker token a face-down permanent was made with (#7532) #7535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
| import { faceDownMarkerRef } from "../faceDownMarker.ts"; | ||
|
|
||
| describe("faceDownMarkerRef", () => { | ||
| it("maps each rules cause onto the printing paper play uses", () => { | ||
| expect(faceDownMarkerRef(true, "Manifest")?.face_name).toBe("manifest"); | ||
| expect(faceDownMarkerRef(true, "Morph")?.face_name).toBe("morph"); | ||
| // Cloak (CR 701.58a) and disguise (CR 702.166a) are different rules that | ||
| // share one printed token — the mapping is where they converge, not the | ||
| // engine's enum. | ||
| expect(faceDownMarkerRef(true, "Cloak")?.face_name).toBe("a mysterious creature"); | ||
| expect(faceDownMarkerRef(true, "Disguise")?.face_name).toBe("a mysterious creature"); | ||
| expect(faceDownMarkerRef(true, "Cloak")?.scryfall_oracle_id).toBe( | ||
| faceDownMarkerRef(true, "Disguise")?.scryfall_oracle_id, | ||
| ); | ||
| }); | ||
|
|
||
| it("has no marker for a cause with no printed token", () => { | ||
| // Ixidron turns permanents face down with no keyword action, and Wizards | ||
| // prints nothing for it — the generic card back stays. | ||
| expect(faceDownMarkerRef(true, "TurnedFaceDown")).toBeNull(); | ||
| }); | ||
|
|
||
| it("stays null unless the permanent is actually face down", () => { | ||
| // The engine leaves the cause on the object after it turns face up, so | ||
| // every reader must gate on `face_down`. This is that gate. | ||
| expect(faceDownMarkerRef(false, "Manifest")).toBeNull(); | ||
| expect(faceDownMarkerRef(true, null)).toBeNull(); | ||
| expect(faceDownMarkerRef(true, undefined)).toBeNull(); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import type { FaceDownCause, TokenImageRef } from "../../adapter/types.ts"; | ||
|
|
||
| /** | ||
| * The marker token Wizards prints for each face-down family. | ||
| * | ||
| * Paper play uses these as the required "what ability caused them to be face | ||
| * down" reminder (Duskmourn rulings, 2024-09-20), and the engine already tells | ||
| * us the cause. Mapping the cause onto a printing is a display decision, which | ||
| * is why the ids live here and not in the engine: four rules-level causes share | ||
| * three printed tokens, and one cause has no token at all. | ||
| * | ||
| * Oracle ids are used rather than a single printing's Scryfall id so the lookup | ||
| * survives a reprint — `fetchTokenImageByRef` falls back to the oracle key that | ||
| * `scryfall-token-images.json` already indexes for all three. | ||
| */ | ||
| const MARKERS: Partial<Record<FaceDownCause, TokenImageRef>> = { | ||
| // https://scryfall.com/card/tfrf/4/manifest — also used for manifest dread, | ||
| // which is the same keyword action with a different card-selection step. | ||
| Manifest: { | ||
| scryfall_id: "", | ||
| scryfall_oracle_id: "f4f184ef-f456-47d8-9012-095629a5ea4d", | ||
| face_name: "manifest", | ||
| preset_id: "face-down-manifest", | ||
| }, | ||
| // https://scryfall.com/card/tdtk/7/morph — megamorph shares it. | ||
| Morph: { | ||
| scryfall_id: "", | ||
| scryfall_oracle_id: "8f92f8d7-ec89-426f-86dc-fbc259eb5559", | ||
| face_name: "morph", | ||
| preset_id: "face-down-morph", | ||
| }, | ||
| // https://scryfall.com/card/tmkm/21/a-mysterious-creature — cloak and | ||
| // disguise are different rules (CR 701.58a vs CR 702.166a) with one printing. | ||
| Cloak: { | ||
| scryfall_id: "", | ||
| scryfall_oracle_id: "6481a124-6859-4f02-9fd3-b1302528dd2e", | ||
| face_name: "a mysterious creature", | ||
| preset_id: "face-down-cloak", | ||
| }, | ||
| Disguise: { | ||
| scryfall_id: "", | ||
| scryfall_oracle_id: "6481a124-6859-4f02-9fd3-b1302528dd2e", | ||
| face_name: "a mysterious creature", | ||
| preset_id: "face-down-cloak", | ||
| }, | ||
| // `TurnedFaceDown` (Ixidron class) is deliberately absent: no marker token is | ||
| // printed for it, so it keeps the generic card back. | ||
| }; | ||
|
|
||
| /** | ||
| * The marker printing for a face-down permanent, or `null` when none applies — | ||
| * the permanent is face up, the engine did not record a cause (older saves), or | ||
| * the cause has no printed token. | ||
| */ | ||
| export function faceDownMarkerRef( | ||
| faceDown: boolean, | ||
| cause: FaceDownCause | null | undefined, | ||
| ): TokenImageRef | null { | ||
| if (!faceDown || !cause) return null; | ||
| return MARKERS[cause] ?? null; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6129,6 +6129,7 @@ pub(super) fn parse_theyre_face_down_profile(lower: &str) -> Option<FaceDownProf | |
| extra_core_types, | ||
| subtypes, | ||
| ward: None, | ||
| cause: crate::types::ability::FaceDownCause::Manifest, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n -C 8 'FaceDownProfileSpec|parse_(theyre|its)_face_down_profile|TurnFaceDown' crates/engine/srcRepository: phase-rs/phase Length of output: 50371 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- sequence assignments and nearby logic ---'
rg -n -C 18 'FaceDownProfileSpec|FaceDownCause::|parse_(theyre|its)_face_down_profile|parse_followup_continuation_ast' crates/engine/src/parser/oracle_effect/sequence.rs
printf '%s\n' '--- cause definitions and profile application ---'
rg -n -C 14 'enum FaceDownCause|struct FaceDownProfile|FaceDownCause|face_down_profile' crates/engine/src/types crates/engine/src | head -n 500
printf '%s\n' '--- runtime consumers of face-down cause/profile ---'
rg -n -C 12 'FaceDownCause|face_down_profile|profile\.cause|cause:' crates/engine/src --glob '*.rs' | head -n 800Repository: phase-rs/phase Length of output: 50371 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- continuation application ---'
sed -n '4600,4665p' crates/engine/src/parser/oracle_effect/sequence.rs
rg -n -C 20 'FaceDownProfileSpec' crates/engine/src/parser/oracle_effect/sequence.rs
printf '%s\n' '--- face-down types ---'
rg -n 'enum FaceDownCause|struct FaceDownProfile|FaceDownCause' crates/engine/src/types/ability.rs
sed -n '14880,15020p' crates/engine/src/types/ability.rs
printf '%s\n' '--- all cause-dependent behavior ---'
rg -n -C 10 'FaceDownCause::|cause\b' crates/engine/src --glob '*.rs' \
| rg -n 'FaceDown|face_down|Manifest|Cloak|cause' | head -n 500
printf '%s\n' '--- focused tests for profile continuations ---'
rg -n -C 12 'face.down|FaceDown|Cyber.Conversion|Mondassian|Yedora|manifest' \
crates/engine/src/parser/oracle_effect/tests.rs crates/engine/src/parser/oracle_effect/sequence.rs \
| tail -n 500Repository: phase-rs/phase Length of output: 50370 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- FaceDownCause definition and constructors ---'
sed -n '11635,11775p' crates/engine/src/types/ability.rs
printf '%s\n' '--- exact FaceDownCause references ---'
rg -n -C 8 'FaceDownCause' . --glob '*.rs' --glob '*.ts' --glob '*.tsx' --glob '*.json'
printf '%s\n' '--- profile serialization and runtime propagation ---'
rg -n -C 12 'face_down_profile|FaceDownProfile' crates/engine/src --glob '*.rs' \
| rg -E '(^|:)([0-9]+):|FaceDownProfile|face_down_profile' | head -n 1000Repository: phase-rs/phase Length of output: 49404 Preserve
Seed 🤖 Prompt for AI Agents |
||
| }); | ||
| } | ||
| // Extra core type word (Creature excluded — always implicit). | ||
|
|
@@ -6269,6 +6270,7 @@ pub(super) fn parse_its_face_down_profile(lower: &str) -> Option<FaceDownProfile | |
| extra_core_types, | ||
| subtypes, | ||
| ward: None, | ||
| cause: crate::types::ability::FaceDownCause::Manifest, | ||
| }), | ||
| // "... land/artifact/enchantment/planeswalker." — non-creature | ||
| // body whose core type is the terminal noun; no implicit | ||
|
|
@@ -6287,6 +6289,7 @@ pub(super) fn parse_its_face_down_profile(lower: &str) -> Option<FaceDownProfile | |
| extra_core_types, | ||
| subtypes, | ||
| ward: None, | ||
| cause: crate::types::ability::FaceDownCause::Manifest, | ||
| }) | ||
| } | ||
| }; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.