edhvault-mcp 0.2.0 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/dist/cli.js +1735 -286
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3787,15 +3787,15 @@ var require_compile = __commonJS({
|
|
|
3787
3787
|
var _a3;
|
|
3788
3788
|
if (((_a3 = parsedRef.fragment) === null || _a3 === void 0 ? void 0 : _a3[0]) !== "/")
|
|
3789
3789
|
return;
|
|
3790
|
-
for (const
|
|
3790
|
+
for (const part2 of parsedRef.fragment.slice(1).split("/")) {
|
|
3791
3791
|
if (typeof schema === "boolean")
|
|
3792
3792
|
return;
|
|
3793
|
-
const partSchema = schema[(0, util_1.unescapeFragment)(
|
|
3793
|
+
const partSchema = schema[(0, util_1.unescapeFragment)(part2)];
|
|
3794
3794
|
if (partSchema === void 0)
|
|
3795
3795
|
return;
|
|
3796
3796
|
schema = partSchema;
|
|
3797
3797
|
const schId = typeof schema === "object" && schema[this.opts.schemaId];
|
|
3798
|
-
if (!PREVENT_SCOPE_CHANGE.has(
|
|
3798
|
+
if (!PREVENT_SCOPE_CHANGE.has(part2) && schId) {
|
|
3799
3799
|
baseId = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schId);
|
|
3800
3800
|
}
|
|
3801
3801
|
}
|
|
@@ -4367,21 +4367,21 @@ var require_fast_uri = __commonJS({
|
|
|
4367
4367
|
normalizeString(uri, options);
|
|
4368
4368
|
} else if (typeof uri === "object") {
|
|
4369
4369
|
uri = /** @type {T} */
|
|
4370
|
-
|
|
4370
|
+
parse4(serialize(uri, options), options);
|
|
4371
4371
|
}
|
|
4372
4372
|
return uri;
|
|
4373
4373
|
}
|
|
4374
4374
|
function resolve(baseURI, relativeURI, options) {
|
|
4375
4375
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
4376
|
-
const resolved = resolveComponent(
|
|
4376
|
+
const resolved = resolveComponent(parse4(baseURI, schemelessOptions), parse4(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
4377
4377
|
schemelessOptions.skipEscape = true;
|
|
4378
4378
|
return serialize(resolved, schemelessOptions);
|
|
4379
4379
|
}
|
|
4380
4380
|
function resolveComponent(base, relative, options, skipNormalization) {
|
|
4381
4381
|
const target = {};
|
|
4382
4382
|
if (!skipNormalization) {
|
|
4383
|
-
base =
|
|
4384
|
-
relative =
|
|
4383
|
+
base = parse4(serialize(base, options), options);
|
|
4384
|
+
relative = parse4(serialize(relative, options), options);
|
|
4385
4385
|
}
|
|
4386
4386
|
options = options || {};
|
|
4387
4387
|
if (!options.tolerant && relative.scheme) {
|
|
@@ -4604,7 +4604,7 @@ var require_fast_uri = __commonJS({
|
|
|
4604
4604
|
}
|
|
4605
4605
|
return { parsed, malformedAuthorityOrPort };
|
|
4606
4606
|
}
|
|
4607
|
-
function
|
|
4607
|
+
function parse4(uri, opts) {
|
|
4608
4608
|
return parseWithStatus(uri, opts).parsed;
|
|
4609
4609
|
}
|
|
4610
4610
|
function normalizeString(uri, opts) {
|
|
@@ -4633,7 +4633,7 @@ var require_fast_uri = __commonJS({
|
|
|
4633
4633
|
resolveComponent,
|
|
4634
4634
|
equal,
|
|
4635
4635
|
serialize,
|
|
4636
|
-
parse:
|
|
4636
|
+
parse: parse4
|
|
4637
4637
|
};
|
|
4638
4638
|
module.exports = fastUri;
|
|
4639
4639
|
module.exports.default = fastUri;
|
|
@@ -7384,8 +7384,8 @@ var require_formats = __commonJS({
|
|
|
7384
7384
|
return false;
|
|
7385
7385
|
const year = +matches[1];
|
|
7386
7386
|
const month = +matches[2];
|
|
7387
|
-
const
|
|
7388
|
-
return month >= 1 && month <= 12 &&
|
|
7387
|
+
const day2 = +matches[3];
|
|
7388
|
+
return month >= 1 && month <= 12 && day2 >= 1 && day2 <= (month === 2 && isLeapYear(year) ? 29 : DAYS[month]);
|
|
7389
7389
|
}
|
|
7390
7390
|
function compareDate(d1, d2) {
|
|
7391
7391
|
if (!(d1 && d2))
|
|
@@ -7970,6 +7970,14 @@ function validTutorOverrides(raw) {
|
|
|
7970
7970
|
}
|
|
7971
7971
|
return out;
|
|
7972
7972
|
}
|
|
7973
|
+
function isEmptyTutorOverride(o) {
|
|
7974
|
+
return Object.entries(o).every(
|
|
7975
|
+
([k, v]) => v === void 0 || (k === "added" || k === "off") && v === false || typeof v === "string" && !v.trim()
|
|
7976
|
+
);
|
|
7977
|
+
}
|
|
7978
|
+
function isEmptyManaOverride(o) {
|
|
7979
|
+
return Object.entries(o).every(([, v]) => v === void 0 || typeof v === "string" && !v.trim());
|
|
7980
|
+
}
|
|
7973
7981
|
var SAC_KINDS, GRAVE_KINDS, count, WHENS, TUTOR_TOS;
|
|
7974
7982
|
var init_manaOverrides = __esm({
|
|
7975
7983
|
"../src/lib/deckPlan/manaOverrides.ts"() {
|
|
@@ -8058,12 +8066,36 @@ function layerTable(cards, table) {
|
|
|
8058
8066
|
for (const oid of oids) out[oid] = { ...cards[oid], ...table[oid] };
|
|
8059
8067
|
return out;
|
|
8060
8068
|
}
|
|
8061
|
-
|
|
8069
|
+
function splitEdit(oid, o, cards, table) {
|
|
8070
|
+
const nextCards = { ...cards };
|
|
8071
|
+
const nextTable = { ...table };
|
|
8072
|
+
delete nextTable[oid];
|
|
8073
|
+
if (!o) {
|
|
8074
|
+
delete nextCards[oid];
|
|
8075
|
+
return { cards: nextCards, table: nextTable };
|
|
8076
|
+
}
|
|
8077
|
+
const prev = cards[oid];
|
|
8078
|
+
const card = { ...o };
|
|
8079
|
+
const guess = {};
|
|
8080
|
+
for (const f of TABLE_FIELDS) {
|
|
8081
|
+
delete card[f];
|
|
8082
|
+
if (prev?.[f] !== void 0) card[f] = prev[f];
|
|
8083
|
+
const mine = o[f]?.length ? o[f] : void 0;
|
|
8084
|
+
if (same(mine, prev?.[f])) continue;
|
|
8085
|
+
if (mine || prev?.[f]?.length) guess[f] = mine ?? [];
|
|
8086
|
+
}
|
|
8087
|
+
if (Object.keys(card).length) nextCards[oid] = card;
|
|
8088
|
+
else delete nextCards[oid];
|
|
8089
|
+
if (Object.keys(guess).length) nextTable[oid] = guess;
|
|
8090
|
+
return { cards: nextCards, table: nextTable };
|
|
8091
|
+
}
|
|
8092
|
+
var TABLE_FIELDS, same;
|
|
8062
8093
|
var init_tableGuesses = __esm({
|
|
8063
8094
|
"../src/lib/deckPlan/tableGuesses.ts"() {
|
|
8064
8095
|
"use strict";
|
|
8065
8096
|
init_manaOverrides();
|
|
8066
8097
|
TABLE_FIELDS = ["drawsPerRound", "treasuresPerRound"];
|
|
8098
|
+
same = (a, b) => JSON.stringify(a ?? []) === JSON.stringify(b ?? []);
|
|
8067
8099
|
}
|
|
8068
8100
|
});
|
|
8069
8101
|
|
|
@@ -8220,13 +8252,34 @@ var init_oddsPlans = __esm({
|
|
|
8220
8252
|
|
|
8221
8253
|
// src/cli.ts
|
|
8222
8254
|
import { rmSync as rmSync4 } from "node:fs";
|
|
8223
|
-
import { join as
|
|
8255
|
+
import { join as join9 } from "node:path";
|
|
8224
8256
|
import { createInterface } from "node:readline/promises";
|
|
8225
8257
|
|
|
8226
8258
|
// src/catalog.ts
|
|
8227
8259
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
8228
8260
|
import { join as join2 } from "node:path";
|
|
8229
8261
|
|
|
8262
|
+
// ../src/lib/priceTrend.ts
|
|
8263
|
+
var TREND_WINDOWS = ["1d", "7d", "30d"];
|
|
8264
|
+
var SLOT = { "7d": 2, "30d": 3, "1d": 4 };
|
|
8265
|
+
function cardTrend(tuple2, window2) {
|
|
8266
|
+
if (!tuple2) return null;
|
|
8267
|
+
const now = tuple2[0];
|
|
8268
|
+
const then = tuple2[SLOT[window2]] ?? null;
|
|
8269
|
+
if (now == null || then == null || then === now) return null;
|
|
8270
|
+
return { now, then, delta: now - then, pct: then > 0 ? (now - then) / then : 0 };
|
|
8271
|
+
}
|
|
8272
|
+
function cardTrendWindows(tuple2, asOf) {
|
|
8273
|
+
const out = {};
|
|
8274
|
+
for (const w of TREND_WINDOWS) {
|
|
8275
|
+
const at = asOf[w];
|
|
8276
|
+
if (!at) continue;
|
|
8277
|
+
const t = cardTrend(tuple2, w);
|
|
8278
|
+
out[w] = { delta: t?.delta ?? 0, pct: t?.pct ?? 0, asOf: at };
|
|
8279
|
+
}
|
|
8280
|
+
return out;
|
|
8281
|
+
}
|
|
8282
|
+
|
|
8230
8283
|
// ../src/lib/cardInsights.ts
|
|
8231
8284
|
init_slug();
|
|
8232
8285
|
|
|
@@ -8577,6 +8630,13 @@ function expandImageUrl(s) {
|
|
|
8577
8630
|
}
|
|
8578
8631
|
|
|
8579
8632
|
// ../src/lib/scryfall/bakedPrintingsFormat.ts
|
|
8633
|
+
function decodeFinishMask(mask) {
|
|
8634
|
+
const out = [];
|
|
8635
|
+
if (mask.includes("n")) out.push("nonfoil");
|
|
8636
|
+
if (mask.includes("f")) out.push("foil");
|
|
8637
|
+
if (mask.includes("e")) out.push("etched");
|
|
8638
|
+
return out;
|
|
8639
|
+
}
|
|
8580
8640
|
var KNOWN_FINISH_TREATMENTS = [
|
|
8581
8641
|
"confettifoil",
|
|
8582
8642
|
"galaxyfoil",
|
|
@@ -8616,6 +8676,46 @@ var TREATMENT_CODES = {
|
|
|
8616
8676
|
var CODE_TO_TREATMENT = Object.fromEntries(
|
|
8617
8677
|
KNOWN_FINISH_TREATMENTS.map((t) => [TREATMENT_CODES[t], t])
|
|
8618
8678
|
);
|
|
8679
|
+
function decodeTreatment(code) {
|
|
8680
|
+
if (!code) return void 0;
|
|
8681
|
+
return CODE_TO_TREATMENT[code];
|
|
8682
|
+
}
|
|
8683
|
+
function decodeRarity(char) {
|
|
8684
|
+
switch (char) {
|
|
8685
|
+
case "m":
|
|
8686
|
+
return "mythic";
|
|
8687
|
+
case "r":
|
|
8688
|
+
return "rare";
|
|
8689
|
+
case "u":
|
|
8690
|
+
return "uncommon";
|
|
8691
|
+
case "s":
|
|
8692
|
+
return "special";
|
|
8693
|
+
case "c":
|
|
8694
|
+
default:
|
|
8695
|
+
return "common";
|
|
8696
|
+
}
|
|
8697
|
+
}
|
|
8698
|
+
function hydratePrinting(st, price) {
|
|
8699
|
+
const image = st.i ? expandImageUrl(st.i) : void 0;
|
|
8700
|
+
const opt = {
|
|
8701
|
+
set: st.s,
|
|
8702
|
+
setName: st.sn,
|
|
8703
|
+
collectorNumber: st.c,
|
|
8704
|
+
finishes: decodeFinishMask(st.f),
|
|
8705
|
+
rarity: decodeRarity(st.r),
|
|
8706
|
+
priceUsd: price?.[0] ?? null,
|
|
8707
|
+
priceUsdFoil: price?.[1] ?? null
|
|
8708
|
+
};
|
|
8709
|
+
if (image) opt.image = image;
|
|
8710
|
+
if (st.b) opt.backImage = st.b;
|
|
8711
|
+
if (st.d) opt.releasedAt = st.d;
|
|
8712
|
+
const treatment = decodeTreatment(st.t);
|
|
8713
|
+
if (treatment) opt.treatment = treatment;
|
|
8714
|
+
return opt;
|
|
8715
|
+
}
|
|
8716
|
+
function hydrateOraclePrintings(structs, prices) {
|
|
8717
|
+
return structs.map((st, i) => hydratePrinting(st, prices?.[i]));
|
|
8718
|
+
}
|
|
8619
8719
|
|
|
8620
8720
|
// ../src/lib/scryfall/treatmentAliases.ts
|
|
8621
8721
|
var TREATMENT_IS_CODES = (() => {
|
|
@@ -9140,6 +9240,18 @@ function parseExpr(toks, leafOf) {
|
|
|
9140
9240
|
if (i < toks.length) throw new ExprError("unbalanced parentheses");
|
|
9141
9241
|
return root;
|
|
9142
9242
|
}
|
|
9243
|
+
function forEachLeaf(node2, fn) {
|
|
9244
|
+
switch (node2.kind) {
|
|
9245
|
+
case "leaf":
|
|
9246
|
+
fn(node2.clauses);
|
|
9247
|
+
return;
|
|
9248
|
+
case "not":
|
|
9249
|
+
forEachLeaf(node2.child, fn);
|
|
9250
|
+
return;
|
|
9251
|
+
default:
|
|
9252
|
+
for (const c of node2.children) forEachLeaf(c, fn);
|
|
9253
|
+
}
|
|
9254
|
+
}
|
|
9143
9255
|
function parseBooleanQuery(input2, tokens, parens, out) {
|
|
9144
9256
|
const addUnsupported = (c) => {
|
|
9145
9257
|
if (!out.unsupported.some((u) => u.label === c.label)) out.unsupported.push(c);
|
|
@@ -9362,6 +9474,20 @@ function hasRunnableClause(q) {
|
|
|
9362
9474
|
if (q.tree !== null) return true;
|
|
9363
9475
|
return q.text !== "" || q.exactName !== null || q.negated.length > 0 || q.color !== null || q.identity !== null || q.types.length > 0 || q.mv.length > 0 || q.mvParity !== null || q.year.length > 0 || q.edhrecRank.length > 0 || q.oracle.length > 0 || q.otags.length > 0 || q.otagsBroad.length > 0 || q.roles.length > 0 || q.sets.length > 0 || q.finishes.length > 0 || q.treatments.length > 0 || q.keywords.length > 0 || q.isDerived.length > 0 || q.rarities.length > 0 || q.rarityCmp.length > 0 || q.pow.length > 0 || q.tou.length > 0 || q.loy.length > 0 || q.produces !== null || q.price.length > 0 || q.ownership !== null || q.ub !== "include" || q.banned !== null || q.reserved !== null || q.commander !== null;
|
|
9364
9476
|
}
|
|
9477
|
+
function negatedBroadSlugs(q) {
|
|
9478
|
+
const out = [];
|
|
9479
|
+
const add = (slugs) => {
|
|
9480
|
+
for (const s of slugs) if (!out.includes(s)) out.push(s);
|
|
9481
|
+
};
|
|
9482
|
+
const walk = (sub) => {
|
|
9483
|
+
add(sub.otagsBroad);
|
|
9484
|
+
for (const n of sub.negated) walk(n);
|
|
9485
|
+
if (sub.tree) forEachLeaf(sub.tree, walk);
|
|
9486
|
+
};
|
|
9487
|
+
for (const n of q.negated) walk(n);
|
|
9488
|
+
if (q.tree) forEachLeaf(q.tree, walk);
|
|
9489
|
+
return out;
|
|
9490
|
+
}
|
|
9365
9491
|
function isQueryUnrunnable(q) {
|
|
9366
9492
|
const broken = q.unsupported.length > 0 || q.warnings.length > 0;
|
|
9367
9493
|
if (!broken) return false;
|
|
@@ -9492,8 +9618,8 @@ function parseToken(token) {
|
|
|
9492
9618
|
const parts = rhs.split(",").map((s) => s.trim()).filter(Boolean);
|
|
9493
9619
|
if (parts.length === 0) return { kind: "warn", value: `empty rarity filter` };
|
|
9494
9620
|
const rs = [];
|
|
9495
|
-
for (const
|
|
9496
|
-
const canon = RARITY_ALIASES[
|
|
9621
|
+
for (const part2 of parts) {
|
|
9622
|
+
const canon = RARITY_ALIASES[part2] ?? part2;
|
|
9497
9623
|
if (!RARITY_VALUES.has(canon)) {
|
|
9498
9624
|
return { kind: "warn", value: `bad rarity value: "${token}"` };
|
|
9499
9625
|
}
|
|
@@ -10127,7 +10253,7 @@ function buildCatalogPredicate(filters) {
|
|
|
10127
10253
|
mvMax,
|
|
10128
10254
|
types,
|
|
10129
10255
|
themes,
|
|
10130
|
-
ownership,
|
|
10256
|
+
ownership: ownership2,
|
|
10131
10257
|
ubMode,
|
|
10132
10258
|
role,
|
|
10133
10259
|
gameChangersOnly,
|
|
@@ -10167,7 +10293,7 @@ function buildCatalogPredicate(filters) {
|
|
|
10167
10293
|
if (!hit.pass) return { pass: false };
|
|
10168
10294
|
matchedAltIndex = hit.matchedAltIndex;
|
|
10169
10295
|
}
|
|
10170
|
-
const effectiveOwnership =
|
|
10296
|
+
const effectiveOwnership = ownership2 !== "all" ? ownership2 : parsed.ownership ?? "all";
|
|
10171
10297
|
if (effectiveOwnership === "owned" && !entry.owned) return { pass: false };
|
|
10172
10298
|
if (effectiveOwnership === "unowned" && entry.owned) return { pass: false };
|
|
10173
10299
|
const effectiveUb = parsed.ub !== "include" ? parsed.ub : ubMode;
|
|
@@ -10260,6 +10386,90 @@ function buildOtagIndex(data) {
|
|
|
10260
10386
|
descendantsOf
|
|
10261
10387
|
};
|
|
10262
10388
|
}
|
|
10389
|
+
function resolveOtagTokens(index, positive, negated) {
|
|
10390
|
+
const built = positive.length ? buildOtagBroadMatch(index, positive) : { match: null, unknown: [] };
|
|
10391
|
+
const negatedMatchers = /* @__PURE__ */ new Map();
|
|
10392
|
+
const negUnknown = [];
|
|
10393
|
+
for (const slug of negated) {
|
|
10394
|
+
const one = buildOtagBroadMatch(index, [slug]);
|
|
10395
|
+
if (one.unknown.length > 0) {
|
|
10396
|
+
negUnknown.push(...one.unknown);
|
|
10397
|
+
continue;
|
|
10398
|
+
}
|
|
10399
|
+
negatedMatchers.set(slug, one.match);
|
|
10400
|
+
}
|
|
10401
|
+
return { match: built.match, unknown: [...built.unknown, ...negUnknown], negatedMatchers };
|
|
10402
|
+
}
|
|
10403
|
+
function buildOtagBroadMatch(index, slugs) {
|
|
10404
|
+
const tokens = [];
|
|
10405
|
+
const unknown2 = [];
|
|
10406
|
+
for (const slug of slugs) {
|
|
10407
|
+
const i = index.indexOfSlug.get(slug);
|
|
10408
|
+
if (i === void 0) {
|
|
10409
|
+
unknown2.push(slug);
|
|
10410
|
+
continue;
|
|
10411
|
+
}
|
|
10412
|
+
tokens.push(index.descendantsOf(i));
|
|
10413
|
+
}
|
|
10414
|
+
if (unknown2.length > 0) return { match: () => false, unknown: unknown2 };
|
|
10415
|
+
return {
|
|
10416
|
+
match: (oracleId) => {
|
|
10417
|
+
const have = index.tagIndicesByOid.get(oracleId);
|
|
10418
|
+
if (!have) return false;
|
|
10419
|
+
for (const token of tokens) {
|
|
10420
|
+
let hit = false;
|
|
10421
|
+
for (const ti of have) {
|
|
10422
|
+
if (token.has(ti)) {
|
|
10423
|
+
hit = true;
|
|
10424
|
+
break;
|
|
10425
|
+
}
|
|
10426
|
+
}
|
|
10427
|
+
if (!hit) return false;
|
|
10428
|
+
}
|
|
10429
|
+
return true;
|
|
10430
|
+
},
|
|
10431
|
+
unknown: unknown2
|
|
10432
|
+
};
|
|
10433
|
+
}
|
|
10434
|
+
|
|
10435
|
+
// ../src/lib/cardCatalog/setIndex.ts
|
|
10436
|
+
init_fetchWithTimeout();
|
|
10437
|
+
function hydrateSetIndex(file3) {
|
|
10438
|
+
const membership = /* @__PURE__ */ new Map();
|
|
10439
|
+
for (const [oid, codes] of Object.entries(file3.membership ?? {})) {
|
|
10440
|
+
membership.set(oid, new Set(codes));
|
|
10441
|
+
}
|
|
10442
|
+
const finishes = new Map(Object.entries(file3.finishes ?? {}));
|
|
10443
|
+
const treatments = /* @__PURE__ */ new Map();
|
|
10444
|
+
for (const [oid, codes] of Object.entries(file3.treatments ?? {})) {
|
|
10445
|
+
treatments.set(oid, new Set(codes));
|
|
10446
|
+
}
|
|
10447
|
+
return { membership, finishes, treatments, sets: file3.sets ?? [] };
|
|
10448
|
+
}
|
|
10449
|
+
function buildSetMatch(idx) {
|
|
10450
|
+
return (oracleId, codes) => {
|
|
10451
|
+
const has2 = idx.membership.get(oracleId);
|
|
10452
|
+
if (!has2) return false;
|
|
10453
|
+
for (const c of codes) if (has2.has(c)) return true;
|
|
10454
|
+
return false;
|
|
10455
|
+
};
|
|
10456
|
+
}
|
|
10457
|
+
function buildFinishMatch(idx) {
|
|
10458
|
+
return (oracleId, finishes) => {
|
|
10459
|
+
const mask = idx.finishes.get(oracleId);
|
|
10460
|
+
if (!mask) return false;
|
|
10461
|
+
for (const f of finishes) if (!mask.includes(f)) return false;
|
|
10462
|
+
return true;
|
|
10463
|
+
};
|
|
10464
|
+
}
|
|
10465
|
+
function buildTreatmentMatch(idx) {
|
|
10466
|
+
return (oracleId, codes) => {
|
|
10467
|
+
const has2 = idx.treatments.get(oracleId);
|
|
10468
|
+
if (!has2) return false;
|
|
10469
|
+
for (const c of codes) if (!has2.has(c)) return false;
|
|
10470
|
+
return true;
|
|
10471
|
+
};
|
|
10472
|
+
}
|
|
10263
10473
|
|
|
10264
10474
|
// ../src/lib/banlist.ts
|
|
10265
10475
|
init_slug();
|
|
@@ -10321,6 +10531,9 @@ var COMPANION_BANNED_SLUG_SET = new Set(
|
|
|
10321
10531
|
function isBannedName(name) {
|
|
10322
10532
|
return BANNED_SET.has(normalize(name)) || BANNED_SLUG_SET.has(toEdhrecSlug(name));
|
|
10323
10533
|
}
|
|
10534
|
+
function isCompanionBannedName(name) {
|
|
10535
|
+
return COMPANION_BANNED_SET.has(normalize(name)) || COMPANION_BANNED_SLUG_SET.has(toEdhrecSlug(name));
|
|
10536
|
+
}
|
|
10324
10537
|
function isCardBanned(card) {
|
|
10325
10538
|
if (card.banned) return true;
|
|
10326
10539
|
return !card.commanderLegal && isBannedName(card.name);
|
|
@@ -10527,6 +10740,32 @@ function assessDeck(deck, cards, bySlug) {
|
|
|
10527
10740
|
// ../src/lib/scryfall/loader.ts
|
|
10528
10741
|
init_build();
|
|
10529
10742
|
init_storage();
|
|
10743
|
+
|
|
10744
|
+
// ../src/lib/scryfall/priceOverlay.ts
|
|
10745
|
+
var overlay = null;
|
|
10746
|
+
function applyPriceOverlay(index, prices = overlay) {
|
|
10747
|
+
if (!prices) return 0;
|
|
10748
|
+
let changed = 0;
|
|
10749
|
+
for (const [oid, t] of prices) {
|
|
10750
|
+
const card = index.byOracleId.get(oid);
|
|
10751
|
+
if (!card) continue;
|
|
10752
|
+
const usd = t[0];
|
|
10753
|
+
const eur = t[1];
|
|
10754
|
+
let hit = false;
|
|
10755
|
+
if (usd != null && card.priceUsd !== usd) {
|
|
10756
|
+
card.priceUsd = usd;
|
|
10757
|
+
hit = true;
|
|
10758
|
+
}
|
|
10759
|
+
if (eur != null && card.priceEur !== eur) {
|
|
10760
|
+
card.priceEur = eur;
|
|
10761
|
+
hit = true;
|
|
10762
|
+
}
|
|
10763
|
+
if (hit) changed++;
|
|
10764
|
+
}
|
|
10765
|
+
return changed;
|
|
10766
|
+
}
|
|
10767
|
+
|
|
10768
|
+
// ../src/lib/scryfall/loader.ts
|
|
10530
10769
|
init_fetchWithTimeout();
|
|
10531
10770
|
var ROLE_CHAR_TO_NAME = {
|
|
10532
10771
|
l: "land",
|
|
@@ -10747,7 +10986,7 @@ function buildIndex(cards, builtAt) {
|
|
|
10747
10986
|
// src/cardData.ts
|
|
10748
10987
|
import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
10749
10988
|
import { join } from "node:path";
|
|
10750
|
-
var SIDE_FILES = ["oracle-text.json", "otags.json"];
|
|
10989
|
+
var SIDE_FILES = ["oracle-text.json", "otags.json", "set-index.json"];
|
|
10751
10990
|
var CARD_SET = {
|
|
10752
10991
|
name: "cards",
|
|
10753
10992
|
manifest: "cards-manifest.json",
|
|
@@ -10758,6 +10997,11 @@ var COMBO_SET = {
|
|
|
10758
10997
|
manifest: "combos-manifest.json",
|
|
10759
10998
|
files: (m) => ["combos.json", ...m.parts ?? []]
|
|
10760
10999
|
};
|
|
11000
|
+
var COMBO_DETAIL_SET = {
|
|
11001
|
+
name: "combo-detail",
|
|
11002
|
+
manifest: "combos-manifest.json",
|
|
11003
|
+
files: (m) => ["combos-detail.json", ...m.detailParts ?? []]
|
|
11004
|
+
};
|
|
10761
11005
|
var SAFE_NAME = /^[a-z0-9.-]+\.json$/i;
|
|
10762
11006
|
function ensureCardData(opts) {
|
|
10763
11007
|
return ensureDataSet(opts, CARD_SET);
|
|
@@ -10807,24 +11051,73 @@ async function ensureDataSet(opts, set2) {
|
|
|
10807
11051
|
}
|
|
10808
11052
|
|
|
10809
11053
|
// src/catalog.ts
|
|
10810
|
-
function
|
|
11054
|
+
function setCodes(q, out = /* @__PURE__ */ new Set()) {
|
|
11055
|
+
for (const c of q.sets) out.add(c);
|
|
11056
|
+
for (const n of q.negated) setCodes(n, out);
|
|
11057
|
+
if (q.tree) forEachLeaf(q.tree, (leaf) => setCodes(leaf, out));
|
|
11058
|
+
return out;
|
|
11059
|
+
}
|
|
11060
|
+
function buildCatalog(cards, builtAt, oracleMap, stale, otagFile = () => null, setFile = () => null) {
|
|
10811
11061
|
const index = buildIndex(cards, builtAt);
|
|
10812
11062
|
const oracle = (oid) => oracleMap[oid];
|
|
10813
11063
|
let otagIndex;
|
|
11064
|
+
let setIndex;
|
|
11065
|
+
const sets = () => {
|
|
11066
|
+
if (setIndex === void 0) {
|
|
11067
|
+
const raw = setFile();
|
|
11068
|
+
setIndex = raw ? hydrateSetIndex(raw) : null;
|
|
11069
|
+
}
|
|
11070
|
+
return setIndex;
|
|
11071
|
+
};
|
|
11072
|
+
const otags = () => {
|
|
11073
|
+
if (otagIndex === void 0) {
|
|
11074
|
+
const raw = otagFile();
|
|
11075
|
+
otagIndex = raw ? buildOtagIndex(raw) : null;
|
|
11076
|
+
}
|
|
11077
|
+
return otagIndex;
|
|
11078
|
+
};
|
|
11079
|
+
const resolve = (parsed) => {
|
|
11080
|
+
const tags = otags();
|
|
11081
|
+
const t = tags ? resolveOtagTokens(tags, parsed.otagsBroad, negatedBroadSlugs(parsed)) : null;
|
|
11082
|
+
const si = sets();
|
|
11083
|
+
return {
|
|
11084
|
+
unknownTags: t?.unknown ?? [],
|
|
11085
|
+
filters: {
|
|
11086
|
+
otagBroadMatch: t ? t.match : parsed.otagsBroad.length ? () => false : null,
|
|
11087
|
+
otagBroadNegated: t ? t.negatedMatchers : /* @__PURE__ */ new Map(),
|
|
11088
|
+
setMatch: si ? buildSetMatch(si) : null,
|
|
11089
|
+
finishMatch: si ? buildFinishMatch(si) : null,
|
|
11090
|
+
treatmentMatch: si ? buildTreatmentMatch(si) : null
|
|
11091
|
+
}
|
|
11092
|
+
};
|
|
11093
|
+
};
|
|
10814
11094
|
return {
|
|
10815
11095
|
index,
|
|
10816
11096
|
bySlug: buildBuySlugIndex(index),
|
|
10817
11097
|
stale,
|
|
10818
11098
|
oracle,
|
|
10819
|
-
otags
|
|
10820
|
-
|
|
10821
|
-
|
|
10822
|
-
|
|
11099
|
+
otags,
|
|
11100
|
+
unsupported: (query) => parseScryfallQuery(query).unsupported.map((u) => u.label),
|
|
11101
|
+
notes(query) {
|
|
11102
|
+
const parsed = parseScryfallQuery(query);
|
|
11103
|
+
const out = [];
|
|
11104
|
+
const allTags = [...parsed.otagsBroad, ...negatedBroadSlugs(parsed)];
|
|
11105
|
+
if (allTags.length && !otags()) out.push("Scryfall tag data isn't available, so otag: clauses match nothing.");
|
|
11106
|
+
for (const t of resolve(parsed).unknownTags) out.push(`No Scryfall tag "${t}". Tags are slugs like otag:ramp or otag:mana-rock.`);
|
|
11107
|
+
const codes = [...setCodes(parsed)];
|
|
11108
|
+
const si = codes.length ? sets() : null;
|
|
11109
|
+
if (codes.length && !si) out.push("Set data isn't available, so set: clauses match nothing.");
|
|
11110
|
+
if (si) {
|
|
11111
|
+
const known = new Set(si.sets.map((s) => s.code.toLowerCase()));
|
|
11112
|
+
for (const c of codes) if (!known.has(c)) out.push(`No set with the code "${c}".`);
|
|
10823
11113
|
}
|
|
10824
|
-
return
|
|
11114
|
+
return out;
|
|
11115
|
+
},
|
|
11116
|
+
tagsOf(oracleId) {
|
|
11117
|
+
return (otags()?.entriesByOid.get(oracleId) ?? []).map((e) => e.slug);
|
|
10825
11118
|
},
|
|
10826
|
-
unsupported: (query) => parseScryfallQuery(query).unsupported.map((u) => u.label),
|
|
10827
11119
|
search(query) {
|
|
11120
|
+
const parsed = parseScryfallQuery(query);
|
|
10828
11121
|
const pred = buildCatalogPredicate({
|
|
10829
11122
|
query,
|
|
10830
11123
|
colors: /* @__PURE__ */ new Set(),
|
|
@@ -10837,7 +11130,8 @@ function buildCatalog(cards, builtAt, oracleMap, stale, otagFile = () => null) {
|
|
|
10837
11130
|
ownership: "all",
|
|
10838
11131
|
ubMode: "include",
|
|
10839
11132
|
sortBy: "popularity",
|
|
10840
|
-
oracleText: oracle
|
|
11133
|
+
oracleText: oracle,
|
|
11134
|
+
...resolve(parsed).filters
|
|
10841
11135
|
});
|
|
10842
11136
|
return cards.filter((card) => pred({ card, owned: false }).pass);
|
|
10843
11137
|
}
|
|
@@ -10851,13 +11145,18 @@ function readCatalog(files) {
|
|
|
10851
11145
|
}
|
|
10852
11146
|
const cards = rows.map((r) => expandCatalogRow(r));
|
|
10853
11147
|
const { oracle } = JSON.parse(readFileSync2(join2(files.dir, "oracle-text.json"), "utf8"));
|
|
10854
|
-
const
|
|
10855
|
-
return buildCatalog(cards, files.builtAt, oracle, files.stale, ()
|
|
11148
|
+
const read = (name) => () => JSON.parse(readFileSync2(join2(files.dir, name), "utf8"));
|
|
11149
|
+
return buildCatalog(cards, files.builtAt, oracle, files.stale, read("otags.json"), read("set-index.json"));
|
|
11150
|
+
}
|
|
11151
|
+
function withPrices(catalog, prices) {
|
|
11152
|
+
applyPriceOverlay(catalog.index, prices.byOid);
|
|
11153
|
+
catalog.pricedAt = prices.pricedAt;
|
|
11154
|
+
return catalog;
|
|
10856
11155
|
}
|
|
10857
11156
|
function catalogLoader(opts) {
|
|
10858
11157
|
let loading = null;
|
|
10859
11158
|
return () => {
|
|
10860
|
-
loading ??= ensureCardData(opts).then(readCatalog).catch((e) => {
|
|
11159
|
+
loading ??= ensureCardData(opts).then(readCatalog).then(async (c) => opts.prices ? opts.prices().then((p) => withPrices(c, p), () => c) : c).catch((e) => {
|
|
10861
11160
|
loading = null;
|
|
10862
11161
|
throw e;
|
|
10863
11162
|
});
|
|
@@ -10874,9 +11173,9 @@ function readComboIndex(files) {
|
|
|
10874
11173
|
if (typeof index.builtAt !== "string" || !Array.isArray(index.variants) || !Array.isArray(index.features)) {
|
|
10875
11174
|
throw new Error("The combo index on disk is damaged.");
|
|
10876
11175
|
}
|
|
10877
|
-
for (const
|
|
10878
|
-
const doc = read(
|
|
10879
|
-
if (doc.builtAt !== index.builtAt || !Array.isArray(doc.variants)) throw new Error(`${
|
|
11176
|
+
for (const part2 of index.parts ?? []) {
|
|
11177
|
+
const doc = read(part2);
|
|
11178
|
+
if (doc.builtAt !== index.builtAt || !Array.isArray(doc.variants)) throw new Error(`${part2} is from another build.`);
|
|
10880
11179
|
index.variants.push(...doc.variants);
|
|
10881
11180
|
}
|
|
10882
11181
|
return index;
|
|
@@ -10892,9 +11191,119 @@ function comboLoader(opts) {
|
|
|
10892
11191
|
};
|
|
10893
11192
|
}
|
|
10894
11193
|
|
|
10895
|
-
// src/
|
|
10896
|
-
import { existsSync as
|
|
11194
|
+
// src/extras.ts
|
|
11195
|
+
import { existsSync as existsSync3, readFileSync as readFileSync5 } from "node:fs";
|
|
11196
|
+
import { join as join5 } from "node:path";
|
|
11197
|
+
|
|
11198
|
+
// src/dataFile.ts
|
|
11199
|
+
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync4, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
10897
11200
|
import { join as join4 } from "node:path";
|
|
11201
|
+
async function ensureFile(opts, name) {
|
|
11202
|
+
if (!SAFE_NAME.test(name)) throw new Error(`Not a data file name: ${name}`);
|
|
11203
|
+
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
11204
|
+
const origin = opts.origin ?? "https://edhvault.com";
|
|
11205
|
+
const dir = join4(opts.dir, "files");
|
|
11206
|
+
mkdirSync2(dir, { recursive: true });
|
|
11207
|
+
const path = join4(dir, name);
|
|
11208
|
+
const metaPath = `${path}.meta.json`;
|
|
11209
|
+
const cached2 = existsSync2(path) && existsSync2(metaPath) ? JSON.parse(readFileSync4(metaPath, "utf8")) : null;
|
|
11210
|
+
const headers = {};
|
|
11211
|
+
if (cached2?.etag) headers["If-None-Match"] = cached2.etag;
|
|
11212
|
+
if (cached2?.lastModified) headers["If-Modified-Since"] = cached2.lastModified;
|
|
11213
|
+
let res;
|
|
11214
|
+
try {
|
|
11215
|
+
res = await fetchImpl(`${origin}/data/${name}`, { headers, signal: AbortSignal.timeout(opts.timeoutMs ?? 12e4) });
|
|
11216
|
+
} catch (e) {
|
|
11217
|
+
if (cached2) return { path, stale: true };
|
|
11218
|
+
throw e;
|
|
11219
|
+
}
|
|
11220
|
+
if (res.status === 304 && cached2) return { path, stale: false };
|
|
11221
|
+
if (!res.ok) {
|
|
11222
|
+
if (cached2) return { path, stale: true };
|
|
11223
|
+
throw new Error(`${name}: ${res.status}`);
|
|
11224
|
+
}
|
|
11225
|
+
let body;
|
|
11226
|
+
try {
|
|
11227
|
+
body = new Uint8Array(await res.arrayBuffer());
|
|
11228
|
+
} catch (e) {
|
|
11229
|
+
if (cached2) return { path, stale: true };
|
|
11230
|
+
throw e;
|
|
11231
|
+
}
|
|
11232
|
+
writeFileSync2(`${path}.incoming`, body);
|
|
11233
|
+
renameSync2(`${path}.incoming`, path);
|
|
11234
|
+
const etag = res.headers.get("etag");
|
|
11235
|
+
const lastModified = res.headers.get("last-modified");
|
|
11236
|
+
writeFileSync2(metaPath, JSON.stringify({ ...etag ? { etag } : {}, ...lastModified ? { lastModified } : {} }));
|
|
11237
|
+
return { path, stale: false };
|
|
11238
|
+
}
|
|
11239
|
+
|
|
11240
|
+
// src/extras.ts
|
|
11241
|
+
var parse = {
|
|
11242
|
+
prices(raw) {
|
|
11243
|
+
const doc = raw;
|
|
11244
|
+
if (typeof doc.pricedAt !== "string" || !doc.prices) throw new Error("card-prices.json is damaged.");
|
|
11245
|
+
return { pricedAt: doc.pricedAt, asOf: doc.trend ?? {}, byOid: new Map(Object.entries(doc.prices)) };
|
|
11246
|
+
},
|
|
11247
|
+
printings(raw) {
|
|
11248
|
+
const doc = raw;
|
|
11249
|
+
if (typeof doc.builtAt !== "string" || !doc.p || !doc.pr) throw new Error("printings.json is damaged.");
|
|
11250
|
+
return doc;
|
|
11251
|
+
},
|
|
11252
|
+
printingTrend(raw) {
|
|
11253
|
+
const doc = raw;
|
|
11254
|
+
if (typeof doc.pricedAt !== "string" || !doc.s) throw new Error("printing-prices-trend.json is damaged.");
|
|
11255
|
+
return doc;
|
|
11256
|
+
},
|
|
11257
|
+
landCycles(raw) {
|
|
11258
|
+
const doc = raw;
|
|
11259
|
+
if (!Array.isArray(doc.cycles)) throw new Error("land-cycles.json is damaged.");
|
|
11260
|
+
return doc.cycles;
|
|
11261
|
+
},
|
|
11262
|
+
/** Every detail file of one build, as one map. A part from another build is
|
|
11263
|
+
* refused (it would pair one build's ids with another's steps). */
|
|
11264
|
+
comboDetail(docs) {
|
|
11265
|
+
const first = docs[0];
|
|
11266
|
+
const out = {};
|
|
11267
|
+
for (const raw of docs) {
|
|
11268
|
+
const doc = raw;
|
|
11269
|
+
if (!Array.isArray(doc.detail) || doc.builtAt !== first?.builtAt) throw new Error("The combo steps on disk are from different builds.");
|
|
11270
|
+
for (const r of doc.detail) out[r.i] = { ...r.x ? { x: r.x } : {}, ...r.s ? { s: r.s } : {}, ...r.m ? { m: r.m } : {} };
|
|
11271
|
+
}
|
|
11272
|
+
return out;
|
|
11273
|
+
}
|
|
11274
|
+
};
|
|
11275
|
+
function extrasLoader(opts) {
|
|
11276
|
+
const stale = /* @__PURE__ */ new Set();
|
|
11277
|
+
const once = (load) => {
|
|
11278
|
+
let p = null;
|
|
11279
|
+
return () => p ??= load().catch((e) => {
|
|
11280
|
+
p = null;
|
|
11281
|
+
throw e;
|
|
11282
|
+
});
|
|
11283
|
+
};
|
|
11284
|
+
const file3 = (name, read) => once(async () => {
|
|
11285
|
+
const got = await ensureFile(opts, name);
|
|
11286
|
+
if (got.stale) stale.add(name);
|
|
11287
|
+
return read(JSON.parse(readFileSync5(got.path, "utf8")));
|
|
11288
|
+
});
|
|
11289
|
+
return {
|
|
11290
|
+
prices: file3("card-prices.json", parse.prices),
|
|
11291
|
+
printings: file3("printings.json", parse.printings),
|
|
11292
|
+
printingTrend: file3("printing-prices-trend.json", parse.printingTrend),
|
|
11293
|
+
landCycles: file3("land-cycles.json", parse.landCycles),
|
|
11294
|
+
comboDetail: once(async () => {
|
|
11295
|
+
const files = await ensureDataSet(opts, COMBO_DETAIL_SET);
|
|
11296
|
+
if (files.stale) stale.add("combos-detail.json");
|
|
11297
|
+
return parse.comboDetail(files.files.map((n) => JSON.parse(readFileSync5(join5(files.dir, n), "utf8"))));
|
|
11298
|
+
}),
|
|
11299
|
+
comboStepsOnDisk: () => existsSync3(join5(opts.dir, COMBO_DETAIL_SET.name, "manifest.json")),
|
|
11300
|
+
stale: () => [...stale]
|
|
11301
|
+
};
|
|
11302
|
+
}
|
|
11303
|
+
|
|
11304
|
+
// src/library.ts
|
|
11305
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync3, readdirSync, readFileSync as readFileSync6, rmSync as rmSync2, writeFileSync as writeFileSync3 } from "node:fs";
|
|
11306
|
+
import { join as join6 } from "node:path";
|
|
10898
11307
|
|
|
10899
11308
|
// ../src/lib/sync/agentAccess.ts
|
|
10900
11309
|
init_sealedBox();
|
|
@@ -10971,7 +11380,7 @@ function entries(index) {
|
|
|
10971
11380
|
var Library = class {
|
|
10972
11381
|
constructor(opts) {
|
|
10973
11382
|
this.opts = opts;
|
|
10974
|
-
this.cache =
|
|
11383
|
+
this.cache = join6(opts.dir, "view");
|
|
10975
11384
|
this.now = opts.now ?? Date.now;
|
|
10976
11385
|
this.freshMs = opts.freshMs ?? FRESH_MS;
|
|
10977
11386
|
}
|
|
@@ -11033,19 +11442,19 @@ var Library = class {
|
|
|
11033
11442
|
return this.index;
|
|
11034
11443
|
}
|
|
11035
11444
|
prune(index) {
|
|
11036
|
-
if (!
|
|
11445
|
+
if (!existsSync4(this.cache)) return;
|
|
11037
11446
|
const live = new Set(entries(index).map((e) => e.obj));
|
|
11038
|
-
for (const f of readdirSync(this.cache)) if (!live.has(f)) rmSync2(
|
|
11447
|
+
for (const f of readdirSync(this.cache)) if (!live.has(f)) rmSync2(join6(this.cache, f), { force: true });
|
|
11039
11448
|
}
|
|
11040
11449
|
/** Object texts by name, from the disk cache or batched reads. */
|
|
11041
11450
|
async read(list) {
|
|
11042
11451
|
const { token, viewKey } = await this.connect();
|
|
11043
|
-
|
|
11452
|
+
mkdirSync3(this.cache, { recursive: true });
|
|
11044
11453
|
const sealed = /* @__PURE__ */ new Map();
|
|
11045
11454
|
const missing = [];
|
|
11046
11455
|
for (const e of list) {
|
|
11047
|
-
const file3 =
|
|
11048
|
-
if (
|
|
11456
|
+
const file3 = join6(this.cache, e.obj);
|
|
11457
|
+
if (existsSync4(file3)) sealed.set(e.obj, new Uint8Array(readFileSync6(file3)));
|
|
11049
11458
|
else missing.push(e.obj);
|
|
11050
11459
|
}
|
|
11051
11460
|
for (let i = 0; i < missing.length; i += GET_BATCH) {
|
|
@@ -11058,7 +11467,7 @@ var Library = class {
|
|
|
11058
11467
|
for (const [name, bytes] of got) {
|
|
11059
11468
|
if (!bytes) continue;
|
|
11060
11469
|
sealed.set(name, bytes);
|
|
11061
|
-
|
|
11470
|
+
writeFileSync3(join6(this.cache, name), bytes);
|
|
11062
11471
|
}
|
|
11063
11472
|
}
|
|
11064
11473
|
const out = /* @__PURE__ */ new Map();
|
|
@@ -11097,14 +11506,14 @@ var Library = class {
|
|
|
11097
11506
|
};
|
|
11098
11507
|
|
|
11099
11508
|
// src/log.ts
|
|
11100
|
-
import { appendFileSync, mkdirSync as
|
|
11509
|
+
import { appendFileSync, mkdirSync as mkdirSync4 } from "node:fs";
|
|
11101
11510
|
import { dirname } from "node:path";
|
|
11102
11511
|
var file = null;
|
|
11103
11512
|
var debugOn = false;
|
|
11104
11513
|
function configureLog(opts) {
|
|
11105
11514
|
file = opts.file ?? null;
|
|
11106
11515
|
debugOn = !!opts.debug;
|
|
11107
|
-
if (file)
|
|
11516
|
+
if (file) mkdirSync4(dirname(file), { recursive: true });
|
|
11108
11517
|
}
|
|
11109
11518
|
function write(level, message) {
|
|
11110
11519
|
const line = `${(/* @__PURE__ */ new Date()).toISOString()} ${level} ${message}
|
|
@@ -11172,9 +11581,9 @@ async function redeemPairCode(text, t = {}, purpose = "sync") {
|
|
|
11172
11581
|
// src/secretStore.ts
|
|
11173
11582
|
init_syncKeys();
|
|
11174
11583
|
import { execFileSync } from "node:child_process";
|
|
11175
|
-
import { chmodSync, existsSync as
|
|
11584
|
+
import { chmodSync, existsSync as existsSync5, mkdirSync as mkdirSync5, readFileSync as readFileSync7, rmSync as rmSync3, writeFileSync as writeFileSync4 } from "node:fs";
|
|
11176
11585
|
import { userInfo } from "node:os";
|
|
11177
|
-
import { dirname as dirname2, join as
|
|
11586
|
+
import { dirname as dirname2, join as join7 } from "node:path";
|
|
11178
11587
|
var SERVICE = "edhvault-mcp";
|
|
11179
11588
|
var ACCOUNT = "access-code";
|
|
11180
11589
|
async function osKeychain() {
|
|
@@ -11199,25 +11608,25 @@ function lockToOwner(file3) {
|
|
|
11199
11608
|
}
|
|
11200
11609
|
const windir = process.env.SystemRoot ?? "C:\\Windows";
|
|
11201
11610
|
execFileSync(
|
|
11202
|
-
|
|
11611
|
+
join7(windir, "System32", "icacls.exe"),
|
|
11203
11612
|
[file3, "/inheritance:r", "/grant:r", `${userInfo().username}:F`],
|
|
11204
11613
|
{ stdio: "ignore", windowsHide: true }
|
|
11205
11614
|
);
|
|
11206
11615
|
}
|
|
11207
11616
|
function fileKeychain(dir) {
|
|
11208
|
-
const file3 =
|
|
11617
|
+
const file3 = join7(dir, ACCOUNT);
|
|
11209
11618
|
return {
|
|
11210
|
-
get: () =>
|
|
11619
|
+
get: () => existsSync5(file3) ? readFileSync7(file3, "utf8").trim() : null,
|
|
11211
11620
|
set: (value) => {
|
|
11212
|
-
|
|
11213
|
-
|
|
11621
|
+
mkdirSync5(dirname2(file3), { recursive: true, mode: 448 });
|
|
11622
|
+
writeFileSync4(file3, "", { mode: 384 });
|
|
11214
11623
|
try {
|
|
11215
11624
|
lockToOwner(file3);
|
|
11216
11625
|
} catch (e) {
|
|
11217
11626
|
rmSync3(file3, { force: true });
|
|
11218
11627
|
throw new Error(`Couldn't make ${file3} private, so the code wasn't saved: ${e instanceof Error ? e.message : e}`);
|
|
11219
11628
|
}
|
|
11220
|
-
|
|
11629
|
+
writeFileSync4(file3, value);
|
|
11221
11630
|
},
|
|
11222
11631
|
remove: () => rmSync3(file3, { force: true })
|
|
11223
11632
|
};
|
|
@@ -11263,12 +11672,12 @@ async function login(code, store2, t) {
|
|
|
11263
11672
|
|
|
11264
11673
|
// src/paths.ts
|
|
11265
11674
|
import { homedir } from "node:os";
|
|
11266
|
-
import { join as
|
|
11675
|
+
import { join as join8 } from "node:path";
|
|
11267
11676
|
function configDir(env = process.env, platform = process.platform) {
|
|
11268
11677
|
if (env.EDHVAULT_MCP_HOME) return env.EDHVAULT_MCP_HOME;
|
|
11269
|
-
if (platform === "win32") return
|
|
11270
|
-
if (platform === "darwin") return
|
|
11271
|
-
return
|
|
11678
|
+
if (platform === "win32") return join8(env.APPDATA ?? join8(homedir(), "AppData", "Roaming"), "edhvault-mcp");
|
|
11679
|
+
if (platform === "darwin") return join8(homedir(), "Library", "Application Support", "edhvault-mcp");
|
|
11680
|
+
return join8(env.XDG_CONFIG_HOME ?? join8(homedir(), ".config"), "edhvault-mcp");
|
|
11272
11681
|
}
|
|
11273
11682
|
|
|
11274
11683
|
// ../node_modules/zod/v3/helpers/util.js
|
|
@@ -15453,7 +15862,7 @@ __export(core_exports2, {
|
|
|
15453
15862
|
memoizer: () => memoizer,
|
|
15454
15863
|
mergeValues: () => mergeValues2,
|
|
15455
15864
|
meta: () => meta,
|
|
15456
|
-
parse: () =>
|
|
15865
|
+
parse: () => parse2,
|
|
15457
15866
|
parseAsync: () => parseAsync,
|
|
15458
15867
|
parseURLObject: () => parseURLObject,
|
|
15459
15868
|
prettifyError: () => prettifyError,
|
|
@@ -16673,7 +17082,7 @@ var _parse = (_Err) => {
|
|
|
16673
17082
|
};
|
|
16674
17083
|
return fn;
|
|
16675
17084
|
};
|
|
16676
|
-
var
|
|
17085
|
+
var parse2 = /* @__PURE__ */ _parse($ZodRealError);
|
|
16677
17086
|
var _parseAsync = (_Err) => {
|
|
16678
17087
|
const fn = async (schema, value, _ctx, params) => {
|
|
16679
17088
|
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
@@ -16761,18 +17170,18 @@ var validateAsync = async (schema, value, _ctx) => {
|
|
|
16761
17170
|
return result.issues.length === 0;
|
|
16762
17171
|
};
|
|
16763
17172
|
var _encode = (_Err) => {
|
|
16764
|
-
const
|
|
17173
|
+
const parse4 = _parse(_Err);
|
|
16765
17174
|
const fn = (schema, value, _ctx, _params) => {
|
|
16766
17175
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
16767
|
-
return
|
|
17176
|
+
return parse4(schema, value, ctx, finalizeParams(fn, _params));
|
|
16768
17177
|
};
|
|
16769
17178
|
return fn;
|
|
16770
17179
|
};
|
|
16771
17180
|
var encode = /* @__PURE__ */ _encode($ZodRealError);
|
|
16772
17181
|
var _decode = (_Err) => {
|
|
16773
|
-
const
|
|
17182
|
+
const parse4 = _parse(_Err);
|
|
16774
17183
|
const fn = (schema, value, _ctx, _params) => {
|
|
16775
|
-
return
|
|
17184
|
+
return parse4(schema, value, _ctx, finalizeParams(fn, _params));
|
|
16776
17185
|
};
|
|
16777
17186
|
return fn;
|
|
16778
17187
|
};
|
|
@@ -18267,7 +18676,7 @@ function capSize(inst, size) {
|
|
|
18267
18676
|
if (!caps.length)
|
|
18268
18677
|
return;
|
|
18269
18678
|
const cap2 = Math.min(...caps.map((c) => c[0]));
|
|
18270
|
-
const
|
|
18679
|
+
const parse4 = inst._zod.parse;
|
|
18271
18680
|
inst._zod.parse = (payload, ctx) => {
|
|
18272
18681
|
const n = size(payload.value);
|
|
18273
18682
|
if (n > cap2 && !ctx?.skipChecks && ctx?.direction !== "backward") {
|
|
@@ -18281,7 +18690,7 @@ function capSize(inst, size) {
|
|
|
18281
18690
|
}
|
|
18282
18691
|
}
|
|
18283
18692
|
}
|
|
18284
|
-
return
|
|
18693
|
+
return parse4(payload, ctx);
|
|
18285
18694
|
};
|
|
18286
18695
|
}
|
|
18287
18696
|
var arraySize = (input2) => Array.isArray(input2) ? input2.length : -1;
|
|
@@ -19779,17 +20188,17 @@ function partPattern(schema) {
|
|
|
19779
20188
|
var $ZodTemplateLiteral = /* @__PURE__ */ $constructor("$ZodTemplateLiteral", (inst, def) => {
|
|
19780
20189
|
$ZodType.init(inst, def);
|
|
19781
20190
|
const regexParts = [];
|
|
19782
|
-
for (const
|
|
19783
|
-
if (typeof
|
|
19784
|
-
const source = partPattern(
|
|
20191
|
+
for (const part2 of def.parts) {
|
|
20192
|
+
if (typeof part2 === "object" && part2 !== null) {
|
|
20193
|
+
const source = partPattern(part2);
|
|
19785
20194
|
if (!source) {
|
|
19786
|
-
throw new Error(`Invalid template literal part, no pattern found: ${[...
|
|
20195
|
+
throw new Error(`Invalid template literal part, no pattern found: ${[...part2._zod.traits].shift()}`);
|
|
19787
20196
|
}
|
|
19788
20197
|
regexParts.push(cleanRegex(source));
|
|
19789
|
-
} else if (
|
|
19790
|
-
regexParts.push(escapeRegex(`${
|
|
20198
|
+
} else if (part2 === null || primitiveTypes.has(typeof part2)) {
|
|
20199
|
+
regexParts.push(escapeRegex(`${part2}`));
|
|
19791
20200
|
} else {
|
|
19792
|
-
throw new Error(`Invalid template literal part: ${
|
|
20201
|
+
throw new Error(`Invalid template literal part: ${part2}`);
|
|
19793
20202
|
}
|
|
19794
20203
|
}
|
|
19795
20204
|
inst._zod.pattern = new RegExp(`^${regexParts.join("")}$`);
|
|
@@ -19826,10 +20235,10 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
|
|
|
19826
20235
|
throw new Error("implement() must be called with a function");
|
|
19827
20236
|
}
|
|
19828
20237
|
return Object.defineProperty(function(...args) {
|
|
19829
|
-
const parsedArgs = inst._def.input ?
|
|
20238
|
+
const parsedArgs = inst._def.input ? parse2(inst._def.input, args) : args;
|
|
19830
20239
|
const result = Reflect.apply(func, this, parsedArgs);
|
|
19831
20240
|
if (inst._def.output) {
|
|
19832
|
-
return
|
|
20241
|
+
return parse2(inst._def.output, result);
|
|
19833
20242
|
}
|
|
19834
20243
|
return result;
|
|
19835
20244
|
}, "_zod", { value: inst._zod, enumerable: false });
|
|
@@ -30761,11 +31170,11 @@ function foldObjects(members2) {
|
|
|
30761
31170
|
continue;
|
|
30762
31171
|
const parts = [];
|
|
30763
31172
|
for (const other of objects) {
|
|
30764
|
-
const
|
|
30765
|
-
if (
|
|
31173
|
+
const part2 = other.properties?.[key] ?? undeclaredConstraint(other);
|
|
31174
|
+
if (part2 === null || part2 === void 0)
|
|
30766
31175
|
continue;
|
|
30767
|
-
if (!parts.some((seen) => JSON.stringify(seen) === JSON.stringify(
|
|
30768
|
-
parts.push(
|
|
31176
|
+
if (!parts.some((seen) => JSON.stringify(seen) === JSON.stringify(part2)))
|
|
31177
|
+
parts.push(part2);
|
|
30769
31178
|
}
|
|
30770
31179
|
const merged = parts.length === 1 ? parts[0] : foldObjects(parts) ?? { allOf: parts };
|
|
30771
31180
|
assignProp(properties, key, merged);
|
|
@@ -31889,7 +32298,7 @@ var ZodMiniType = /* @__PURE__ */ $constructor("ZodMiniType", (inst, def) => {
|
|
|
31889
32298
|
own(this, "with", value);
|
|
31890
32299
|
},
|
|
31891
32300
|
parse(data, params) {
|
|
31892
|
-
return
|
|
32301
|
+
return parse2(this, data, params, { callee: this.parse });
|
|
31893
32302
|
},
|
|
31894
32303
|
parseAsync(data, params) {
|
|
31895
32304
|
return parseAsync(this, data, params, { callee: this.parseAsync });
|
|
@@ -32452,7 +32861,7 @@ __export(external_exports, {
|
|
|
32452
32861
|
optional: () => optional,
|
|
32453
32862
|
output: () => output,
|
|
32454
32863
|
overwrite: () => _overwrite,
|
|
32455
|
-
parse: () =>
|
|
32864
|
+
parse: () => parse3,
|
|
32456
32865
|
parseAsync: () => parseAsync2,
|
|
32457
32866
|
partialRecord: () => partialRecord,
|
|
32458
32867
|
pipe: () => pipe,
|
|
@@ -32780,7 +33189,7 @@ var ZodRealError = /* @__PURE__ */ $constructor("ZodError", initializer2, void 0
|
|
|
32780
33189
|
});
|
|
32781
33190
|
|
|
32782
33191
|
// ../node_modules/zod/v4/classic/parse.js
|
|
32783
|
-
var
|
|
33192
|
+
var parse3 = /* @__PURE__ */ _parse(ZodRealError);
|
|
32784
33193
|
var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
32785
33194
|
var safeParse3 = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
32786
33195
|
var safeParseAsync3 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
@@ -32917,7 +33326,7 @@ var ZodType2 = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
32917
33326
|
util_exports.own(this, "~standard", value);
|
|
32918
33327
|
},
|
|
32919
33328
|
parse: function _parse2(data, params) {
|
|
32920
|
-
return
|
|
33329
|
+
return parse3(this, data, params, { callee: _parse2 });
|
|
32921
33330
|
},
|
|
32922
33331
|
parseAsync: async function _parseAsync2(data, params) {
|
|
32923
33332
|
return await parseAsync2(this, data, params, { callee: _parseAsync2 });
|
|
@@ -40697,6 +41106,165 @@ function countTwoCardInfiniteCombos(included) {
|
|
|
40697
41106
|
return seen.size;
|
|
40698
41107
|
}
|
|
40699
41108
|
|
|
41109
|
+
// ../src/lib/combos/comboIndex.ts
|
|
41110
|
+
function expandVariant(v, index, cardOf, detail) {
|
|
41111
|
+
const uses = v.u.map((u) => {
|
|
41112
|
+
const known = cardOf(u.o);
|
|
41113
|
+
return {
|
|
41114
|
+
card: {
|
|
41115
|
+
// The baked index is keyed by oracleId; Spellbook's numeric card id is
|
|
41116
|
+
// display-irrelevant, and `ComboRow` keys on oracleId.
|
|
41117
|
+
id: 0,
|
|
41118
|
+
name: u.n ?? known?.name ?? "Unknown card",
|
|
41119
|
+
oracleId: u.o,
|
|
41120
|
+
typeLine: known?.typeLine ?? "",
|
|
41121
|
+
imageUriFrontNormal: known?.image ?? null,
|
|
41122
|
+
// The catalog carries one front image; Spellbook distinguishes normal
|
|
41123
|
+
// from small, and `ComboRow` falls back from one to the other, so the
|
|
41124
|
+
// same URL in both keeps that fallback a no-op rather than a hole.
|
|
41125
|
+
imageUriFrontSmall: known?.image ?? null,
|
|
41126
|
+
imageUriFrontArtCrop: null,
|
|
41127
|
+
imageUriBackNormal: known?.backImage ?? null
|
|
41128
|
+
},
|
|
41129
|
+
quantity: 1,
|
|
41130
|
+
zoneLocations: u.z ?? ["B"],
|
|
41131
|
+
...u.c ? { mustBeCommander: true } : {}
|
|
41132
|
+
};
|
|
41133
|
+
});
|
|
41134
|
+
const d = detail?.[v.i];
|
|
41135
|
+
return {
|
|
41136
|
+
id: v.i,
|
|
41137
|
+
uses,
|
|
41138
|
+
produces: v.p.map((idx) => ({
|
|
41139
|
+
feature: { id: idx, name: index.features[idx] ?? "Combo effect" },
|
|
41140
|
+
quantity: 1
|
|
41141
|
+
})),
|
|
41142
|
+
identity: v.d,
|
|
41143
|
+
status: "OK",
|
|
41144
|
+
description: d?.x ?? "",
|
|
41145
|
+
...d?.s ? { notes: d.s } : {},
|
|
41146
|
+
prices: v.c != null ? { tcgplayer: String(v.c) } : {},
|
|
41147
|
+
popularity: v.n,
|
|
41148
|
+
...v.b ? { bracketTag: v.b } : {},
|
|
41149
|
+
manaNeeded: d?.m ?? "",
|
|
41150
|
+
legalities: { commander: true },
|
|
41151
|
+
...v.r ? {
|
|
41152
|
+
requires: v.r.map((r) => ({
|
|
41153
|
+
quantity: 1,
|
|
41154
|
+
template: { id: r.t, name: templateName(r.t) },
|
|
41155
|
+
zoneLocations: r.z ?? ["B"]
|
|
41156
|
+
}))
|
|
41157
|
+
} : {}
|
|
41158
|
+
};
|
|
41159
|
+
}
|
|
41160
|
+
function templateName(id) {
|
|
41161
|
+
return `Flexible piece #${id}`;
|
|
41162
|
+
}
|
|
41163
|
+
function hasOutstandingTemplate(v) {
|
|
41164
|
+
return (v.r?.length ?? 0) > 0;
|
|
41165
|
+
}
|
|
41166
|
+
function identityCovers(variantIdentity, identity) {
|
|
41167
|
+
for (let i = 0; i < variantIdentity.length; i++) {
|
|
41168
|
+
const ch = variantIdentity[i];
|
|
41169
|
+
if (ch === "C") continue;
|
|
41170
|
+
if (!identity.has(ch)) return false;
|
|
41171
|
+
}
|
|
41172
|
+
return true;
|
|
41173
|
+
}
|
|
41174
|
+
function matchCombos(index, input2) {
|
|
41175
|
+
const { ownedOracleIds: owned, identity, commanderOracleIds } = input2;
|
|
41176
|
+
const included = [];
|
|
41177
|
+
const almostIncluded = [];
|
|
41178
|
+
const addColors = [];
|
|
41179
|
+
const changeCommanders = [];
|
|
41180
|
+
for (let k = 0; k < index.variants.length; k++) {
|
|
41181
|
+
const v = index.variants[k];
|
|
41182
|
+
const uses = v.u;
|
|
41183
|
+
let missing = 0;
|
|
41184
|
+
let commanderGap = false;
|
|
41185
|
+
for (let j = 0; j < uses.length; j++) {
|
|
41186
|
+
const u = uses[j];
|
|
41187
|
+
if (!owned.has(u.o)) missing++;
|
|
41188
|
+
if (u.c && commanderOracleIds && !commanderOracleIds.has(u.o)) commanderGap = true;
|
|
41189
|
+
if (missing > 1) break;
|
|
41190
|
+
}
|
|
41191
|
+
if (missing > 1) continue;
|
|
41192
|
+
if (!identityCovers(v.d, identity)) {
|
|
41193
|
+
addColors.push(v);
|
|
41194
|
+
continue;
|
|
41195
|
+
}
|
|
41196
|
+
if (commanderGap) {
|
|
41197
|
+
changeCommanders.push(v);
|
|
41198
|
+
continue;
|
|
41199
|
+
}
|
|
41200
|
+
if (missing === 1) {
|
|
41201
|
+
if (hasOutstandingTemplate(v)) continue;
|
|
41202
|
+
almostIncluded.push(v);
|
|
41203
|
+
continue;
|
|
41204
|
+
}
|
|
41205
|
+
if (hasOutstandingTemplate(v)) {
|
|
41206
|
+
almostIncluded.push(v);
|
|
41207
|
+
continue;
|
|
41208
|
+
}
|
|
41209
|
+
included.push(v);
|
|
41210
|
+
}
|
|
41211
|
+
return {
|
|
41212
|
+
included,
|
|
41213
|
+
almostIncluded,
|
|
41214
|
+
almostIncludedByAddingColors: addColors,
|
|
41215
|
+
almostIncludedByChangingCommanders: changeCommanders,
|
|
41216
|
+
identity: [...identity].join("")
|
|
41217
|
+
};
|
|
41218
|
+
}
|
|
41219
|
+
function toApiShape(match, index, cardOf, detail) {
|
|
41220
|
+
const ex = (list) => list.map((v) => expandVariant(v, index, cardOf, detail));
|
|
41221
|
+
return {
|
|
41222
|
+
identity: match.identity,
|
|
41223
|
+
included: ex(match.included),
|
|
41224
|
+
almostIncluded: ex(match.almostIncluded),
|
|
41225
|
+
almostIncludedByAddingColors: ex(match.almostIncludedByAddingColors),
|
|
41226
|
+
almostIncludedByChangingCommanders: ex(match.almostIncludedByChangingCommanders)
|
|
41227
|
+
};
|
|
41228
|
+
}
|
|
41229
|
+
|
|
41230
|
+
// ../src/lib/combos/comboScope.ts
|
|
41231
|
+
function buildCardComboResults(index, oracleId, deckOracleIds, cardOf, detail) {
|
|
41232
|
+
const included = [];
|
|
41233
|
+
const almostIncluded = [];
|
|
41234
|
+
for (const v of index.variants) {
|
|
41235
|
+
if (!v.u.some((u) => u.o === oracleId)) continue;
|
|
41236
|
+
if (v.u.every((u) => deckOracleIds.has(u.o))) included.push(v);
|
|
41237
|
+
else almostIncluded.push(v);
|
|
41238
|
+
}
|
|
41239
|
+
const match = {
|
|
41240
|
+
included,
|
|
41241
|
+
almostIncluded,
|
|
41242
|
+
almostIncludedByAddingColors: [],
|
|
41243
|
+
almostIncludedByChangingCommanders: [],
|
|
41244
|
+
identity: ""
|
|
41245
|
+
};
|
|
41246
|
+
return toApiShape(match, index, cardOf, detail);
|
|
41247
|
+
}
|
|
41248
|
+
|
|
41249
|
+
// src/tools/registry.ts
|
|
41250
|
+
init_slug();
|
|
41251
|
+
|
|
41252
|
+
// ../src/lib/printingTrend.ts
|
|
41253
|
+
var SLOT2 = { "7d": 0, "30d": 2, "1d": 4 };
|
|
41254
|
+
function printingTrendWindows(file3, set2, collectorNumber, foil, priceNow) {
|
|
41255
|
+
const out = {};
|
|
41256
|
+
if (!file3 || !set2 || !collectorNumber) return out;
|
|
41257
|
+
const slots = file3.s[set2.toLowerCase()]?.[collectorNumber];
|
|
41258
|
+
for (const w of ["1d", "7d", "30d"]) {
|
|
41259
|
+
const at = file3.trend[w];
|
|
41260
|
+
if (!at) continue;
|
|
41261
|
+
const delta = slots?.[SLOT2[w] + (foil ? 1 : 0)] ?? 0;
|
|
41262
|
+
const then = priceNow != null ? priceNow - delta : void 0;
|
|
41263
|
+
out[w] = { delta, pct: then && then > 0 ? delta / then : 0, asOf: at };
|
|
41264
|
+
}
|
|
41265
|
+
return out;
|
|
41266
|
+
}
|
|
41267
|
+
|
|
40700
41268
|
// ../src/lib/edhrec/bracket-signals.ts
|
|
40701
41269
|
init_slug();
|
|
40702
41270
|
var MLD_NAMES = [
|
|
@@ -40903,127 +41471,6 @@ var MAX_CACHE_BYTES = 50 * 1024 * 1024;
|
|
|
40903
41471
|
init_build();
|
|
40904
41472
|
init_fetchWithTimeout();
|
|
40905
41473
|
|
|
40906
|
-
// ../src/lib/combos/comboIndex.ts
|
|
40907
|
-
function expandVariant(v, index, cardOf, detail) {
|
|
40908
|
-
const uses = v.u.map((u) => {
|
|
40909
|
-
const known = cardOf(u.o);
|
|
40910
|
-
return {
|
|
40911
|
-
card: {
|
|
40912
|
-
// The baked index is keyed by oracleId; Spellbook's numeric card id is
|
|
40913
|
-
// display-irrelevant, and `ComboRow` keys on oracleId.
|
|
40914
|
-
id: 0,
|
|
40915
|
-
name: u.n ?? known?.name ?? "Unknown card",
|
|
40916
|
-
oracleId: u.o,
|
|
40917
|
-
typeLine: known?.typeLine ?? "",
|
|
40918
|
-
imageUriFrontNormal: known?.image ?? null,
|
|
40919
|
-
// The catalog carries one front image; Spellbook distinguishes normal
|
|
40920
|
-
// from small, and `ComboRow` falls back from one to the other, so the
|
|
40921
|
-
// same URL in both keeps that fallback a no-op rather than a hole.
|
|
40922
|
-
imageUriFrontSmall: known?.image ?? null,
|
|
40923
|
-
imageUriFrontArtCrop: null,
|
|
40924
|
-
imageUriBackNormal: known?.backImage ?? null
|
|
40925
|
-
},
|
|
40926
|
-
quantity: 1,
|
|
40927
|
-
zoneLocations: u.z ?? ["B"],
|
|
40928
|
-
...u.c ? { mustBeCommander: true } : {}
|
|
40929
|
-
};
|
|
40930
|
-
});
|
|
40931
|
-
const d = detail?.[v.i];
|
|
40932
|
-
return {
|
|
40933
|
-
id: v.i,
|
|
40934
|
-
uses,
|
|
40935
|
-
produces: v.p.map((idx) => ({
|
|
40936
|
-
feature: { id: idx, name: index.features[idx] ?? "Combo effect" },
|
|
40937
|
-
quantity: 1
|
|
40938
|
-
})),
|
|
40939
|
-
identity: v.d,
|
|
40940
|
-
status: "OK",
|
|
40941
|
-
description: d?.x ?? "",
|
|
40942
|
-
...d?.s ? { notes: d.s } : {},
|
|
40943
|
-
prices: v.c != null ? { tcgplayer: String(v.c) } : {},
|
|
40944
|
-
popularity: v.n,
|
|
40945
|
-
...v.b ? { bracketTag: v.b } : {},
|
|
40946
|
-
manaNeeded: d?.m ?? "",
|
|
40947
|
-
legalities: { commander: true },
|
|
40948
|
-
...v.r ? {
|
|
40949
|
-
requires: v.r.map((r) => ({
|
|
40950
|
-
quantity: 1,
|
|
40951
|
-
template: { id: r.t, name: templateName(r.t) },
|
|
40952
|
-
zoneLocations: r.z ?? ["B"]
|
|
40953
|
-
}))
|
|
40954
|
-
} : {}
|
|
40955
|
-
};
|
|
40956
|
-
}
|
|
40957
|
-
function templateName(id) {
|
|
40958
|
-
return `Flexible piece #${id}`;
|
|
40959
|
-
}
|
|
40960
|
-
function hasOutstandingTemplate(v) {
|
|
40961
|
-
return (v.r?.length ?? 0) > 0;
|
|
40962
|
-
}
|
|
40963
|
-
function identityCovers(variantIdentity, identity) {
|
|
40964
|
-
for (let i = 0; i < variantIdentity.length; i++) {
|
|
40965
|
-
const ch = variantIdentity[i];
|
|
40966
|
-
if (ch === "C") continue;
|
|
40967
|
-
if (!identity.has(ch)) return false;
|
|
40968
|
-
}
|
|
40969
|
-
return true;
|
|
40970
|
-
}
|
|
40971
|
-
function matchCombos(index, input2) {
|
|
40972
|
-
const { ownedOracleIds: owned, identity, commanderOracleIds } = input2;
|
|
40973
|
-
const included = [];
|
|
40974
|
-
const almostIncluded = [];
|
|
40975
|
-
const addColors = [];
|
|
40976
|
-
const changeCommanders = [];
|
|
40977
|
-
for (let k = 0; k < index.variants.length; k++) {
|
|
40978
|
-
const v = index.variants[k];
|
|
40979
|
-
const uses = v.u;
|
|
40980
|
-
let missing = 0;
|
|
40981
|
-
let commanderGap = false;
|
|
40982
|
-
for (let j = 0; j < uses.length; j++) {
|
|
40983
|
-
const u = uses[j];
|
|
40984
|
-
if (!owned.has(u.o)) missing++;
|
|
40985
|
-
if (u.c && commanderOracleIds && !commanderOracleIds.has(u.o)) commanderGap = true;
|
|
40986
|
-
if (missing > 1) break;
|
|
40987
|
-
}
|
|
40988
|
-
if (missing > 1) continue;
|
|
40989
|
-
if (!identityCovers(v.d, identity)) {
|
|
40990
|
-
addColors.push(v);
|
|
40991
|
-
continue;
|
|
40992
|
-
}
|
|
40993
|
-
if (commanderGap) {
|
|
40994
|
-
changeCommanders.push(v);
|
|
40995
|
-
continue;
|
|
40996
|
-
}
|
|
40997
|
-
if (missing === 1) {
|
|
40998
|
-
if (hasOutstandingTemplate(v)) continue;
|
|
40999
|
-
almostIncluded.push(v);
|
|
41000
|
-
continue;
|
|
41001
|
-
}
|
|
41002
|
-
if (hasOutstandingTemplate(v)) {
|
|
41003
|
-
almostIncluded.push(v);
|
|
41004
|
-
continue;
|
|
41005
|
-
}
|
|
41006
|
-
included.push(v);
|
|
41007
|
-
}
|
|
41008
|
-
return {
|
|
41009
|
-
included,
|
|
41010
|
-
almostIncluded,
|
|
41011
|
-
almostIncludedByAddingColors: addColors,
|
|
41012
|
-
almostIncludedByChangingCommanders: changeCommanders,
|
|
41013
|
-
identity: [...identity].join("")
|
|
41014
|
-
};
|
|
41015
|
-
}
|
|
41016
|
-
function toApiShape(match, index, cardOf, detail) {
|
|
41017
|
-
const ex = (list) => list.map((v) => expandVariant(v, index, cardOf, detail));
|
|
41018
|
-
return {
|
|
41019
|
-
identity: match.identity,
|
|
41020
|
-
included: ex(match.included),
|
|
41021
|
-
almostIncluded: ex(match.almostIncluded),
|
|
41022
|
-
almostIncludedByAddingColors: ex(match.almostIncludedByAddingColors),
|
|
41023
|
-
almostIncludedByChangingCommanders: ex(match.almostIncludedByChangingCommanders)
|
|
41024
|
-
};
|
|
41025
|
-
}
|
|
41026
|
-
|
|
41027
41474
|
// ../src/lib/combos/resolveCombos.ts
|
|
41028
41475
|
function poolIdentity(oracleIds, cards) {
|
|
41029
41476
|
const identity = /* @__PURE__ */ new Set();
|
|
@@ -41370,8 +41817,8 @@ function readDraws(text) {
|
|
|
41370
41817
|
continue;
|
|
41371
41818
|
else if (!draws && iffy(line)) continue;
|
|
41372
41819
|
else if (!draws) {
|
|
41373
|
-
const
|
|
41374
|
-
draws = count2(line) * (
|
|
41820
|
+
const same2 = text.match(/\bchoose (two|three|four)\. you may choose the same mode more than once/);
|
|
41821
|
+
draws = count2(line) * (same2 && /^\s*[•·]/.test(raw) ? DRAW_WORD[same2[1]] : 1);
|
|
41375
41822
|
if (!draws && /\breveal the top card of your library\. if it's a land card, put it onto the battlefield\. otherwise, put (?:that card|it) into your hand\b/.test(line)) draws = 1;
|
|
41376
41823
|
}
|
|
41377
41824
|
}
|
|
@@ -41433,7 +41880,7 @@ function readUntapsAndReduces(text) {
|
|
|
41433
41880
|
const COLOR = { white: "w", blue: "u", black: "b", red: "r", green: "g" };
|
|
41434
41881
|
const NOT_A_TYPE = /* @__PURE__ */ new Set(["the", "other", "each", "your", "all", "that", "of", "and", "or", "spells"]);
|
|
41435
41882
|
const one = (w) => w === "noncreature" ? "-t:creature" : COLOR[w] ? `c:${COLOR[w]}` : w && !NOT_A_TYPE.has(w) ? `t:${w}` : "";
|
|
41436
|
-
const parts = words.split(/ (?:and|or) /).map((
|
|
41883
|
+
const parts = words.split(/ (?:and|or) /).map((part2) => part2.split(/\s+/).map(one).filter(Boolean).join(" ")).filter(Boolean);
|
|
41437
41884
|
const finds = parts.length > 1 ? parts.join(" or ") : parts[0] ?? "";
|
|
41438
41885
|
const chosen = / of the chosen type /.test(m[0]) ? /\bchoose a creature type\b/.test(t) || /\bcreature\b/.test(words) ? "@subtype" : "@type" : "";
|
|
41439
41886
|
out.reduces = { amount: sign * Number(m[2]), finds: [finds, chosen].filter(Boolean).join(" ") };
|
|
@@ -41803,7 +42250,7 @@ function castTriggerOf(line) {
|
|
|
41803
42250
|
desc = desc.replace(/^your first\b\s*/, "");
|
|
41804
42251
|
} else desc = desc.replace(/^an?(?: |$)/, "");
|
|
41805
42252
|
if (NOT_A_KIND.test(desc)) return null;
|
|
41806
|
-
const parts = desc ? desc.split(/,? or |, /).map((
|
|
42253
|
+
const parts = desc ? desc.split(/,? or |, /).map((part2) => part2.split(/\s+/).map(kindWord)) : [];
|
|
41807
42254
|
if (parts.some((ws) => ws.some((w) => w === null))) return null;
|
|
41808
42255
|
let finds = parts.map((ws) => ws.join(" ")).join(" or ");
|
|
41809
42256
|
if (m[4]) finds = parts.length > 1 ? `(${finds}) mv>=${m[4]}` : `${finds} mv>=${m[4]}`.trim();
|
|
@@ -42010,8 +42457,8 @@ function readPaidDraw(self, planeswalker = false) {
|
|
|
42010
42457
|
let discard = 0;
|
|
42011
42458
|
let sacAnother = false;
|
|
42012
42459
|
let ok = true;
|
|
42013
|
-
for (const
|
|
42014
|
-
const p =
|
|
42460
|
+
for (const part2 of l.slice(0, at).split(/,\s*/)) {
|
|
42461
|
+
const p = part2.trim();
|
|
42015
42462
|
if (p === "{t}") tap = true;
|
|
42016
42463
|
else if (loyalty && /^\+?\d+$/.test(p)) tap = true;
|
|
42017
42464
|
else if (/^(?:\{[0-9wubrgc/]+\})+$/.test(p)) {
|
|
@@ -42061,6 +42508,12 @@ function readCastTriggers(text) {
|
|
|
42061
42508
|
const out = text.split("\n").flatMap((l) => castTriggerOf(l.trim())?.trigger ?? []);
|
|
42062
42509
|
return out.length ? { castTriggers: out } : {};
|
|
42063
42510
|
}
|
|
42511
|
+
function withoutCastTriggers(text) {
|
|
42512
|
+
return text.split("\n").flatMap((l) => {
|
|
42513
|
+
const r = castTriggerOf(l.trim());
|
|
42514
|
+
return !r ? [l] : r.rest ? [r.rest] : [];
|
|
42515
|
+
}).join("\n");
|
|
42516
|
+
}
|
|
42064
42517
|
var LIFE_DRAWS_BUDGET = 30;
|
|
42065
42518
|
var LIFE_FILL = /(?:^|\n)pay 1 life: exile the top card of your library face down\. put that card into your hand at the beginning of your next end step\./;
|
|
42066
42519
|
function withLifeDraws(deck, profiles) {
|
|
@@ -42187,9 +42640,9 @@ function readExtraMana2(text) {
|
|
|
42187
42640
|
const boost = text.match(/(?:^|\n)whenever you tap an? (creature|nonland permanent|artifact|land) for mana, add (an additional [^.\n]*|one mana of any type that (?:permanent|creature|artifact|land) produced)/);
|
|
42188
42641
|
if (boost) {
|
|
42189
42642
|
const per = boost[1] === "nonland permanent" ? "nonland" : boost[1];
|
|
42190
|
-
const
|
|
42191
|
-
const u =
|
|
42192
|
-
if (
|
|
42643
|
+
const same2 = /^one mana of any type that/.test(boost[2]);
|
|
42644
|
+
const u = same2 ? [] : addedUnits(boost[2].replace(/^an additional /, ""));
|
|
42645
|
+
if (same2 || u.length) out.boost = { per, adds: same2 ? null : u };
|
|
42193
42646
|
}
|
|
42194
42647
|
const landfall = text.match(/(?:^|\n)(?:landfall — )?whenever a land (?:you control )?enters(?: the battlefield)?(?: under your control)?, add ([^.\n]*)/);
|
|
42195
42648
|
if (landfall) {
|
|
@@ -42445,8 +42898,8 @@ function readProfile(card, oracleText) {
|
|
|
42445
42898
|
}
|
|
42446
42899
|
if (!p0.land && (p0.draws ?? 0) > 0 && /(?:^|\n)(?:each player discards their hand|discard your hand), then (?:each player )?draws? seven cards\./.test(text)) p0 = { ...p0, wheel: true };
|
|
42447
42900
|
if (!p0.land && (p0.draws ?? 0) > 0 && /(?:^|\n)each player shuffles their hand and graveyard into their library, then draws seven cards\./.test(text)) p0 = { ...p0, wheel: "shuffle" };
|
|
42448
|
-
const
|
|
42449
|
-
if (
|
|
42901
|
+
const same2 = !p0.land ? text.match(/(?:^|\n)(?:discard (?:all the cards in your hand|your hand)|each player discards (?:all the cards in their hand|their hand)), then (?:each player )?draws? (?:that many cards|cards equal to the greatest number of cards a player discarded this way)(?: (plus|minus) one)?\./) : null;
|
|
42902
|
+
if (same2) p0 = { ...p0, wheel: "same", ...same2[1] ? { wheelPlus: same2[1] === "plus" ? 1 : -1 } : {} };
|
|
42450
42903
|
if (!p0.land && /(?:^|\n)return to your hand all cards in your graveyard that you (?:cycled or )?discarded this turn\./.test(text)) p0 = { ...p0, returnsDiscarded: true };
|
|
42451
42904
|
const tapT = text.match(/(?:^|\n)whenever (?:a|an) ([a-z]+) you control becomes tapped, create a treasure token\./);
|
|
42452
42905
|
if (tapT) p0 = { ...p0, tapTreasure: { type: tapT[1] === "creature" ? null : tapT[1] } };
|
|
@@ -45379,6 +45832,33 @@ function describeAlt(a) {
|
|
|
45379
45832
|
if (a.mv) tail.push(`with mana value ${a.mv.value}${a.mv.mode === "lte" ? " or less" : a.mv.mode === "gte" ? " or more" : ""}`);
|
|
45380
45833
|
return [...head, groups.join(" or "), ...tail].filter(Boolean).join(" ");
|
|
45381
45834
|
}
|
|
45835
|
+
function altQuery(a) {
|
|
45836
|
+
const parts = [];
|
|
45837
|
+
const word = (w) => w === "permanent" ? "is:permanent" : w === "historic" ? "is:historic" : `t:${w}`;
|
|
45838
|
+
if (a.types) {
|
|
45839
|
+
const gs = a.types.map((g) => g.map(word).join(" "));
|
|
45840
|
+
parts.push(gs.length === 1 ? gs[0] : `(${gs.map((g) => g.includes(" ") ? `(${g})` : g).join(" or ")})`);
|
|
45841
|
+
}
|
|
45842
|
+
for (const n of a.not ?? []) parts.push(`-t:${n}`);
|
|
45843
|
+
if (a.colors) parts.push(a.colors.length === 1 ? `c:${a.colors[0].toLowerCase()}` : `(${a.colors.map((c) => `c:${c.toLowerCase()}`).join(" or ")})`);
|
|
45844
|
+
if (a.colorCount) parts.push(a.colorCount === "none" ? "c:c" : a.colorCount === "multi" ? "c:m" : "c=1");
|
|
45845
|
+
if (a.keywords) parts.push(a.keywords.length === 1 ? `kw:${a.keywords[0]}` : `(${a.keywords.map((k) => `kw:${k}`).join(" or ")})`);
|
|
45846
|
+
if (a.manaAbility) parts.push("(produces:w or produces:u or produces:b or produces:r or produces:g or produces:c)");
|
|
45847
|
+
if (a.manaCost) {
|
|
45848
|
+
const generic = a.manaCost.every((c) => /^\{\d+\}$/.test(c));
|
|
45849
|
+
if (generic) parts.push(`c:c mv<=${Math.max(...a.manaCost.map((c) => Number(c.slice(1, -1))))}`);
|
|
45850
|
+
}
|
|
45851
|
+
if (a.basicLandType) parts.push(`(${BASIC_TYPES2.map((b) => `t:${b}`).join(" or ")})`);
|
|
45852
|
+
if (a.sharesColorWithLegendary) parts.push("-c:c");
|
|
45853
|
+
if (a.mv) parts.push(`mv${a.mv.mode === "lte" ? "<=" : a.mv.mode === "gte" ? ">=" : "="}${a.mv.value}`);
|
|
45854
|
+
return parts.join(" ");
|
|
45855
|
+
}
|
|
45856
|
+
function altsQuery(alts) {
|
|
45857
|
+
const qs = alts.map(altQuery);
|
|
45858
|
+
if (qs.some((q) => q === "")) return "";
|
|
45859
|
+
if (qs.length === 1) return qs[0];
|
|
45860
|
+
return qs.map((q) => /\s/.test(q) && !/^\(.*\)$/.test(q) ? `(${q})` : q).join(" or ");
|
|
45861
|
+
}
|
|
45382
45862
|
|
|
45383
45863
|
// ../src/lib/deckPlan/tutorFetch.ts
|
|
45384
45864
|
function printedMvGate(oracleId) {
|
|
@@ -45663,6 +46143,110 @@ function classifyDeckTutors(index, target, candidates) {
|
|
|
45663
46143
|
}
|
|
45664
46144
|
return { targetWord: word, counted, review, excluded };
|
|
45665
46145
|
}
|
|
46146
|
+
var CHECKABILITY_PROBE = {
|
|
46147
|
+
words: /* @__PURE__ */ new Set(["creature", "land", "artifact", "enchantment", "aura"]),
|
|
46148
|
+
cmc: 0,
|
|
46149
|
+
colors: [],
|
|
46150
|
+
keywords: []
|
|
46151
|
+
};
|
|
46152
|
+
function isFetchTutor(index, oracleId) {
|
|
46153
|
+
const sets = reachSets(index);
|
|
46154
|
+
const tags = index.tagIndicesByOid.get(oracleId);
|
|
46155
|
+
if (!isLibraryTutor(sets, tags)) return false;
|
|
46156
|
+
return sets.fromOpponent === void 0 || !tags.includes(sets.fromOpponent);
|
|
46157
|
+
}
|
|
46158
|
+
function buildTutorReach(index, tutor) {
|
|
46159
|
+
if (!isFetchTutor(index, tutor.oracleId)) return null;
|
|
46160
|
+
const sets = reachSets(index);
|
|
46161
|
+
const tags = index.tagIndicesByOid.get(tutor.oracleId);
|
|
46162
|
+
const reachSlugs = tags.filter((t) => sets.tutorRoot.has(t) && !sets.skip.has(t)).map((t) => index.slugs[t]);
|
|
46163
|
+
const gated = tags.some((t) => sets.mvSet.has(t));
|
|
46164
|
+
const text = textEntry(tutor.oracleId);
|
|
46165
|
+
let mvLimit = null;
|
|
46166
|
+
if (gated) {
|
|
46167
|
+
const mv = mvInfoFor(tutor);
|
|
46168
|
+
mvLimit = mv.kind !== "manual" ? { kind: mv.kind, pred: mv.seed } : { kind: /\{X\}/.test(tutor.manaCost ?? "") ? "x" : "dynamic" };
|
|
46169
|
+
}
|
|
46170
|
+
const readable = mvLimit === null || mvLimit.kind === "x" || mvLimit.kind === "dynamic";
|
|
46171
|
+
return {
|
|
46172
|
+
reachSlugs,
|
|
46173
|
+
...text && "a" in text ? { textQuery: altsQuery(text.a) } : {},
|
|
46174
|
+
anyCard: !gated && (text ? "a" in text && altsQuery(text.a) === "" : reachSlugs.includes("tutor-card")),
|
|
46175
|
+
// A transmute / printed limit is a readable reach on its own ("any card with
|
|
46176
|
+
// mana value 1 or less"), even with no type tag beside it. Words the bake
|
|
46177
|
+
// read as a review ("a card with the same name as …") can't be told.
|
|
46178
|
+
cantTell: text ? "r" in text : readable && reachSlugs.every((s) => slugReach(s, CHECKABILITY_PROBE) === "unknown"),
|
|
46179
|
+
mvLimit,
|
|
46180
|
+
fetches: (card) => {
|
|
46181
|
+
const v = tutorVerdict(index, sets, tags, tutor, parseTarget(card), card.cmc);
|
|
46182
|
+
if (v.status === "counted") return "yes";
|
|
46183
|
+
return v.status === "review" && v.mv ? "guess" : "no";
|
|
46184
|
+
}
|
|
46185
|
+
};
|
|
46186
|
+
}
|
|
46187
|
+
function slugQuery(slug) {
|
|
46188
|
+
const fixed = {
|
|
46189
|
+
"tutor-card": "",
|
|
46190
|
+
"tutor-land": "t:land",
|
|
46191
|
+
"tutor-land-any": "t:land",
|
|
46192
|
+
"tutor-permanent": "is:permanent",
|
|
46193
|
+
"tutor-nonland": "-t:land",
|
|
46194
|
+
"tutor-noncreature": "-t:creature",
|
|
46195
|
+
"tutor-legendary": "t:legendary",
|
|
46196
|
+
"tutor-artifact-creature": "t:artifact t:creature",
|
|
46197
|
+
"tutor-artifact-noncreature": "t:artifact -t:creature",
|
|
46198
|
+
"tutor-artifact-land": "t:artifact t:land",
|
|
46199
|
+
"tutor-artifact-colored": "t:artifact -c:c",
|
|
46200
|
+
"tutor-permanent-snow": "is:permanent t:snow",
|
|
46201
|
+
"tutor-land-basic": "t:basic t:land",
|
|
46202
|
+
"take-the-initiative": "t:basic t:land",
|
|
46203
|
+
"repeatable-landers": "t:basic t:land",
|
|
46204
|
+
"tutor-creature-colorless": "t:creature c:c",
|
|
46205
|
+
"tutor-creature-green": "t:creature c:g",
|
|
46206
|
+
"tutor-white": "c:w",
|
|
46207
|
+
"tutor-blue": "c:u",
|
|
46208
|
+
"tutor-black": "c:b",
|
|
46209
|
+
"tutor-red": "c:r",
|
|
46210
|
+
"tutor-green": "c:g",
|
|
46211
|
+
"tutor-monocolored": "c=1",
|
|
46212
|
+
"tutor-multicolored": "c:m",
|
|
46213
|
+
"tutor-flash": "kw:flash",
|
|
46214
|
+
"tutor-flashback": "kw:flashback",
|
|
46215
|
+
"tutor-augment": "kw:augment",
|
|
46216
|
+
"tutor-host": "t:host"
|
|
46217
|
+
};
|
|
46218
|
+
if (slug in fixed) return fixed[slug];
|
|
46219
|
+
const typeTag = /^tutor-(creature|land|artifact|enchantment|planeswalker|instant|sorcery|battle)$/.exec(slug);
|
|
46220
|
+
if (typeTag) return `t:${typeTag[1]}`;
|
|
46221
|
+
const basicSub = /^tutor-land-basic-([a-z]+)$/.exec(slug);
|
|
46222
|
+
if (basicSub) return `t:basic t:${basicSub[1]}`;
|
|
46223
|
+
const spell = /^tutor-instant-sorcery-([a-z]+)$/.exec(slug);
|
|
46224
|
+
if (spell) return `(t:instant or t:sorcery) t:${spell[1]}`;
|
|
46225
|
+
const creatureKw = /^tutor-creature-(deathtouch|hexproof|reach|trample|flying)$/.exec(slug);
|
|
46226
|
+
if (creatureKw) return `t:creature kw:${creatureKw[1]}`;
|
|
46227
|
+
const sub = /^tutor-(creature|land|artifact|enchantment)-([a-z-]+)$/.exec(slug);
|
|
46228
|
+
if (sub) {
|
|
46229
|
+
if (sub[2] === "power" || sub[2] === "toughness") return `t:creature`;
|
|
46230
|
+
if (UNCHECKABLE_SUBTAGS.has(sub[2])) return null;
|
|
46231
|
+
return `t:${sub[1]} t:${sub[2]}`;
|
|
46232
|
+
}
|
|
46233
|
+
return null;
|
|
46234
|
+
}
|
|
46235
|
+
function tutorReachQuery(reach) {
|
|
46236
|
+
if (reach.cantTell) return null;
|
|
46237
|
+
if (reach.textQuery !== void 0) return withMvLimit(reach.textQuery, reach.mvLimit);
|
|
46238
|
+
const parts = (reach.reachSlugs ?? []).map(slugQuery).filter((q2) => q2 !== null);
|
|
46239
|
+
const anyCard = reach.anyCard || parts.includes("") || parts.length === 0;
|
|
46240
|
+
let q = anyCard ? "" : parts.length === 1 ? parts[0] : parts.map((x) => x.includes(" ") ? `(${x})` : x).join(" or ");
|
|
46241
|
+
if (!anyCard && parts.length > 1) q = `(${q})`;
|
|
46242
|
+
return withMvLimit(q, reach.mvLimit);
|
|
46243
|
+
}
|
|
46244
|
+
function withMvLimit(q, lim) {
|
|
46245
|
+
if (!lim || lim.kind !== "transmute" && lim.kind !== "printed") return q;
|
|
46246
|
+
const op = lim.pred.mode === "lte" ? "<=" : lim.pred.mode === "gte" ? ">=" : "=";
|
|
46247
|
+
const head = / or /.test(q) && !/^\(.*\)$/.test(q) ? `(${q})` : q;
|
|
46248
|
+
return `${head} mv${op}${lim.pred.value}`.trim();
|
|
46249
|
+
}
|
|
45666
46250
|
|
|
45667
46251
|
// ../src/lib/deckPlan/planWiring.ts
|
|
45668
46252
|
function planEngineProfiles({
|
|
@@ -45936,9 +46520,9 @@ function preparePlay(reqs, profiles) {
|
|
|
45936
46520
|
const partsOf = Array.from({ length: profiles.length }, () => []);
|
|
45937
46521
|
const optionsOf = reqs.map(
|
|
45938
46522
|
(r, k) => r.options?.length ? r.options.map(
|
|
45939
|
-
(o) => o.map((
|
|
45940
|
-
const f = parts.push({ k, part }) - 1;
|
|
45941
|
-
for (let i = 0; i < profiles.length; i++) if (
|
|
46523
|
+
(o) => o.map((part2) => {
|
|
46524
|
+
const f = parts.push({ k, part: part2 }) - 1;
|
|
46525
|
+
for (let i = 0; i < profiles.length; i++) if (part2.members[i]) partsOf[i].push(f);
|
|
45942
46526
|
return f;
|
|
45943
46527
|
})
|
|
45944
46528
|
) : null
|
|
@@ -46046,8 +46630,8 @@ function playGame(state, reqs, profiles, opts, prep = preparePlay(reqs, profiles
|
|
|
46046
46630
|
reqs.forEach((r, k) => {
|
|
46047
46631
|
if (r.count) goals.push({ k, kind: r.count, atLeast: r.atLeast, f: -1 });
|
|
46048
46632
|
});
|
|
46049
|
-
parts.forEach(({ k, part }, f) => {
|
|
46050
|
-
if (
|
|
46633
|
+
parts.forEach(({ k, part: part2 }, f) => {
|
|
46634
|
+
if (part2.count) goals.push({ k, kind: part2.count, atLeast: part2.atLeast, f });
|
|
46051
46635
|
});
|
|
46052
46636
|
const counting = goals.length > 0;
|
|
46053
46637
|
const handRow = goals.some((g) => g.kind === "hand");
|
|
@@ -47552,20 +48136,20 @@ function playGame(state, reqs, profiles, opts, prep = preparePlay(reqs, profiles
|
|
|
47552
48136
|
return to === "yours" ? castOnOwn(i) : tryCast(i, rituals);
|
|
47553
48137
|
};
|
|
47554
48138
|
const partCount = (f) => {
|
|
47555
|
-
const { k, part } = parts[f];
|
|
47556
|
-
if (
|
|
48139
|
+
const { k, part: part2 } = parts[f];
|
|
48140
|
+
if (part2.count) return countBest[partGoal[f]];
|
|
47557
48141
|
if (reqs[k].mode === "graveyard") {
|
|
47558
48142
|
let g = 0;
|
|
47559
|
-
for (const i of grave) if (
|
|
48143
|
+
for (const i of grave) if (part2.members[i]) g++;
|
|
47560
48144
|
return g;
|
|
47561
48145
|
}
|
|
47562
48146
|
const have2 = reqs[k].mode === "have";
|
|
47563
48147
|
let c = partCast[f];
|
|
47564
|
-
if (
|
|
47565
|
-
for (let z2 = 0; z2 < zoneCast.length; z2++) if (
|
|
48148
|
+
if (part2.commanders) {
|
|
48149
|
+
for (let z2 = 0; z2 < zoneCast.length; z2++) if (part2.commanders[z2] && (zoneCast[z2] || have2)) c++;
|
|
47566
48150
|
}
|
|
47567
48151
|
if (have2) {
|
|
47568
|
-
for (const i of hand) if (
|
|
48152
|
+
for (const i of hand) if (part2.members[i]) c++;
|
|
47569
48153
|
}
|
|
47570
48154
|
return c;
|
|
47571
48155
|
};
|
|
@@ -47594,8 +48178,8 @@ function playGame(state, reqs, profiles, opts, prep = preparePlay(reqs, profiles
|
|
|
47594
48178
|
let w = -1;
|
|
47595
48179
|
for (const o of optionsOf[k])
|
|
47596
48180
|
for (const f of o) {
|
|
47597
|
-
const { part } = parts[f];
|
|
47598
|
-
if (!(i < 0 ? !!
|
|
48181
|
+
const { part: part2 } = parts[f];
|
|
48182
|
+
if (!(i < 0 ? !!part2.commanders?.[-1 - i] : !!part2.members[i]) || partCount(f) >= part2.atLeast) continue;
|
|
47599
48183
|
if (best.has(o)) return 0;
|
|
47600
48184
|
w = 1;
|
|
47601
48185
|
}
|
|
@@ -49855,6 +50439,9 @@ function resolvePlanRow(row, rc) {
|
|
|
49855
50439
|
return { ...x, members: members2, zone: zone.some(Boolean) ? zone : void 0, options };
|
|
49856
50440
|
}
|
|
49857
50441
|
|
|
50442
|
+
// src/plan.ts
|
|
50443
|
+
init_countRows();
|
|
50444
|
+
|
|
49858
50445
|
// ../src/lib/ranking/rankCommanders.ts
|
|
49859
50446
|
init_slug();
|
|
49860
50447
|
|
|
@@ -50308,7 +50895,548 @@ function cumulative(counts, to, trials) {
|
|
|
50308
50895
|
return out;
|
|
50309
50896
|
}
|
|
50310
50897
|
|
|
50898
|
+
// ../src/lib/deckPlan/planAssumptions.ts
|
|
50899
|
+
var ASSUMPTION_LABEL = {
|
|
50900
|
+
tutorUnread: { title: "Tutors we can't read", hint: "We can't tell what these find. Edit one to say." },
|
|
50901
|
+
manaUnread: { title: "Mana we didn't read", hint: "Their text adds mana in a way we didn't catch. Set what they make." },
|
|
50902
|
+
landRamp: { title: "Land ramp, not counted", hint: "Spells that put lands onto the battlefield. Set what each adds (say {W/U/B/R/G}, next turn)." },
|
|
50903
|
+
untap: { title: "Untapping lands, not counted", hint: "Set the mana it frees up as a one-time burst (once)." },
|
|
50904
|
+
extraLand: { title: "Extra land drops we can't read", hint: "We play one land a turn for these (an activated one, a condition). Set its extra drops each turn, or once when cast." },
|
|
50905
|
+
reducer: { title: "Cost reducers we couldn't read", hint: "Set what they make cheaper and by how much." },
|
|
50906
|
+
needsTarget: {
|
|
50907
|
+
title: "Counterspells we never cast",
|
|
50908
|
+
hint: "Playing alone there's nothing to counter, so their draw or untap doesn't count. Set when you'd cast one: on an opponent's spell (their turn), or on one of your own."
|
|
50909
|
+
},
|
|
50910
|
+
tutorMissed: {
|
|
50911
|
+
title: "Tutors we don't count",
|
|
50912
|
+
hint: `Their text finds a card, but they aren't on our tutor list. Edit one and tick "count it as a tutor" (and say what it finds).`
|
|
50913
|
+
},
|
|
50914
|
+
tutorRepeat: {
|
|
50915
|
+
title: "Tutors that may search again",
|
|
50916
|
+
hint: "Their search is an ability, so it may repeat (or not: Wishclaw Talisman goes to an opponent). We count one search; edit one to say how many, and what each later one costs."
|
|
50917
|
+
},
|
|
50918
|
+
freeCast: {
|
|
50919
|
+
title: "Free casts we can't read",
|
|
50920
|
+
hint: "A copy, an exiled card, a card from the top or an opponent's. We count none; set one from your hand if that's close enough."
|
|
50921
|
+
},
|
|
50922
|
+
manaTokens: {
|
|
50923
|
+
title: "Treasure and the like we can't count",
|
|
50924
|
+
hint: "Their number depends on the board or on the other players. Set your guess: Treasure when cast, or about how many a round from which turn."
|
|
50925
|
+
},
|
|
50926
|
+
opponentMana: {
|
|
50927
|
+
title: "Mana that depends on opponents' lands",
|
|
50928
|
+
hint: "We assume any color. At your table it may not be."
|
|
50929
|
+
},
|
|
50930
|
+
phyrexian: {
|
|
50931
|
+
title: "Phyrexian mana, paid with life",
|
|
50932
|
+
hint: "Each {W/P} is paid with 2 life, so it costs no mana (you start at 40 and nothing here costs you life). Set the cost higher if you'd pay mana."
|
|
50933
|
+
},
|
|
50934
|
+
sourceVaries: {
|
|
50935
|
+
title: "Mana that grows with the board, read as one",
|
|
50936
|
+
hint: '"Add {G} for each Elf you control" and the like. Set about how much it makes a turn, from which turn.'
|
|
50937
|
+
},
|
|
50938
|
+
selfCost: {
|
|
50939
|
+
title: "Spells whose own cost depends on the board",
|
|
50940
|
+
hint: `"This spell costs {1} less for each creature", affinity, convoke, delve, improvise: we read its printed cost. Set what you'd pay.`
|
|
50941
|
+
},
|
|
50942
|
+
triggerDraw: {
|
|
50943
|
+
title: "Draws from triggers, not counted",
|
|
50944
|
+
hint: "When it dies, whenever a creature enters, when it enters if ...: not for sure in a goldfish. Set a number each turn if you'd count on it."
|
|
50945
|
+
},
|
|
50946
|
+
elsewhereCast: {
|
|
50947
|
+
title: "Casting from the graveyard or exile we don't read",
|
|
50948
|
+
hint: 'Foretell, suspend, dredge, unearth and the like (flashback, escape and harmonize are read). Edit one: "cast from your graveyard for" sets a cost, or set a draw on it.'
|
|
50949
|
+
},
|
|
50950
|
+
altUnread: {
|
|
50951
|
+
title: "Other ways to cast it we don't read",
|
|
50952
|
+
hint: `Evoke, dash, madness, morph, pitch spells like Force of Will, and the like. Add one under "another way to cast it" if you'd use it.`
|
|
50953
|
+
},
|
|
50954
|
+
drawVaries: {
|
|
50955
|
+
title: "Draws that depend on the board, not counted",
|
|
50956
|
+
hint: `"Draw cards equal to the greatest power", "draw X cards": set how many you'd expect.`
|
|
50957
|
+
},
|
|
50958
|
+
impulseDraw: {
|
|
50959
|
+
title: "Play from exile we don't read, not counted",
|
|
50960
|
+
hint: `An exile-and-play we couldn't read (a trigger, a condition, an opponent's cards). Edit one: "exiles your top" sets how many and for how long.`
|
|
50961
|
+
},
|
|
50962
|
+
tapUnknown: {
|
|
50963
|
+
title: "Lands that enter tapped unless something we can't check",
|
|
50964
|
+
hint: "A player's life, a planeswalker, a creature type. We read them untapped; edit one to say when it enters tapped."
|
|
50965
|
+
},
|
|
50966
|
+
landVaries: {
|
|
50967
|
+
title: "Lands whose mana we can't fully read",
|
|
50968
|
+
hint: "Their mana depends on the board, is restricted, or they cost you later. We count one mana a turn (City of Traitors two). Set about how much from which turn."
|
|
50969
|
+
},
|
|
50970
|
+
regrowth: {
|
|
50971
|
+
title: "Cards back from your graveyard to your hand we don't read",
|
|
50972
|
+
hint: 'Shadow of the Grave, a return on dying or on a trigger: not played. Edit one: "returns ... to your hand" sets what it gets back.'
|
|
50973
|
+
},
|
|
50974
|
+
graveUnread: {
|
|
50975
|
+
title: "Graveyard abilities we don't play",
|
|
50976
|
+
hint: "A mill you pay for, a card returning itself (Reassembling Skeleton), a mill or return on a trigger: not played. If one matters to your plan, set it in its card (mills you, returns ... to your hand) as what it does when cast."
|
|
50977
|
+
},
|
|
50978
|
+
explore: {
|
|
50979
|
+
title: "Explore, not counted",
|
|
50980
|
+
hint: "Exploring puts a land it reveals into your hand (or mills the card): we don't count it. Set a draw on it if you'd count on it."
|
|
50981
|
+
},
|
|
50982
|
+
treasureGuess: {
|
|
50983
|
+
title: "Treasure off other players, our guess",
|
|
50984
|
+
hint: "Smothering Tithe makes a Treasure whenever an opponent draws, unless they pay. We guess 1 a round per opponent (your opponents setting), as if nobody pays. Set your own in its card."
|
|
50985
|
+
},
|
|
50986
|
+
treasureTiming: {
|
|
50987
|
+
title: "Treasure that comes after several uses",
|
|
50988
|
+
hint: "Treasure Map's three Treasure come on its third use, then it transforms. We use it whenever there's mana to spare, so at your table they may come later."
|
|
50989
|
+
},
|
|
50990
|
+
drawGuess: {
|
|
50991
|
+
title: "Draws we guessed",
|
|
50992
|
+
hint: "Ad Nauseam draws as many as you'll pay life for. We guess 30 of your 40 life, at this deck's average mana value a card; Necropotence fills your hand to seven at each end step, a life a card, up to 30. Set your own in its card."
|
|
50993
|
+
},
|
|
50994
|
+
kicker: {
|
|
50995
|
+
title: "Optional extra costs, not paid",
|
|
50996
|
+
hint: "Kicker, multikicker, an optional waterbend: we cast it without, so what the extra cost adds isn't counted. Set what you'd get if you'd pay it."
|
|
50997
|
+
},
|
|
50998
|
+
prepared: {
|
|
50999
|
+
title: "Prepared and adventure spells, not cast",
|
|
51000
|
+
hint: "Studious First-Year's Rampant Growth, Emeritus of Woe's Demonic Tutor, Bonecrusher Giant's Stomp: the spell half isn't played, only the creature. In its card, set it to play as its spell to count the spell instead."
|
|
51001
|
+
},
|
|
51002
|
+
grantsMana: {
|
|
51003
|
+
title: "Mana it gives your other permanents, not counted",
|
|
51004
|
+
hint: "Chromatic Lantern's lands, Cryptolith Rite's creatures: we count each card's own mana, not what this one gives them. Set what this adds a turn (say one of any color) if you'd count on it."
|
|
51005
|
+
},
|
|
51006
|
+
extraTurn: {
|
|
51007
|
+
title: "Extra turns, not taken",
|
|
51008
|
+
hint: "Time Warp, Nexus of Fate: the extra turn's untap, draw and land drop aren't played. Set a draw on it if you'd count on the extra card."
|
|
51009
|
+
},
|
|
51010
|
+
copyUnread: {
|
|
51011
|
+
title: "Copies we don't play",
|
|
51012
|
+
hint: "Kiki-Jiki's and Helm of the Host's token copies, Mirage Mirror becoming a copy, Reverberate copying a ritual, a clone with a limit (Mockingbird): we don't count the copy. A clone of yours (Clone, Phyrexian Metamorph) is played. Set what the copy adds (say a dork's mana) if you'd count on it."
|
|
51013
|
+
},
|
|
51014
|
+
tokenDoubler: {
|
|
51015
|
+
title: "More Treasure than we count",
|
|
51016
|
+
hint: "Doubling Season, Anointed Procession, Mondrak, Xorn: your Treasure comes doubled or with one more, and we count each card's Treasure once. Set the Treasure on your Treasure cards if you'd count on the extra."
|
|
51017
|
+
},
|
|
51018
|
+
grantsUnread: {
|
|
51019
|
+
title: "Abilities it gives your other cards, not counted",
|
|
51020
|
+
hint: "Tectonic Reformation gives the lands in your hand cycling: we don't count what it gives. Set the cycling on those cards, or a draw on this one."
|
|
51021
|
+
},
|
|
51022
|
+
exilesFirst: {
|
|
51023
|
+
title: "Tutors that exile your top cards first, counted with the risk",
|
|
51024
|
+
hint: "Demonic Bargain exiles your top 13 before it searches, Demonic Consultation your top 6: the card you want can be among them. We play it as the card says: then it finds another of the row's cards, or nothing."
|
|
51025
|
+
},
|
|
51026
|
+
reanimate: {
|
|
51027
|
+
title: "Reanimation we don't read, not counted",
|
|
51028
|
+
hint: `Reanimate, Animate Dead and Sun Titan are played. These aren't: a return on dying (Persist), several at once (Victimize), or under a condition. Edit one: "returns ... to the battlefield" sets what it brings back.`
|
|
51029
|
+
},
|
|
51030
|
+
landRunsOut: {
|
|
51031
|
+
title: "Lands that run out, counted",
|
|
51032
|
+
hint: "Each taps for its real amount until its counters are gone, then it's sacrificed. We tap it every turn it's untapped; if you'd save one, set its uses."
|
|
51033
|
+
},
|
|
51034
|
+
trickCounted: {
|
|
51035
|
+
title: "Untaps, cost reducers and taxes we count",
|
|
51036
|
+
hint: "Worth a look: which spells a reducer or a tax hits (a tax on every player costs your spells more too), and that you control enough lands to untap."
|
|
51037
|
+
},
|
|
51038
|
+
selection: { title: "Card selection, not counted", hint: "Looking at cards and keeping some. Set how many it draws you." },
|
|
51039
|
+
activatedDraw: { title: "Draw from abilities, not counted", hint: 'Paid abilities that draw. Edit one: "pay ... to draw" sets what it costs and how often, or set a number each turn.' },
|
|
51040
|
+
opponentDraw: {
|
|
51041
|
+
title: "Draws off opponents, not counted unless you set it",
|
|
51042
|
+
hint: "Playing alone nobody else casts anything. Set your guess: about how many cards a round, from which turn."
|
|
51043
|
+
},
|
|
51044
|
+
drawCounted: { title: "Card draw we count", hint: "Worth a look: conditions on the draw aren't modeled." },
|
|
51045
|
+
hurtsYou: {
|
|
51046
|
+
title: "Locks and sweepers that hit you too, not played",
|
|
51047
|
+
hint: "They hold every player back, you included (one spell a turn, no searching, nonbasics as basics, rocks shut off, a discard), or wipe your own board too (your dorks and rocks). We play as if they don't touch you."
|
|
51048
|
+
}
|
|
51049
|
+
};
|
|
51050
|
+
var TOKEN_DOUBLER = /\bif (?:an effect would create one or more tokens|one or more tokens would be created)\b(?: under your control)?, [^.\n]*\b(?:twice|three times) that many\b|\bif you would create one or more treasure tokens, instead create those tokens plus (?:an additional|another) treasure token\b/;
|
|
51051
|
+
var TREASURE2 = /creates? (?:a|an|one|two|three|four|x|\w+) (?:tapped )?(?:[a-z]+(?: tokens?)?,? (?:or (?:an? )?)?){0,4}(?:treasure|gold|powerstone)/;
|
|
51052
|
+
var maskDrawConditions = (t) => t.replace(
|
|
51053
|
+
/\b(?:whenever|when|if you would)\b[^,.\n]*,/g,
|
|
51054
|
+
(m) => m.replace(/\bdraw(s?)\b/g, "dr_w$1").replace(/\b(?:an |each )?opponents? controls? (?=dies\b|(?:is|are) dealt\b)/g, "someone controls ")
|
|
51055
|
+
).replace(/\bdamage to (?:an |each |target |that )?(?:opponent|player)s?\b/g, "damage to someone").replace(/\byou and (?:an |each |target )?opponents? each\b/g, "you").replace(/\b(?:one or more of )?(?:your |an |each )?opponents? (?:is|are) dealt (?:combat )?damage\b/g, "someone is dealt damage");
|
|
51056
|
+
function reanimates(text, name) {
|
|
51057
|
+
if (/\bsearch your library\b/.test(text)) return false;
|
|
51058
|
+
const self = name.toLowerCase().split(" // ")[0];
|
|
51059
|
+
if (/\breturn enchanted creature card to the battlefield\b/.test(text)) return true;
|
|
51060
|
+
return text.split("\n").some(
|
|
51061
|
+
(line) => line.split(/(?<=\.)\s+/).some((s, k, all) => {
|
|
51062
|
+
if (!/\b(?:to|onto) the battlefield\b/.test(s)) return false;
|
|
51063
|
+
if (!/\b(?:return|put)s?\b/.test(s)) return false;
|
|
51064
|
+
const where = /\bgraveyards?\b/.test(s) ? s : all.slice(0, k).reverse().find((x) => /\bcards? in (?:your|a|any) graveyard\b/.test(x));
|
|
51065
|
+
if (!where) return false;
|
|
51066
|
+
const what = `${where} ${s}`;
|
|
51067
|
+
if (!/\bcards?\b/.test(what)) return false;
|
|
51068
|
+
if (/\b(?:return|put) (?:this card|this creature|it|~)\b/.test(s) || s.includes(`return ${self} `) || s.includes(`put ${self} `)) return false;
|
|
51069
|
+
const object3 = (what.match(/\b(?:return|put|choose)s? ((?:(?!\bcards?\b)[^.])*?)\bcards?\b/) ?? [])[1] ?? "";
|
|
51070
|
+
if (/\bland\b/.test(object3) && !/\b(?:creature|permanent|artifact|enchantment|nonland)\b/.test(object3)) return false;
|
|
51071
|
+
return true;
|
|
51072
|
+
})
|
|
51073
|
+
);
|
|
51074
|
+
}
|
|
51075
|
+
function planAssumptions(args) {
|
|
51076
|
+
const out = [];
|
|
51077
|
+
const seen = /* @__PURE__ */ new Set();
|
|
51078
|
+
const drawsOffOpponents = (t) => maskDrawConditions(t).split("\n").some((line) => {
|
|
51079
|
+
if (/^\s*whenever a player\b[^\n]*\byou draw\b/.test(line)) return true;
|
|
51080
|
+
if (/^\s*whenever a player\b[^\n]*\bthat player's opponents (?:may )?draw\b/.test(line)) return true;
|
|
51081
|
+
if (!ACTIVATED.test(line) && /\b(?:target|an|each) (?:opponent|player)\b/.test(line) && line.split(/(?<=\.)\s+/).some((s) => /^if (?:they|that player)\b[^.]*\b(?:don't|doesn't|didn't|can't|cannot)\b[^.]*\bdraws? (?:a|an|one|two|three|four|five|\d+) cards?\b/.test(s) && !/\b(?:they|that player) (?:may )?draws?\b/.test(s)))
|
|
51082
|
+
return true;
|
|
51083
|
+
if (!/\bopponents?\b/.test(line) || ACTIVATED.test(line)) return false;
|
|
51084
|
+
return line.split(/(?<=\.)\s+/).some((s) => {
|
|
51085
|
+
const mine = s.replace(/,? (?:and )?(?:an |each |target )?opponents? (?:may |each )?draws? (?:a|an|one|two|three|\d+) cards?\b/g, "").replace(/\b(?:that (?:attacking )?player|they) (?:may )?draws? (?:a|an|one|two|three|\d+) cards?\b/g, "");
|
|
51086
|
+
return /\bopponents?\b/.test(mine) && /\bdraws? (?:a|an|one|two|three|\d+) cards?\b/.test(mine);
|
|
51087
|
+
});
|
|
51088
|
+
});
|
|
51089
|
+
const makesTreasure = (c, p) => !!p && (!!p.treasures || !!p.treasuresPerRound?.length || !!p.treasuresPerOpponent || !!p.paidTreasure || !!p.combatTreasures || !!p.diesTreasures || !!p.diesDraw?.some((d) => d.treasures) || !!p.castTriggers?.some((x) => x.treasures)) || // (Not a doubler's own line: Xorn's "plus an additional treasure token"
|
|
51090
|
+
// makes none by itself.)
|
|
51091
|
+
TREASURE2.test(
|
|
51092
|
+
(args.text(c.oracleId) ?? "").toLowerCase().replace(/\([^)]*\)/g, "").split("\n").filter((l) => !TOKEN_DOUBLER.test(l)).join("\n")
|
|
51093
|
+
);
|
|
51094
|
+
const deckTreasure = args.deck.some((c, i) => makesTreasure(c, args.profiles[i])) || (args.commanders ?? []).some((c, z2) => makesTreasure(c, args.commanderProfiles?.[z2]));
|
|
51095
|
+
(args.commanders ?? []).forEach((c, z2) => {
|
|
51096
|
+
const p = args.commanderProfiles?.[z2];
|
|
51097
|
+
if (p) return flagCard(c, p);
|
|
51098
|
+
if (seen.has(c.oracleId) || args.yours(c.oracleId)) return;
|
|
51099
|
+
seen.add(c.oracleId);
|
|
51100
|
+
const t = (args.text(c.oracleId) ?? "").toLowerCase().replace(/\([^)]*\)/g, "");
|
|
51101
|
+
if (drawsOffOpponents(t)) out.push({ kind: "opponentDraw", oracleId: c.oracleId, name: c.name });
|
|
51102
|
+
});
|
|
51103
|
+
args.deck.forEach((c, i) => flagCard(c, args.profiles[i]));
|
|
51104
|
+
function flagCard(c, p) {
|
|
51105
|
+
if (seen.has(c.oracleId)) return;
|
|
51106
|
+
seen.add(c.oracleId);
|
|
51107
|
+
if (!p) return;
|
|
51108
|
+
const kinds = /* @__PURE__ */ new Set();
|
|
51109
|
+
let side = false;
|
|
51110
|
+
const add = (kind) => {
|
|
51111
|
+
if (kinds.has(kind) || side && NOT_READINGS.has(kind)) return;
|
|
51112
|
+
kinds.add(kind);
|
|
51113
|
+
out.push({ kind, oracleId: c.oracleId, name: c.name });
|
|
51114
|
+
};
|
|
51115
|
+
if (args.yours(c.oracleId)) return;
|
|
51116
|
+
const text = (args.text(c.oracleId) ?? "").toLowerCase();
|
|
51117
|
+
const faces = p.prepared ? preparedFaces(c.name, text) : null;
|
|
51118
|
+
if (p.prepared || /\bbecomes? prepared\b/.test(text) || !!p.spellSide && !p.land) add("prepared");
|
|
51119
|
+
check2(p, faces?.creature ?? text);
|
|
51120
|
+
if (p.spellSide && (p.land || faces)) {
|
|
51121
|
+
side = true;
|
|
51122
|
+
check2(p.spellSide, faces?.spell ?? spellFaceText(text));
|
|
51123
|
+
}
|
|
51124
|
+
function check2(p2, rawText) {
|
|
51125
|
+
const raw = rawText;
|
|
51126
|
+
const t = raw.replace(/\([^)]*\)/g, "");
|
|
51127
|
+
const unread = (p2.castTriggers ? withoutCastTriggers(t) : t).split("\n").filter((l) => !(p2.diesDraw && diesDrawsOf(selfRef(c.name, l))) && !(p2.sacDraw && SAC_DRAW.test(selfRef(c.name, l).trim())) && !(p2.enterDraw && enterDrawOf(l)) && !(p2.paidDraw?.sacSelf && LEAVES_DRAW.test(selfRef(c.name, l).trim())) && !(p2.paidDraw?.sacCreature && /^\s*whenever equipped creature dies, (?:you )?draw\b/.test(l))).join("\n");
|
|
51128
|
+
const sides = raw.split(/\n\(transforms from [^)]*\)/);
|
|
51129
|
+
const front = sides[0].replace(/\([^)]*\)/g, "");
|
|
51130
|
+
const backTreasure = sides.length > 1 && TREASURE2.test(sides.slice(1).join("\n"));
|
|
51131
|
+
const abilityDraw = t.replace(/\n(?=\s*(?:[•·]|\+ ))/g, " ").split("\n").flatMap((l) => [l, ...(l.match(/"[^"]*"/g) ?? []).map((q) => q.slice(1, -1))]).some((l) => ACTIVATED.test(l) && /:[^\n]*(?:\bdraws? (?:a|one|two|three|four|five|six|seven|\d+|x|that many) cards?|\bdraws? cards equal to\b|\btop card of your library\b[^\n]*\binto your hand|\bput (?:one|two|a card) of (?:them|those cards) into your hand|\bconnives?\b)/.test(l.replace(/"[^"]*"/g, "")) || // A Class's level is bought (Wizard Class: "when this class becomes level 2, draw two").
|
|
51132
|
+
/^\s*when this class becomes level \d+, [^\n]*\bdraws?\b/.test(l));
|
|
51133
|
+
const theirLands = /a land an opponent controls could produce/.test(t);
|
|
51134
|
+
const scryUnread = !p2.scry && /\b(?:scry|scries|surveils?) (?:\d+|x)\b/.test(raw);
|
|
51135
|
+
if (p2.land) {
|
|
51136
|
+
if (scryUnread) add("selection");
|
|
51137
|
+
if (!p2.paidDraw && /look at the top [^.\n]*\.[^\n]*\binto your hand\b/.test(t)) add("selection");
|
|
51138
|
+
if (!p2.drawsEachTurn && !p2.paidDraw && abilityDraw) add("activatedDraw");
|
|
51139
|
+
if (theirLands) add("opponentMana");
|
|
51140
|
+
if (p2.manaVaries && !p2.makesLater) add("landVaries");
|
|
51141
|
+
if (p2.landUses) add("landRunsOut");
|
|
51142
|
+
if (EXTRA_TURN.test(t)) add("extraTurn");
|
|
51143
|
+
if (GRANTS_MANA.test(t)) add("grantsMana");
|
|
51144
|
+
if (p2.tapRule?.kind === "unknown") add("tapUnknown");
|
|
51145
|
+
if (!p2.paidTreasure && TREASURE2.test(t)) add("manaTokens");
|
|
51146
|
+
if (/\bsearch your library for up to (?:two|three) basic land cards\b[^.\n]*\bonto the battlefield\b/.test(t)) add("landRamp");
|
|
51147
|
+
if (/(?:^|\n)(?:hideaway|mayhem)\b/.test(t)) add("elsewhereCast");
|
|
51148
|
+
if (SELF_MILL.test(t)) add("graveUnread");
|
|
51149
|
+
if (IMPULSE.test(raw)) add("impulseDraw");
|
|
51150
|
+
if (/\bdiscover (?:\d+|x)\b/.test(t)) add("freeCast");
|
|
51151
|
+
if (/\buntap (?:target|up to \w+|x target|all|each|two|three)[^.\n]*\blands?\b|\buntap target legendary permanent\b/.test(t)) add("untap");
|
|
51152
|
+
if (/\bspells you cast cost \{\d+\} less\b|\bcosts? \{\d+\} less to cast\b/.test(t)) add("reducer");
|
|
51153
|
+
if (/\bput a land card from your hand onto the battlefield\b/.test(t)) add("extraLand");
|
|
51154
|
+
if (/\beach land is an? (?:plains|island|swamp|mountain|forest) in addition to its other land types\b/.test(t)) add("grantsMana");
|
|
51155
|
+
if (!p2.sacBurst && /(?:^|\n)\{t\}, (?:sacrifice (?:this land|an? (?:land|plains|island|swamp|mountain|forest))|exert this land)[^:\n]*: add\b|(?:^|\n)\{[wubrgc]\}, \{t\}, exert this land: add\b/.test(t)) add("manaUnread");
|
|
51156
|
+
return;
|
|
51157
|
+
}
|
|
51158
|
+
if (theirLands) add("opponentMana");
|
|
51159
|
+
if (p2.phyrexian) add("phyrexian");
|
|
51160
|
+
if (p2.manaVaries && !p2.makesLater) add("sourceVaries");
|
|
51161
|
+
const findsACard = /search your library for (?:a|an|up to \w+) /.test(t) || /reveal cards from the top of your library until you reveal a card with the chosen name[^.]*\. put that card into your hand/.test(t) || // Digging until you keep one (Tainted Pact).
|
|
51162
|
+
/\brepeat this process until you put a card into your hand\b/.test(t);
|
|
51163
|
+
if (findsACard && args.isTutor && !args.isTutor(c.oracleId) && !args.asked?.(c.oracleId)) add("tutorMissed");
|
|
51164
|
+
if (args.isTutor?.(c.oracleId) && t.split("\n").some(
|
|
51165
|
+
(l) => /^[^:\n]+:[^\n]*search your library/.test(l) && !/^[^:]*\bsacrifice (?:this|it)\b[^:]*:/.test(l) || // Or a search on a trigger that repeats: every turn (Land Tax),
|
|
51166
|
+
// every attack (Sword of the Animist).
|
|
51167
|
+
/^\s*(?:at the beginning of (?:your|each)|whenever)\b[^\n]*search your library/.test(l) && !/\bsacrifice this\b/.test(l)
|
|
51168
|
+
))
|
|
51169
|
+
add("tutorRepeat");
|
|
51170
|
+
if (!p2.freeCast && !p2.cascade && (/without paying (?:its|their) mana costs?/.test(t) && !/cast this spell without paying/.test(t) || // Other spells cast for life instead (Bolas's Citadel): free here.
|
|
51171
|
+
/rather than pay (?:its|their) mana costs?/.test(t)))
|
|
51172
|
+
add("freeCast");
|
|
51173
|
+
else if (!p2.freeCast && /\bdiscover (?:\d+|x)\b/.test(t)) add("freeCast");
|
|
51174
|
+
if (!p2.treasures && !p2.treasuresPerRound?.length && // (Smothering Tithe's, read as our guess since 2026-10-28.)
|
|
51175
|
+
!p2.treasuresPerOpponent && !p2.combatTreasures && // (A paid Treasure ability: Bucknard's Everfull Purse, since 2026-10-28.)
|
|
51176
|
+
!p2.paidTreasure && !p2.diesTreasures && // (A death watcher's Treasure: Pitiless Plunderer.)
|
|
51177
|
+
!p2.diesDraw?.some((d) => d.treasures) && // (Academy Manufactor's "a clue, food, or treasure token": read.)
|
|
51178
|
+
!p2.tokenTriple && // (A cast trigger's Treasure: Storm-Kiln Artist's magecraft.)
|
|
51179
|
+
!p2.castTriggers?.some((x) => x.treasures) && TREASURE2.test(front) || // A land token (Overlord of the Hauntwoods' "Everywhere") taps for mana.
|
|
51180
|
+
/\bcreates? [^.\n]*\bland tokens?\b/.test(t) || // Its own entry is read, the rest is a trigger (Ganax: "or another dragon ... enters").
|
|
51181
|
+
!!p2.treasures && /\bor another\b[^,\n]*\benters, create\b[^.\n]*\btreasure\b/.test(t))
|
|
51182
|
+
add("manaTokens");
|
|
51183
|
+
if (/\bspend mana as though it were mana of any (?:color|type)\./.test(t)) add("manaUnread");
|
|
51184
|
+
const noMana = !givesMana(p2);
|
|
51185
|
+
if (args.tutorUnread(c.oracleId)) add("tutorUnread");
|
|
51186
|
+
const ADDS = /(?:^|\n|: |, |\. |• |— |may |and |you |controller |player )adds? (?:\{|an additional \{|(?:one|two|three|four|five|six|seven|eight|nine|ten|x) mana|an amount of)/;
|
|
51187
|
+
const onToken = /* @__PURE__ */ new Set();
|
|
51188
|
+
const given = [...t.matchAll(/"[^"]*"/g)].filter((q) => ADDS.test(q[0].slice(1))).map((q) => {
|
|
51189
|
+
if (/\bcreates? [^."]*\btokens?\b[^."]*$|\btokens? you control ha(?:s|ve) $/.test(t.slice(0, q.index))) onToken.add(q[0]);
|
|
51190
|
+
return q[0];
|
|
51191
|
+
});
|
|
51192
|
+
const tokenMana = (q) => onToken.has(q) || /sacrifice this (?:token|artifact)/.test(q);
|
|
51193
|
+
if ((noMana || given.some((q) => onToken.has(q))) && given.some(tokenMana) && !p2.foodMana) add("manaTokens");
|
|
51194
|
+
if (p2.foodMana && !p2.foodsPerRound?.length && /\bwhenever an opponent\b[^\n]*\bcreate (?:a|an|one|two) food\b/.test(t)) add("manaTokens");
|
|
51195
|
+
const playedGrant = (q) => !!p2.grantsTapMana && new RegExp(`\\bcreatures you control (?:have|gain) (?:[a-z]+ and )?${q.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`).test(t);
|
|
51196
|
+
const granted = given.some((q) => !tokenMana(q) && !playedGrant(q)) || // Every land of yours taps for every color (Dryad of the Ilysian Grove).
|
|
51197
|
+
/\blands you control are every basic land type\b/.test(t);
|
|
51198
|
+
const unreadMana = backTreasure || // (A source we read at a floor of 0, Nyx Lotus, is flagged as varying, not unread.)
|
|
51199
|
+
noMana && !p2.manaVaries && !p2.foodMana && !p2.grantsTapMana?.length && ADDS.test(unread.replace(/"[^"]*"/g, ""));
|
|
51200
|
+
if (granted) add("grantsMana");
|
|
51201
|
+
if (unreadMana) add("manaUnread");
|
|
51202
|
+
else if (!granted && p2.makes.length && /(?:^|\n)[^:{\n]+: untap this (?:creature|artifact|permanent)\b/.test(t)) add("manaUnread");
|
|
51203
|
+
if (noMana && !p2.rampLands && (/search your library for [^.\n]*\b(?:lands?|plains|islands?|swamps?|mountains?|forests?)\b[^.\n]*onto the battlefield/.test(t) || // "... for a creature or land card ... put it onto the battlefield tapped if it's a land card"
|
|
51204
|
+
/search your library for [^.\n]*\blands? card\b[^\n]*onto the battlefield[^.\n]*\bif it's a land\b/.test(t) || /search your library for [^.\n]*\bland card\.\s*put (?:both cards|them|that card|it) onto the battlefield/.test(t) || // (Traverse the Outlands: "... basic land cards, where x is ... . put those cards onto the battlefield".)
|
|
51205
|
+
/search your library for [^.\n]*\blands? cards\b[^.\n]*\.\s*put those cards onto the battlefield/.test(t)))
|
|
51206
|
+
add("landRamp");
|
|
51207
|
+
if (noMana && !p2.untaps && (/\buntap (?:target|up to \w+|x target|all|each|two|three)[^.\n]*\blands?\b/.test(t) || /\btarget [^.\n]*\blands? you control\b[^.\n]*\.\s*untap (?:it|that land)\b/.test(t) || // Your mana rocks and dorks again (Dramatic Reversal: "untap all
|
|
51208
|
+
// nonland permanents you control"; "untap all artifacts you control").
|
|
51209
|
+
// (Dramatic Reversal's is played since 2026-10-25: untapsNonland.)
|
|
51210
|
+
!p2.untapsNonland && /\buntap all (?:nonland permanents|artifacts|permanents) you control\b/.test(t) || // Your creatures (Sky Hussar as it enters: dorks again), with an
|
|
51211
|
+
// extra combat too: Great Train Heist's "untap all creatures you
|
|
51212
|
+
// control", Grim Reaper's Sprint's "untap each creature you
|
|
51213
|
+
// control", Combat Celebrant's "all other creatures" untap your
|
|
51214
|
+
// dorks, so their mana is there again (Gabriel, 2026-10-26; round 9
|
|
51215
|
+
// had left these out). Not the creatures "that attacked"
|
|
51216
|
+
// (Overpowering Attack, Relentless Assault): attackers, not dorks.
|
|
51217
|
+
/\buntap (?:all|each) (?:other )?creatures? you control\b(?! that attacked)/.test(t) || // (Great Oak Guardian's "creatures target player controls get +2/+2
|
|
51218
|
+
// until end of turn. untap them.": yours, a flash dork-untap.)
|
|
51219
|
+
/\bcreatures target player controls get [^.\n]*\. untap them\b/.test(t) || // One permanent of yours again: "{T}: untap another target permanent"
|
|
51220
|
+
// (Kiora's Follower), "untap another target artifact" (Manifold
|
|
51221
|
+
// Key), "when this creature enters, untap target creature" (Hyrax
|
|
51222
|
+
// Tower Scout): a land's, a rock's or a dork's mana again, not played
|
|
51223
|
+
// (these were silent: ledger round 7).
|
|
51224
|
+
// (Minamo's "untap target legendary permanent": Gaea's Cradle again, round 9.)
|
|
51225
|
+
/\buntap (?:another )?target (?:legendary )?(?:permanent|artifact|creature|nonland permanent)\b/.test(t) || // (Valley Floodcaller's "birds, frogs, otters, and rats you control get +1/+1 until end of turn. untap them.": typed dorks again, round 9.)
|
|
51226
|
+
/\byou control get [^.\n]*\. untap them\b/.test(t) || // (Freed from the Real's "{U}: untap enchanted creature": a dork again.)
|
|
51227
|
+
/\buntap enchanted (?:creature|permanent|artifact|land)\b/.test(t) || // (Tezzeret the Seeker's "+1: untap up to two target artifacts": two
|
|
51228
|
+
// rocks again; Tyvar's "untap up to one target creature".)
|
|
51229
|
+
/\buntap up to \w+ target (?:artifacts?|creatures?|permanents?)\b/.test(t)))
|
|
51230
|
+
add("untap");
|
|
51231
|
+
if (!p2.extraLandsEachTurn && !p2.extraLandsNow && /play (?:an|two|three) additional lands?|put a land card from your hand onto the battlefield/.test(t) || // A trigger's or a repeat's more than we read (Uro's attacks, Cultivator Colossus).
|
|
51232
|
+
/(?:^|\n)\s*whenever [^\n]*\bput a land card from your hand onto the battlefield|put a land card from your hand onto the battlefield[^\n]*\brepeat this process\b/.test(t) || // Permanent cards include lands (CR 110.4a): Ugin, the Spirit Dragon's -10.
|
|
51233
|
+
// (Not a typed one, Goblin Lackey's "goblin permanent card".)
|
|
51234
|
+
/\b(?:put|puts) (?:a|an|up to \w+|any number of) permanent cards?(?: with [^.\n]*?)? from your hand onto the battlefield\b/.test(t))
|
|
51235
|
+
add("extraLand");
|
|
51236
|
+
const ownCost = /this (?:spell|ability) costs (?:(?:\{(?:\d+|[wubrg])\})+|\{x\}|\w+ mana) less|this spell costs \{\d+\} more/;
|
|
51237
|
+
if (/this spell costs (?:\{\d+\}|\{x\}|\w+ mana) less/.test(t)) add("selfCost");
|
|
51238
|
+
if (
|
|
51239
|
+
// (Or a second one `reduces` can't hold: Grand Arbiter Augustin IV's white, and blue.)
|
|
51240
|
+
// (Two different lines, not an ability's: Rowan's other face repeats
|
|
51241
|
+
// its line, Ral's "+1: ... cost {1} less" is a loyalty ability.)
|
|
51242
|
+
(!p2.reduces || new Set(
|
|
51243
|
+
t.replace(new RegExp(ownCost.source, "g"), "").split("\n").filter((l) => !ACTIVATED.test(l) && /\bcosts? \{\d+\} less(?! to activate)/.test(l))
|
|
51244
|
+
).size > 1) && (/costs? (?:\{(?:\d+|[wubrg])\})+ less(?! to activate)|costs? (?:one|two|\d+) (?:generic )?mana less(?! to activate)/.test(t.replace(new RegExp(ownCost.source, "g"), "")) || // Convoke and the like it gives other spells (Hoarding Broodlord).
|
|
51245
|
+
/\bspells? you cast [^.\n]*\bha(?:s|ve) (?:convoke|improvise|delve|affinity)\b/.test(t))
|
|
51246
|
+
)
|
|
51247
|
+
add("reducer");
|
|
51248
|
+
if (p2.target === "none" && (p2.draws || p2.untaps || p2.ritualMakes.length || p2.makes.length || unreadMana || granted)) add("needsTarget");
|
|
51249
|
+
else if (p2.untaps || p2.reduces) add("trickCounted");
|
|
51250
|
+
if (scryUnread) add("selection");
|
|
51251
|
+
else if (!p2.selects && /\blook at the top \w+ cards of your library,? then put them back in any order\b/.test(t)) add("selection");
|
|
51252
|
+
else if (!p2.draws && !p2.selects && !p2.paidDig && (/look at the top [^.\n]*\.[^\n]*\b(?:into your hand|from among them (?:and put it )?onto the battlefield)/.test(t) || /\breveal the top \w+(?: plus one)? cards of your library\.[^\n]*\bfrom among them (?:and put (?:it|them) )?(?:into your hand|onto the battlefield)/.test(t) || /\bmill (?:\w+ )?cards?\.[^\n]*\bfrom among (?:them|the milled cards) into your hand/.test(t))) add("selection");
|
|
51253
|
+
if (!p2.draws && !p2.drawsEachTurn && !p2.paidDraw && !p2.lifeFill && abilityDraw) add("activatedDraw");
|
|
51254
|
+
const triggered = maskDrawConditions(unread).replace(/\n(?=\s*[•·+])/g, " ").split("\n").flatMap((l) => [l.replace(/"[^"]*"/g, ""), ...(l.match(/"[^"]*"/g) ?? []).map((q) => q.slice(1, -1))]).flatMap((l) => [l, ...l.split(/(?<=\.)\s+/).slice(1)]).flatMap((l) => [l, ...l.split(/\s*•\s*/).slice(1).map((m) => m.replace(/^[^—]*—\s*/, ""))]).map((l) => l.replace(/^\s*(?:i|ii|iii|iv|v|vi)(?:, (?:i|ii|iii|iv|v|vi))* — /, "whenever a chapter, ")).map((l) => l.replace(/,? and (?:an |each |target )?opponents? (?:may )?draws? (?:a|an|one|two|three|\d+) cards?\b|\b(?:an |each |target )?opponents? (?:may )?draws? (?:a|an|one|two|three|\d+) cards?\.?\s*/g, "")).map((l) => /\bcreatures? someone controls attack you\b/.test(l) ? l.replace(/\bthat player (?:may )?draws? (?:a|an|one|two|three|\d+) cards?\b/g, "") : l).filter((l) => !(p2.combatDraws && (COMBAT_DRAW.test(selfRef(c.name, l)) || CURSE_DRAW.test(l.trim())))).filter((l) => !(p2.landfallDraws && LANDFALL_DRAW.test(l.trim()))).map((l) => l.replace(/^\s*[a-z][a-z' ]* — /, "").replace(/^\s*\d+\+\s*\|\s*/, "")).map((l) => /^\s*whenever a player attacks\b/.test(l) ? l.replace(/\b(?:one|another) of your opponents\b|\bthat opponent\b/g, "someone").replace(/\bthat attacking player draws\b/g, "you draw") : l).some(
|
|
51255
|
+
(l) => /\bdraws? (?:(?:a|an|one|two|three|four|five|six|seven|\d+|that many|x) cards?\b|cards equal to\b)/.test(l) && !ACTIVATED.test(l) && // (The draw's own sentence or mode decides: Monument to Endurance's
|
|
51256
|
+
// "each opponent loses 3 life" mode isn't its draw. How many isn't
|
|
51257
|
+
// who: Zedruu's "where x is the number of permanents ... your
|
|
51258
|
+
// opponents control" is yours.)
|
|
51259
|
+
!l.split(/(?<=\.)\s+|\s*•\s*/).some((x) => /\bdraws? (?:a|an|one|two|three|four|five|six|seven|\d+|that many|x) cards?\b/.test(x) && /\bopponents?\b/.test(x.replace(AMOUNT, ""))) && !/^\s*when you cast (?:this spell|it)\b/.test(l) && !/^\s*when this class becomes level\b/.test(l) && (/^\s*whenever\b/.test(l) || /^\s*at the beginning of\b/.test(l) && !p2.drawsEachTurn || /^\s*when\b/.test(l) && (!/^\s*when [^,]*\benters\b/.test(l) || /^\s*when [^,]*, if\b/.test(l)) || // "When this enters or is put into a graveyard" (Ichor Wellspring): the second is a trigger.
|
|
51260
|
+
/^\s*when [^,]*\benters (?:or|and whenever)\b/.test(l))
|
|
51261
|
+
);
|
|
51262
|
+
if (triggered || // A card into your hand each turn behind an "if" (Twilight Prophet).
|
|
51263
|
+
/^\s*at the beginning of[^\n]*\bif\b[^\n]*\btop card of your library\b[^\n]*\binto your hand/m.test(t))
|
|
51264
|
+
add("triggerDraw");
|
|
51265
|
+
if (!p2.cascade && /\b(?:has|have|gains?) "?cascade\b/.test(t)) add("freeCast");
|
|
51266
|
+
for (const l of t.split("\n")) {
|
|
51267
|
+
if (!/\b(?:connives?|recruits?|recruit)\b/.test(l) || ACTIVATED.test(l)) continue;
|
|
51268
|
+
add(/\bopponents?\b/.test(l.split(",")[0]) ? "opponentDraw" : /^\s*(?:[a-z][a-z' ]* — )?(?:whenever|when|at the beginning)\b/.test(l) ? "triggerDraw" : "drawVaries");
|
|
51269
|
+
}
|
|
51270
|
+
if (/(?:^|\n)ravenous\b/.test(t) && !p2.draws) add("drawVaries");
|
|
51271
|
+
if (/\bfirebending (?:\d+|x)\b|\bforage: add\b/.test(t)) add("manaUnread");
|
|
51272
|
+
if (/\blander tokens?\b/.test(t)) add("landRamp");
|
|
51273
|
+
if (/(?:^|\n)(?:multi)?kicker\b|\bas an additional cost to cast this spell, you may\b|\bunless you waterbend\b/.test(t)) add("kicker");
|
|
51274
|
+
if (/\bas an additional cost to cast this spell, tap\b/.test(t)) add("selfCost");
|
|
51275
|
+
if (/\binvestigates?\b/.test(t) && !p2.clues && !p2.landfallClues && !p2.castTriggers?.some((x) => x.clues)) add("activatedDraw");
|
|
51276
|
+
if (p2.combatDraws && /\bwhere x is the number of opponents that were dealt combat damage this turn\b/.test(t)) add("drawVaries");
|
|
51277
|
+
if (p2.drawsGuess || p2.lifeFill) add("drawGuess");
|
|
51278
|
+
else if (/\binto your hand\b[^\n]*\byou may repeat this process\b/.test(t)) add("drawVaries");
|
|
51279
|
+
if (p2.treasuresPerOpponent && p2.treasuresPerRound === void 0) add("treasureGuess");
|
|
51280
|
+
if (p2.paidTreasure?.every) add("treasureTiming");
|
|
51281
|
+
if (/\beach player who\b[^.\n]*\bdraws? (?:a|an|one|two|three|four|five|six|seven|\d+) cards?\b/.test(t)) add("opponentDraw");
|
|
51282
|
+
if (/\bdraws? that many cards plus\b|\bdraws? x cards\b[^.\n]*\bwhere x is the number of colors of mana spent\b|\bdraws? (?:a|an|one|two) cards?\b[^.\n]*\brepeat this process\b/.test(t)) add("drawVaries");
|
|
51283
|
+
if (p2.draws && /\bif\b[^.\n]*\bdraws? (?:a|an|one|two|three|four|five|six|seven|\d+) cards? instead\b/.test(t)) add("drawVaries");
|
|
51284
|
+
if (p2.draws && /^\s*when this [a-z]+ enters\b[^\n]*\bdraw (?:a card for each|cards equal to the number of)\b/m.test(selfRef(c.name, t))) add("drawVaries");
|
|
51285
|
+
if (p2.draws && /\bcopy this spell for each\b/.test(t)) add("drawVaries");
|
|
51286
|
+
if (!p2.draws && !p2.drawsEachTurn && !p2.drawsPerOpponent && !p2.drawsHalfLibrary && // (Sentence by sentence, but not the rest of a trigger's line: Well of
|
|
51287
|
+
// Lost Dreams' "if you do, draw x cards" is its trigger's.)
|
|
51288
|
+
t.split("\n").filter((l) => !/^\s*(?:i|ii|iii|iv|v|vi)(?:, (?:i|ii|iii|iv|v|vi))* — /.test(l)).filter((l) => !/^\s*(?:whenever|at the beginning)\b/.test(l) && !(/^\s*when\b/.test(l) && !/^\s*when (?:[^,]*\benters\b|you cast (?:this spell|it)\b)/.test(l))).flatMap((l) => l.split(/(?<=\.)\s+/)).some(
|
|
51289
|
+
(l) => (/\bdraws? (?:(?:a|an|one|two|three|\w+) )?cards? (?:for each|equal to)\b|\bdraws? x cards\b|\bdraws? that many cards?\b/.test(l) || /\bfor each [^,.\n]*, draw a card\b/.test(l) || /\bdraws? half\b/.test(l)) && !ACTIVATED.test(l) && // (When it enters is sure: Regal Force; other triggers are flagged as that.)
|
|
51290
|
+
!/^\s*(?:whenever|at the beginning)\b/.test(l) && !(/^\s*when\b/.test(l) && !/^\s*when (?:[^,]*\benters\b|you cast (?:this spell|it)\b)/.test(l)) && // (Not a draw off opponents, flagged as that. How many isn't who:
|
|
51291
|
+
// Knollspine Dragon's "equal to the damage dealt to target
|
|
51292
|
+
// opponent" is yours.)
|
|
51293
|
+
!/\bopponents?\b/.test(l.replace(AMOUNT, ""))
|
|
51294
|
+
))
|
|
51295
|
+
add("drawVaries");
|
|
51296
|
+
if (!p2.draws && !p2.drawsEachTurn && t.split("\n").filter((l) => !ACTIVATED.test(l) && !/^\s*(?:[a-z][a-z' ]* — )?(?:whenever|at the beginning)\b/.test(l) && !(/^\s*when\b/.test(l) && !/^\s*when (?:[^,]*\benters\b|you cast (?:this spell|it)\b)/.test(l)) && !/^\s*when [^,]*, if\b/.test(l)).map((l) => l.replace(/"[^"]*"/g, "")).flatMap((l) => l.split(/(?<=\.)\s+/)).some(
|
|
51297
|
+
(x) => /\bif\b[^.]*\bdraws? (?:a|an|one|two|three|four|five|six|seven|\d+) cards?\b/.test(x) && !/\bwould draw\b/.test(x) && !/\b(?:its controller|that player|they|(?:an |each |target )?opponents?)\b[^.]*\bdraws?\b/.test(x)
|
|
51298
|
+
))
|
|
51299
|
+
add("drawVaries");
|
|
51300
|
+
if (/\bif you would draw\b[^\n]*(?:\bdraw (?:two|three|\w+) cards? instead\b|\b(?:instead|otherwise)\b[^\n]*\bdraws? (?:a|an|one|two|three|\w+) cards?\b)/.test(t)) add("drawVaries");
|
|
51301
|
+
if (!p2.reanimate && reanimates(t, c.name)) add("reanimate");
|
|
51302
|
+
if (EXTRA_TURN.test(t)) add("extraTurn");
|
|
51303
|
+
if (!p2.discardsEachTurn && HURTS_YOU.some((r) => r.test(t) && !(r === TAX_ON_EVERY_SPELL && (p2.reduces?.amount ?? 0) < 0))) add("hurtsYou");
|
|
51304
|
+
if (!p2.regrowth && /\breturn (?!this card|this creature|it\b)[^.\n]*\bcards? [^.\n]*from (?:your|a) graveyard to (?:your|its owner's) hand\b|\breturn to your hand all cards in your graveyard\b/.test(t)) add("regrowth");
|
|
51305
|
+
if (!p2.mills && !p2.reanimate && !p2.regrowth && !kinds.has("reanimate") && !kinds.has("regrowth") && (SELF_MILL.test(t) || // (Hermit Druid: "reveal cards ... until you reveal a basic land card. put that card into your hand and all other cards revealed this way into your graveyard".)
|
|
51306
|
+
!p2.millUntilPaid && /\buntil you reveal an? [^.\n]*card\. put that card into your hand and all other cards revealed this way into your graveyard\b/.test(t) || // (Undercity Informer's paid one: "target player reveals ... until they reveal a land card, then puts those cards into their graveyard".)
|
|
51307
|
+
!p2.millsUntilLand && !p2.millUntilPaid && /\btarget player reveals cards from the top of their library until they reveal a land card, then puts those cards into their graveyard\b/.test(t) || /\breturn (?:this card|this creature|~) from your graveyard to (?:your hand|the battlefield)\b/.test(t)))
|
|
51308
|
+
add("graveUnread");
|
|
51309
|
+
if (!kinds.has("graveUnread") && /(?:^|\n)(?:dredge|unearth|persist|undying|embalm|eternalize|encore|scavenge)\b/.test(t)) add("graveUnread");
|
|
51310
|
+
if (/\bexplores?\b/.test(t) || /\bmap tokens?\b/.test(t) && !/\bits controller creates\b[^.\n]*\bmap tokens?\b/.test(t)) add("explore");
|
|
51311
|
+
if (/\bcards? in your hand ha(?:s|ve) (?:cycling|[a-z]+cycling|flash|madness|evoke|ninjutsu|plot|foretell|convoke|affinity|improvise|delve)\b/.test(t)) add("grantsUnread");
|
|
51312
|
+
if (/\b(?:that ability|it) triggers an additional time\b|\b(?:another )?target creature (?:becomes [a-z]+ and )?gains haste until end of turn\b|\bwhenever a creature you control with [a-z]+ enters, it gains haste\b|\buntil end of turn, creatures you control get [^.\n]* and gain haste\b|(?:^|\n)enchanted creature has (?:[a-z]+ and )?haste\b|(?:^|\n)\{[^}]+\}: (?:creatures you control|all creatures) gain (?:[a-z]+ and )?haste until end of turn\b/.test(t)) add("grantsUnread");
|
|
51313
|
+
if (!p2.land && // (Not the Chain spells' copy offered to their target: Chain of Vapor's
|
|
51314
|
+
// "they may copy this spell".)
|
|
51315
|
+
(/\bcreates? (?:a|an|x|one|two|three|that many|[a-z]+)(?: tapped)? tokens? that(?:'s| are)(?: a)? cop(?:y|ies) of\b/.test(t) || /\bbecomes? a copy of\b/.test(t) || /\bcop(?:y|ies) (?:target|that|it|this)\b[^.\n]*?(?:\bspell|\bability|$)|\bcopy that spell\b|\bcopies it\b|\bcopy the exiled card\b/m.test(t.replace(/\bthis spell can't be copied\.\s*|\b(?:that player|they) may copy this spell\b/g, "")) || !p2.copiesSource && /\benter as a copy of\b/.test(t) || /\b(?:has|have|gains?) all activated abilities of\b/.test(t) || /(?:^|\n)(?:offspring|squad|myriad|replicate|casualty|conspire|demonstrate)\b/.test(t)))
|
|
51316
|
+
add("copyUnread");
|
|
51317
|
+
if (deckTreasure && TOKEN_DOUBLER.test(t)) add("tokenDoubler");
|
|
51318
|
+
if (p2.sacDraw && /\bwhenever [^,.\n]* enters or attacks, sacrifice another permanent\b/.test(t)) add("triggerDraw");
|
|
51319
|
+
if (/\btarget opponent exiles the top card of their library\. until end of turn, you may play that card\b/.test(t)) add("impulseDraw");
|
|
51320
|
+
if (/\bas long as [^,.\n]* attacked this turn, you may play the top card of your library\b/.test(t)) add("elsewhereCast");
|
|
51321
|
+
if (!kinds.has("graveUnread") && /(?:^|\n)\{t\}: target player mills (?:a|one|two) cards?\b/.test(t)) add("graveUnread");
|
|
51322
|
+
if (readExilesFirst(t) && !args.asked?.(c.oracleId)) add("exilesFirst");
|
|
51323
|
+
if (!p2.alts?.length && (/\b(?:retrace|jump-start|disturb|aftermath|foretell|plot|suspend|mayhem|rebound|cipher|paradigm|hideaway|ripple)\b/.test(t) || // (Flashback, escape, harmonize, the turn's graveyard casting
|
|
51324
|
+
// Underworld Breach / Past in Flames give, and play-from-exile are
|
|
51325
|
+
// played since 2026-10-25: the rest of this is excused once one is read.)
|
|
51326
|
+
!p2.fromGraveyard && !p2.grantsGraveCast && !p2.impulse && (/\b(?:flashback|escape|harmonize)\b|you may (?:cast|play) (?:this card|it|[^.]*) from (?:your graveyard|exile)|you may (?:cast|play) [^.]*\bfrom the top of your library|in your graveyard\. you may cast (?:that card|it)\b/.test(t) || // An opponent's card cast from exile is still a cast from exile (CR
|
|
51327
|
+
// 601.2a; Ragavan's ruling: "pay all costs when casting the exiled
|
|
51328
|
+
// card"): Ragavan's and Grenzo's "exile the top card of that player's
|
|
51329
|
+
// library ... you may cast that card", Hostage Taker's.
|
|
51330
|
+
/\b(?:that player's|target (?:player|opponent)'s|each opponent's|an opponent's) library\b[^\n]*\byou may (?:cast|play)\b/.test(t) || /\bexile another target [^.\n]*\.\s*you may cast that card\b/.test(t) || // (Hoarding Broodlord: "search your library ..., exile it face down ... you may play it".)
|
|
51331
|
+
/\bsearch your library for [^\n]*\bexile (?:it|that card|them)(?: face down)?\b[^\n]*\byou may (?:cast|play) (?:it|that card|them)\b/.test(t))))
|
|
51332
|
+
add("elsewhereCast");
|
|
51333
|
+
if (!p2.alts?.length && (/(?:^|\n)(?:evoke|dash|blitz|madness|miracle|overload|bestow|emerge|surge|spectacle|prowl|warp|impending|morph|disguise|megamorph|mutate|web-slinging|[a-z]+ offering)\b/.test(t) || // Pitch spells (Force of Will: "exile a blue card ... rather than pay
|
|
51334
|
+
// this spell's mana cost").
|
|
51335
|
+
/rather than pay this spell's mana cost/.test(t) || // Free on a condition we don't read (Submerge's "if an opponent
|
|
51336
|
+
// controls a forest and you control an island"); "if you control a
|
|
51337
|
+
// commander" is read (Fierce Guardianship).
|
|
51338
|
+
/\bif (?!you control a commander,)[^,.\n]*, you may cast this spell without paying its mana cost\b/.test(t)))
|
|
51339
|
+
add("altUnread");
|
|
51340
|
+
else if (/\bcards in your hand have (?:warp|dash|blitz|evoke)\b/.test(t)) add("altUnread");
|
|
51341
|
+
if (p2.rampLands && /\bwhenever this (?:creature|permanent) enters or attacks, (?:you may )?search your library for [^.\n]*\bbasic land\b/.test(t)) add("landRamp");
|
|
51342
|
+
if (/(?:^|\n)(?:convoke|delve|improvise|affinity for|undaunted)\b/.test(t)) add("selfCost");
|
|
51343
|
+
if (!p2.impulse && IMPULSE.test(raw)) add("impulseDraw");
|
|
51344
|
+
if (!p2.drawsPerRound?.length && !p2.drawsPerOpponent && drawsOffOpponents(t)) add("opponentDraw");
|
|
51345
|
+
if (p2.target !== "none" && !p2.drawsGuess && (p2.draws || p2.drawsEachTurn || p2.selects || p2.combatDraws || p2.drawsPerOpponent)) add("drawCounted");
|
|
51346
|
+
}
|
|
51347
|
+
}
|
|
51348
|
+
return out;
|
|
51349
|
+
}
|
|
51350
|
+
var GRANTS_MANA = /\b(?:lands|creatures|artifacts|permanents) you control (?:have|gain) "\{t\}: add\b/;
|
|
51351
|
+
var SELF_MILL = /(?<!(?:controller|that player|defending player|opponent|opponents|they) )\bmills? (?:a|an|one|two|three|four|five|six|seven|eight|nine|ten|x|that many|\d+) cards?\b/;
|
|
51352
|
+
var TAX_ON_EVERY_SPELL = /(?:^|\n)(?:noncreature |creature |artifact |enchantment |)spells cost \{\d+\} more to cast\./;
|
|
51353
|
+
var HURTS_YOU = [
|
|
51354
|
+
/\b(?:each player|players) can't cast more than one\b/,
|
|
51355
|
+
/\bplayers can't search libraries\b/,
|
|
51356
|
+
/\bnonbasic lands are (?:mountains|islands|swamps|forests|plains)\b/,
|
|
51357
|
+
/\bnonbasic lands don't untap\b/,
|
|
51358
|
+
/\bactivated abilities of (?:artifacts|creatures|artifacts, creatures, and planeswalkers)(?! your opponents control)(?! an opponent controls) can't be activated\b/,
|
|
51359
|
+
/\ball artifacts have "at the beginning of your upkeep, sacrifice this artifact unless you pay\b/,
|
|
51360
|
+
/\bwhenever a player casts a spell, that player (?:discards|loses|sacrifices)\b/,
|
|
51361
|
+
/\bif a player would draw a card except the first one\b/,
|
|
51362
|
+
/(?:^|\n|: |, |\. |— )each player discards (?:a|one|two|three) cards?\./,
|
|
51363
|
+
// (Edicts that take one of yours too: Plaguecrafter, Fleshbag Marauder,
|
|
51364
|
+
// Season of Loss's mode; Pox Plague's halves; Smallpox's everything.)
|
|
51365
|
+
/(?:^|\n|: |, |\. |• |— )each player sacrifices (?:a|an|one|two)\b/,
|
|
51366
|
+
/\beach player loses half their life\b/,
|
|
51367
|
+
/(?:^|\n)each player loses (?:\d+|one|two) life, discards\b/,
|
|
51368
|
+
// (Root Maze: "artifacts and lands enter tapped", yours too.)
|
|
51369
|
+
/(?:^|\n)(?:artifacts and lands|lands|artifacts) enter tapped\./,
|
|
51370
|
+
// (Taxes on every spell, yours too: Sphere of Resistance, Thalia. Played
|
|
51371
|
+
// since 2026-10-28 when read, a reducer below 0: then not one of these.)
|
|
51372
|
+
TAX_ON_EVERY_SPELL,
|
|
51373
|
+
// (Your untap step too: Static Orb, Storage Matrix.)
|
|
51374
|
+
/\bplayers can't untap more than\b|\beach player chooses artifact, creature, or land during their untap step\b/,
|
|
51375
|
+
// (Your x/1 dorks too: Soul Snuffers.)
|
|
51376
|
+
/(?:^|\n|, )put a -1\/-1 counter on each creature\./,
|
|
51377
|
+
// (Your Treasure and fetches too: Yasharn's "players can't pay life or sacrifice nonland permanents".)
|
|
51378
|
+
/\bplayers can't pay life or sacrifice\b/,
|
|
51379
|
+
// (Your graveyard too: Soulless Jailer.)
|
|
51380
|
+
/\bpermanent cards in graveyards can't enter the battlefield\b|\bplayers can't cast [^.\n]*\bfrom graveyards\b/,
|
|
51381
|
+
/\beach player exiles (?:a|one|two|three) cards? from their hand\b/,
|
|
51382
|
+
/(?:^|\n|\. )(?:non-phyrexian )?creatures enter tapped\b/,
|
|
51383
|
+
/\b(?:permanents|creatures) entering (?:the battlefield )?don't cause abilities to trigger\b/,
|
|
51384
|
+
// (Round 8, 2026-10-25: your free spells countered, Vexing Bauble; your
|
|
51385
|
+
// dorks don't untap, Intruder Alarm, Dream Tides; your second spell,
|
|
51386
|
+
// Ethersworn Canonist; your big lands and second spell, Damping Sphere;
|
|
51387
|
+
// your reanimation, Containment Priest; your abilities taxed, Suppression
|
|
51388
|
+
// Field; your lands, Impending Disaster.)
|
|
51389
|
+
/\bwhenever a player casts a spell, if no mana was spent to cast it, counter that spell\b/,
|
|
51390
|
+
/(?:^|\n)creatures don't untap during their controllers' untap steps\b/,
|
|
51391
|
+
// (Not one that follows its own ability, Conduit of Worlds: "if you do, you can't cast additional spells".)
|
|
51392
|
+
/(?<!\bif you do, you )\bcan't cast additional (?:nonartifact )?spells\b/,
|
|
51393
|
+
/\bif a land is tapped for two or more mana, it produces \{c\} instead\b|\beach spell a player casts costs \{\d+\} more to cast for each other spell\b/,
|
|
51394
|
+
/\bif a nontoken creature would enter (?:the battlefield )?and it wasn't cast, exile it instead\b/,
|
|
51395
|
+
/(?:^|\n)activated abilities cost \{\d+\} more to activate unless they're mana abilities\b/,
|
|
51396
|
+
/\bdestroy all lands\b/,
|
|
51397
|
+
// (A land a turn, The Gitrog Monster's upkeep; your Treasure made Dragons,
|
|
51398
|
+
// Draconic Visitor.)
|
|
51399
|
+
/\bat the beginning of your upkeep, sacrifice [^.\n]* unless you sacrifice a land\b/,
|
|
51400
|
+
// (Not one that adds a token, Stridehangar Automaton's "those tokens plus an additional Thopter".)
|
|
51401
|
+
/\bif one or more artifact tokens would be created under your control, (?![^.\n]*\bplus\b)[^.\n]* are created instead\b/,
|
|
51402
|
+
// (Round 9, 2026-10-25, these were silent.) Your own board too: your
|
|
51403
|
+
// cheap rocks and dorks (Culling Ritual), your dorks' abilities (Dress
|
|
51404
|
+
// Down), your creatures phased out (Out of Time), your small dorks
|
|
51405
|
+
// (Yahenni's Expertise, Toxic Deluge, Black Sun's Zenith), a permanent of
|
|
51406
|
+
// yours (Perilous Research), a sweeper (Wrath of God, Split Up, Bane of
|
|
51407
|
+
// Progress); your graveyard plans (Necrodominance's exile instead,
|
|
51408
|
+
// Necropotence's discards).
|
|
51409
|
+
/\bdestroy each nonland permanent with mana value \d+ or less\b/,
|
|
51410
|
+
/(?:^|\n)creatures lose all abilities\b/,
|
|
51411
|
+
/\buntap all creatures, then those creatures phase out\b/,
|
|
51412
|
+
/(?:^|\n)all creatures get -(?:\d+|x)\/-(?:\d+|x) until end of turn\b|\bput x -1\/-1 counters on each creature\b/,
|
|
51413
|
+
/\bthen sacrifice a permanent\b/,
|
|
51414
|
+
// (Not one that spares yours: Force of Despair's "that entered this turn", "you don't control".)
|
|
51415
|
+
/(?:^|\n|• |enters, |then )destroy all (?:tapped |untapped |non-?[a-z]+ )?(?:creatures|artifacts|nonland permanents)\b(?! (?:that entered|you don't control|your opponents control))/,
|
|
51416
|
+
/\bif a card or token would be put into your graveyard from anywhere, exile it instead\b|\bwhenever you discard a card, exile that card from your graveyard\b/,
|
|
51417
|
+
// (Round 10, 2026-10-25: wordings the sweeper rule missed.) Damage to each
|
|
51418
|
+
// creature (Blasphemous Act, Fire Magic), all but a chosen type (Crippling
|
|
51419
|
+
// Fear), your permanents phased out (Teferi's Protection), every creature
|
|
51420
|
+
// sacrificed first (Living Death).
|
|
51421
|
+
// (Not theirs only: Incinerator of the Guilty's "each creature and planeswalker that player controls".)
|
|
51422
|
+
/\bdeals (?:\d+|x) damage to each creature\b(?! (?:you don't control|your opponents control|and planeswalker (?:that player|they|your opponents) controls?))/,
|
|
51423
|
+
/(?:^|\n|\. )creatures that aren't of the chosen type get -\d+\/-\d+/,
|
|
51424
|
+
/\ball permanents you control phase out\b/,
|
|
51425
|
+
/\bsacrifices all creatures they control\b/,
|
|
51426
|
+
// (Round 11, 2026-10-26: your dorks and rocks sent back too.) Airbend all
|
|
51427
|
+
// (Avatar's Wrath), a bounce of all but one (Consuming Tide), a mass
|
|
51428
|
+
// bounce (Evacuation).
|
|
51429
|
+
/\bairbend all (?:other )?creatures\b/,
|
|
51430
|
+
/\breturn all nonland permanents not chosen\b|(?:^|\n|\. )return all (?:creatures|nonland permanents) to their owners' hands\b/
|
|
51431
|
+
];
|
|
51432
|
+
var EXTRA_TURN = /(?:^|\n|[.,:"] )(?:target player )?takes? an extra turn\b/;
|
|
51433
|
+
var IMPULSE = /exile the top (?:\w+ )?cards? of your library[^.]*\.\s*(?:choose one(?: of them)?\.\s*)?(?:until [^,]*, )?you may (?:play|cast) (?:them|those cards|that card|it|cards exiled|[^.\n]*\bfrom among (?:them|those (?:exiled )?cards))/;
|
|
51434
|
+
var AMOUNT = /\b(?:where x is|equal to) [^.]*/g;
|
|
51435
|
+
var NOT_READINGS = /* @__PURE__ */ new Set(["drawCounted", "trickCounted"]);
|
|
51436
|
+
|
|
50311
51437
|
// ../src/lib/deckPlan/planSources.ts
|
|
51438
|
+
init_manaOverrides();
|
|
51439
|
+
init_tableGuesses();
|
|
50312
51440
|
function planZoneCard(c) {
|
|
50313
51441
|
return { name: c.name.split(" // ")[0], cost: c.cmc, manaCost: c.manaCost, oracleId: c.oracleId, card: c };
|
|
50314
51442
|
}
|
|
@@ -50376,6 +51504,65 @@ var MISS_LABEL = {
|
|
|
50376
51504
|
noMana: { text: "short on mana", hint: "You had the cards and made every land drop, still not enough mana." },
|
|
50377
51505
|
countShort: { text: "fell short", hint: "The count never reached your number by that turn." }
|
|
50378
51506
|
};
|
|
51507
|
+
function tutorReadQuery(a) {
|
|
51508
|
+
const { oid, card: c, otagIndex, tutorOv } = a;
|
|
51509
|
+
if (tutorOv[oid]?.added && !otagIndex) return "any card";
|
|
51510
|
+
const reach = otagIndex && c ? buildTutorReach(otagIndex, { oracleId: oid, cmc: c.cmc, keywords: c.keywords, manaCost: c.manaCost }) : null;
|
|
51511
|
+
if (!reach) return tutorOv[oid]?.added ? "any card" : "can't tell: type what it finds";
|
|
51512
|
+
const text = a.tutorReads.get(oid)?.finds;
|
|
51513
|
+
if (text) return text;
|
|
51514
|
+
const q = tutorReachQuery(reach);
|
|
51515
|
+
return q === null ? "can't tell: type what it finds" : q === "" ? "any card" : q;
|
|
51516
|
+
}
|
|
51517
|
+
function isKnownTutor(otagIndex, oid, c) {
|
|
51518
|
+
const reach = otagIndex && c ? buildTutorReach(otagIndex, { oracleId: oid, cmc: c.cmc, keywords: c.keywords, manaCost: c.manaCost }) : null;
|
|
51519
|
+
return !!reach || !!c?.roles.includes("tutor");
|
|
51520
|
+
}
|
|
51521
|
+
function planAssumptionsFor(a) {
|
|
51522
|
+
const { ctx, overrides, tutorOv } = a;
|
|
51523
|
+
const { profiles, oracle, otagIndex } = ctx;
|
|
51524
|
+
if (!profiles || !oracle) return [];
|
|
51525
|
+
const cardByOid = new Map([...ctx.commanders.map((c) => [c.oracleId, c.card]), ...ctx.deck.map((c) => [c.oracleId, c])]);
|
|
51526
|
+
const rowTutorOids = new Set([...a.rowTutors.values()].flatMap((list) => list.map((t) => t.oracleId)));
|
|
51527
|
+
const askedOids = new Set(a.rows.flatMap((r) => r.source.kind === "cards" ? r.source.cards.map((c) => c.oracleId) : []));
|
|
51528
|
+
const query = (oid) => tutorReadQuery({ oid, card: cardByOid.get(oid), otagIndex, tutorOv, tutorReads: ctx.tutorReads });
|
|
51529
|
+
return planAssumptions({
|
|
51530
|
+
deck: ctx.deck,
|
|
51531
|
+
commanders: ctx.commanders,
|
|
51532
|
+
...ctx.commanderReads ? { commanderProfiles: ctx.commanderReads } : {},
|
|
51533
|
+
profiles,
|
|
51534
|
+
text: (oid) => oracle(oid),
|
|
51535
|
+
yours: (oid) => !!overrides[oid] || !!tutorOv[oid],
|
|
51536
|
+
tutorUnread: (oid) => rowTutorOids.has(oid) && query(oid).startsWith("can't tell"),
|
|
51537
|
+
isTutor: (oid) => {
|
|
51538
|
+
const t = tutorOv[oid];
|
|
51539
|
+
return !t?.off && (isKnownTutor(otagIndex, oid, cardByOid.get(oid)) || !!t?.added || !!t?.finds?.trim());
|
|
51540
|
+
},
|
|
51541
|
+
asked: (oid) => askedOids.has(oid)
|
|
51542
|
+
});
|
|
51543
|
+
}
|
|
51544
|
+
function withTutorRead(prev, oid, o) {
|
|
51545
|
+
const next = { ...prev };
|
|
51546
|
+
if (o && !isEmptyTutorOverride(o)) next[oid] = o;
|
|
51547
|
+
else delete next[oid];
|
|
51548
|
+
return next;
|
|
51549
|
+
}
|
|
51550
|
+
function applyReadEdits(start, edits) {
|
|
51551
|
+
let { cards, table, tutors } = start;
|
|
51552
|
+
for (const e of edits) {
|
|
51553
|
+
if (e.mana) {
|
|
51554
|
+
const next = { ...layerTable(cards, table)[e.oracleId] ?? {}, ...e.mana };
|
|
51555
|
+
const split = splitEdit(e.oracleId, isEmptyManaOverride(next) ? null : next, cards, table);
|
|
51556
|
+
cards = split.cards;
|
|
51557
|
+
table = split.table;
|
|
51558
|
+
}
|
|
51559
|
+
if (e.tutor) {
|
|
51560
|
+
const next = { ...tutors[e.oracleId] ?? {}, ...e.tutor };
|
|
51561
|
+
tutors = withTutorRead(tutors, e.oracleId, isEmptyTutorOverride(next) ? null : next);
|
|
51562
|
+
}
|
|
51563
|
+
}
|
|
51564
|
+
return { cards, table, tutors };
|
|
51565
|
+
}
|
|
50379
51566
|
|
|
50380
51567
|
// src/plan.ts
|
|
50381
51568
|
init_tableGuesses();
|
|
@@ -50462,8 +51649,13 @@ function planModel(deckId, stored, catalog, lib, given) {
|
|
|
50462
51649
|
const cards = [...pool.values()].sort((a, b) => a.card.name.localeCompare(b.card.name));
|
|
50463
51650
|
const saved = validPlans(lib?.oddsPlans)[deckId] ?? null;
|
|
50464
51651
|
const game = savedPlanGame(saved);
|
|
50465
|
-
const
|
|
50466
|
-
const
|
|
51652
|
+
const edits = (given?.reads ?? []).map((r) => readEdit(r, catalog, zone, deck));
|
|
51653
|
+
const reads = applyReadEdits(
|
|
51654
|
+
{ cards: validManaOverrides(lib?.manaReads), table: game.table, tutors: validTutorOverrides(lib?.tutorReads) },
|
|
51655
|
+
edits.map((e) => e.edit)
|
|
51656
|
+
);
|
|
51657
|
+
const overrides = layerTable(reads.cards, reads.table);
|
|
51658
|
+
const tutorOv = reads.tutors;
|
|
50467
51659
|
const ctx = planContext({ deck, commanders, cards, oracle: catalog.oracle, otagIndex: catalog.otags(), overrides, tutorOv });
|
|
50468
51660
|
const cats = normalizeV2Categories(stored.v2Categories);
|
|
50469
51661
|
const pOf = (oid) => primaryOf(cats, oid);
|
|
@@ -50484,7 +51676,28 @@ function planModel(deckId, stored, catalog, lib, given) {
|
|
|
50484
51676
|
input: built.simInput,
|
|
50485
51677
|
labels: new Map(resolved.map(({ row, x }) => [row.key, x.label])),
|
|
50486
51678
|
slotOf: built.slotOf,
|
|
50487
|
-
tutorNames: built.tutorNames
|
|
51679
|
+
tutorNames: built.tutorNames,
|
|
51680
|
+
assumptions: planAssumptionsFor({ ctx, overrides, tutorOv, rows, rowTutors: built.rowTutors }),
|
|
51681
|
+
whatIf: edits.map((e) => e.shown)
|
|
51682
|
+
};
|
|
51683
|
+
}
|
|
51684
|
+
function readEdit(r, catalog, zone, deck) {
|
|
51685
|
+
const c = zone.find((z2) => z2.name.toLowerCase() === r.card.toLowerCase()) ?? deck.find((d) => d.name.toLowerCase() === r.card.toLowerCase()) ?? resolveCardName(catalog.index, r.card);
|
|
51686
|
+
if (!c) throw new PlanProblem(`No card named "${r.card}".`);
|
|
51687
|
+
if (!zone.includes(c) && !deck.some((d) => d.oracleId === c.oracleId)) throw new PlanProblem(`${c.name} isn't in this deck.`);
|
|
51688
|
+
const check2 = (what, raw, valid) => {
|
|
51689
|
+
if (!raw) return void 0;
|
|
51690
|
+
const kept = valid({ [c.oracleId]: raw })[c.oracleId] ?? {};
|
|
51691
|
+
const dropped = Object.keys(raw).filter((k) => !(k in kept));
|
|
51692
|
+
if (dropped.length) throw new PlanProblem(`${c.name}: the ${what} read has no field ${dropped.map((k) => `"${k}"`).join(", ")}, or its value isn't one the app takes.`);
|
|
51693
|
+
return kept;
|
|
51694
|
+
};
|
|
51695
|
+
const mana = check2("mana", r.mana, validManaOverrides);
|
|
51696
|
+
const tutor = check2("tutor", r.tutor, validTutorOverrides);
|
|
51697
|
+
if (!mana && !tutor) throw new PlanProblem(`${c.name}: say what to set, in mana or tutor.`);
|
|
51698
|
+
return {
|
|
51699
|
+
edit: { oracleId: c.oracleId, ...mana ? { mana } : {}, ...tutor ? { tutor } : {} },
|
|
51700
|
+
shown: { card: c.name, ...mana ? { mana } : {}, ...tutor ? { tutor } : {} }
|
|
50488
51701
|
};
|
|
50489
51702
|
}
|
|
50490
51703
|
function definedOnly(o) {
|
|
@@ -50493,6 +51706,10 @@ function definedOnly(o) {
|
|
|
50493
51706
|
function rowFrom(r, key, tags, catalog, zone) {
|
|
50494
51707
|
if (!Number.isInteger(r.byTurn) || r.byTurn < 1 || r.byTurn > 10) throw new PlanProblem("byTurn is a turn from 1 to 10.");
|
|
50495
51708
|
let source;
|
|
51709
|
+
if (r.count) {
|
|
51710
|
+
if (!isCountKind(r.count)) throw new PlanProblem(`count is one of hand, lands, treasures, creatures, mana.`);
|
|
51711
|
+
return { key, source: { kind: "count", what: r.count }, atLeast: Math.max(0, Math.floor(r.atLeast ?? 1)), byTurn: r.byTurn, mode: "have", tutorsOff: [] };
|
|
51712
|
+
}
|
|
50496
51713
|
if (r.cards?.length) {
|
|
50497
51714
|
const picked = r.cards.map((n) => {
|
|
50498
51715
|
const c = zone.find((z2) => z2.name.toLowerCase() === n.toLowerCase()) ?? resolveCardName(catalog.index, n);
|
|
@@ -50510,18 +51727,24 @@ function rowFrom(r, key, tags, catalog, zone) {
|
|
|
50510
51727
|
const names = [...BUILT_IN.values(), ...tags.map((t) => t.name)];
|
|
50511
51728
|
throw new PlanProblem(`No group "${r.group}". This deck has: ${names.join(", ")}.`);
|
|
50512
51729
|
}
|
|
50513
|
-
} else throw new PlanProblem("A row needs cards or a
|
|
51730
|
+
} else throw new PlanProblem("A row needs cards, a group, or a count.");
|
|
50514
51731
|
return { key, source, atLeast: Math.max(1, Math.floor(r.atLeast ?? 1)), byTurn: r.byTurn, mode: r.mode ?? "have", tutorsOff: [] };
|
|
50515
51732
|
}
|
|
50516
51733
|
function runPlan(m) {
|
|
50517
51734
|
return simulatePlan(m.input.deckSize, m.input.reqs, m.input.opts);
|
|
50518
51735
|
}
|
|
50519
51736
|
var pct = (p) => `${Math.round(p * 1e3) / 10}%`;
|
|
51737
|
+
function assumptionList(list, cap2 = MAX_ASSUMED) {
|
|
51738
|
+
const byKind = /* @__PURE__ */ new Map();
|
|
51739
|
+
for (const a of list) byKind.set(a.kind, [...byKind.get(a.kind) ?? [], a.name]);
|
|
51740
|
+
return [...byKind].slice(0, cap2).map(([kind, cards]) => ({ about: ASSUMPTION_LABEL[kind].title, cards, whatToCheck: ASSUMPTION_LABEL[kind].hint }));
|
|
51741
|
+
}
|
|
51742
|
+
var MAX_ASSUMED = 40;
|
|
50520
51743
|
function planAnswer(m, r, withCurve) {
|
|
50521
51744
|
const rows = m.rows.map((row) => {
|
|
50522
51745
|
const slot = m.slotOf.get(row.key);
|
|
50523
51746
|
const label = m.labels.get(row.key) ?? "?";
|
|
50524
|
-
const ask = `${row.atLeast} of ${label} by turn ${row.byTurn} (${row.mode === "play" ? "cast" : row.mode === "graveyard" ? "in graveyard" : "in hand"})`;
|
|
51747
|
+
const ask = row.source.kind === "count" ? `at least ${row.atLeast} ${label} by turn ${row.byTurn}` : `${row.atLeast} of ${label} by turn ${row.byTurn} (${row.mode === "play" ? "cast" : row.mode === "graveyard" ? "in graveyard" : "in hand"})`;
|
|
50525
51748
|
if (slot === void 0) return { row: ask, chance: null, note: "No cards here yet, so it sits out." };
|
|
50526
51749
|
const why = Object.entries(r.why[slot] ?? {}).filter(([, p]) => p >= 5e-3).sort((a, b) => b[1] - a[1]).map(([k, p]) => `${MISS_LABEL[k].text} ${pct(p)}`);
|
|
50527
51750
|
return {
|
|
@@ -50535,6 +51758,7 @@ function planAnswer(m, r, withCurve) {
|
|
|
50535
51758
|
const need = m.settings.need;
|
|
50536
51759
|
return {
|
|
50537
51760
|
plan: m.from,
|
|
51761
|
+
...m.whatIf.length ? { whatIf: { label: "what-if, not saved", reads: m.whatIf } } : {},
|
|
50538
51762
|
together: { chance: pct(r.all), means: need && need < m.rows.length ? `at least ${need} of the rows` : "every row in the same game", ...withCurve ? { byTurn: r.curve.all.map(pct) } : {} },
|
|
50539
51763
|
rows,
|
|
50540
51764
|
...bottleneck ? { mostOftenTheOnlyMiss: m.labels.get(bottleneck.key) } : {},
|
|
@@ -50549,7 +51773,8 @@ function planAnswer(m, r, withCurve) {
|
|
|
50549
51773
|
countTutors: m.settings.useTutors,
|
|
50550
51774
|
games: r.trials
|
|
50551
51775
|
},
|
|
50552
|
-
...m.tutorNames.length ? { tutorsCounted: m.tutorNames.slice(0, 20) } : {}
|
|
51776
|
+
...m.tutorNames.length ? { tutorsCounted: m.tutorNames.slice(0, 20) } : {},
|
|
51777
|
+
...m.assumptions.length ? { weAssume: assumptionList(m.assumptions) } : {}
|
|
50553
51778
|
};
|
|
50554
51779
|
}
|
|
50555
51780
|
|
|
@@ -50724,6 +51949,42 @@ var getDeck = {
|
|
|
50724
51949
|
}
|
|
50725
51950
|
};
|
|
50726
51951
|
var MAX_ROWS = 200;
|
|
51952
|
+
async function ownership(ctx, catalog, refresh) {
|
|
51953
|
+
const stacks = await ctx.library.collection(refresh);
|
|
51954
|
+
const lib = await ctx.library.library();
|
|
51955
|
+
const decks = await ctx.library.decks();
|
|
51956
|
+
const owned = /* @__PURE__ */ new Map();
|
|
51957
|
+
for (const s of stacks) {
|
|
51958
|
+
const card = resolveCardName(catalog.index, s.name);
|
|
51959
|
+
if (!card) continue;
|
|
51960
|
+
const row = owned.get(card.oracleId);
|
|
51961
|
+
if (row) row.stacks.push(s);
|
|
51962
|
+
else owned.set(card.oracleId, { card, stacks: [s] });
|
|
51963
|
+
}
|
|
51964
|
+
const binders = lib?.binders;
|
|
51965
|
+
const wishlist = new Set((lib?.wishlist ?? []).map((w) => w.name));
|
|
51966
|
+
const usedIn = /* @__PURE__ */ new Map();
|
|
51967
|
+
for (const [id, raw] of decks) {
|
|
51968
|
+
const stored = asDeck(raw);
|
|
51969
|
+
const name = viewDeck(id, stored, null).name;
|
|
51970
|
+
for (const oid of stored.assignments?.keys() ?? []) usedIn.set(oid, [...usedIn.get(oid) ?? [], name]);
|
|
51971
|
+
}
|
|
51972
|
+
return {
|
|
51973
|
+
owned,
|
|
51974
|
+
row(oracleId, detail) {
|
|
51975
|
+
const own2 = owned.get(oracleId);
|
|
51976
|
+
const name = own2?.card.name ?? catalog.index.byOracleId.get(oracleId)?.name;
|
|
51977
|
+
const inBinders = (binders?.binders ?? []).filter((b) => binders?.membership?.[b.id]?.includes(oracleId)).map((b) => b.name);
|
|
51978
|
+
return {
|
|
51979
|
+
owned: own2?.stacks.reduce((n, s) => n + s.quantity, 0) ?? 0,
|
|
51980
|
+
...detail !== "summary" && own2 ? { printings: own2.stacks.map((s) => `${s.quantity} ${s.set ?? "?"} ${s.collectorNumber ?? ""}${s.foil ? " foil" : ""}`.trim()) } : {},
|
|
51981
|
+
...inBinders.length ? { binders: inBinders } : {},
|
|
51982
|
+
...usedIn.get(oracleId)?.length ? { decks: usedIn.get(oracleId).slice(0, 10) } : {},
|
|
51983
|
+
...name && wishlist.has(name) ? { wishlist: true } : {}
|
|
51984
|
+
};
|
|
51985
|
+
}
|
|
51986
|
+
};
|
|
51987
|
+
}
|
|
50727
51988
|
var collectionLookup = {
|
|
50728
51989
|
name: "collection_lookup",
|
|
50729
51990
|
description: "What the user owns of some cards: quantity, printings, binders, which decks use it, whether it's on the wishlist. Give names, a search query, or a deck.",
|
|
@@ -50743,25 +52004,18 @@ var collectionLookup = {
|
|
|
50743
52004
|
throw new ToolProblem("Give exactly one of names, query or deck. The whole collection isn't returned at once.");
|
|
50744
52005
|
}
|
|
50745
52006
|
const catalog = await ctx.catalog();
|
|
50746
|
-
const
|
|
50747
|
-
const lib = await ctx.library.library();
|
|
52007
|
+
const own2 = await ownership(ctx, catalog, args.refresh === true);
|
|
50748
52008
|
const decks = await ctx.library.decks();
|
|
50749
|
-
const owned = /* @__PURE__ */ new Map();
|
|
50750
|
-
for (const s of stacks) {
|
|
50751
|
-
const card = resolveCardName(catalog.index, s.name);
|
|
50752
|
-
if (!card) continue;
|
|
50753
|
-
const row = owned.get(card.oracleId);
|
|
50754
|
-
if (row) row.stacks.push(s);
|
|
50755
|
-
else owned.set(card.oracleId, { card, stacks: [s] });
|
|
50756
|
-
}
|
|
50757
52009
|
let wanted;
|
|
50758
52010
|
if (names) {
|
|
50759
52011
|
wanted = names.map((n) => ({ card: resolveCardName(catalog.index, n), asked: n }));
|
|
50760
52012
|
} else if (query) {
|
|
50761
52013
|
const unsupported = catalog.unsupported(query);
|
|
50762
52014
|
if (unsupported.length) throw new ToolProblem(`Can't search for: ${unsupported.join(", ")}.`);
|
|
52015
|
+
const notes = catalog.notes(query);
|
|
52016
|
+
if (notes.length) throw new ToolProblem(notes.join(" "));
|
|
50763
52017
|
const hits = new Set(catalog.search(query).map((c) => c.oracleId));
|
|
50764
|
-
wanted = [...owned.values()].filter((o) => hits.has(o.card.oracleId)).map((o) => ({ card: o.card, asked: o.card.name }));
|
|
52018
|
+
wanted = [...own2.owned.values()].filter((o) => hits.has(o.card.oracleId)).map((o) => ({ card: o.card, asked: o.card.name }));
|
|
50765
52019
|
} else {
|
|
50766
52020
|
const [id, raw] = findDeck(deckArg, decks);
|
|
50767
52021
|
const v = viewDeck(id, asDeck(raw), catalog);
|
|
@@ -50769,29 +52023,9 @@ var collectionLookup = {
|
|
|
50769
52023
|
(card) => ({ card, asked: card.name })
|
|
50770
52024
|
);
|
|
50771
52025
|
}
|
|
50772
|
-
const binders = lib?.binders;
|
|
50773
|
-
const wishlist = new Set((lib?.wishlist ?? []).map((w) => w.name));
|
|
50774
|
-
const usedIn = /* @__PURE__ */ new Map();
|
|
50775
|
-
for (const [id, raw] of decks) {
|
|
50776
|
-
const stored = asDeck(raw);
|
|
50777
|
-
const name = viewDeck(id, stored, null).name;
|
|
50778
|
-
for (const oid of stored.assignments?.keys() ?? []) usedIn.set(oid, [...usedIn.get(oid) ?? [], name]);
|
|
50779
|
-
}
|
|
50780
52026
|
const detail = detailOf(args);
|
|
50781
52027
|
const offset = typeof args.offset === "number" ? args.offset : 0;
|
|
50782
|
-
const rows = wanted.slice(offset, offset + MAX_ROWS).map(({ card, asked }) => {
|
|
50783
|
-
if (!card) return { name: asked, unknownCard: true };
|
|
50784
|
-
const own2 = owned.get(card.oracleId);
|
|
50785
|
-
const inBinders = (binders?.binders ?? []).filter((b) => binders?.membership?.[b.id]?.includes(card.oracleId)).map((b) => b.name);
|
|
50786
|
-
return {
|
|
50787
|
-
name: card.name,
|
|
50788
|
-
owned: own2?.stacks.reduce((n, s) => n + s.quantity, 0) ?? 0,
|
|
50789
|
-
...detail !== "summary" && own2 ? { printings: own2.stacks.map((s) => `${s.quantity} ${s.set ?? "?"} ${s.collectorNumber ?? ""}${s.foil ? " foil" : ""}`.trim()) } : {},
|
|
50790
|
-
...inBinders.length ? { binders: inBinders } : {},
|
|
50791
|
-
...usedIn.get(card.oracleId)?.length ? { decks: usedIn.get(card.oracleId).slice(0, 10) } : {},
|
|
50792
|
-
...wishlist.has(card.name) ? { wishlist: true } : {}
|
|
50793
|
-
};
|
|
50794
|
-
});
|
|
52028
|
+
const rows = wanted.slice(offset, offset + MAX_ROWS).map(({ card, asked }) => card ? { name: card.name, ...own2.row(card.oracleId, detail) } : { name: asked, unknownCard: true });
|
|
50795
52029
|
return json2({
|
|
50796
52030
|
rows,
|
|
50797
52031
|
total: wanted.length,
|
|
@@ -50801,9 +52035,11 @@ var collectionLookup = {
|
|
|
50801
52035
|
}
|
|
50802
52036
|
};
|
|
50803
52037
|
var MAX_SEARCH = 50;
|
|
52038
|
+
var MAX_TAGS_SUMMARY = 12;
|
|
52039
|
+
var SCRYFALL_CREDIT = "Card data and tags from Scryfall (scryfall.com).";
|
|
50804
52040
|
var cardSearch = {
|
|
50805
52041
|
name: "card_search",
|
|
50806
|
-
description: "Search every Magic card with EDHVault's Scryfall-style syntax, for example `t:creature id<=gb cmc<=3`. Needs no access code.",
|
|
52042
|
+
description: "Search every Magic card with EDHVault's Scryfall-style syntax, for example `t:creature id<=gb cmc<=3`, `otag:mana-rock`, `set:cmm`, `is:foil`. Each result has its roles and Scryfall tags. Needs no access code.",
|
|
50807
52043
|
input: {
|
|
50808
52044
|
query: external_exports.string().min(1).describe("The search."),
|
|
50809
52045
|
limit: external_exports.number().int().min(1).max(MAX_SEARCH).optional().describe("At most this many, default 20."),
|
|
@@ -50813,22 +52049,34 @@ var cardSearch = {
|
|
|
50813
52049
|
const query = String(args.query);
|
|
50814
52050
|
const catalog = await ctx.catalog();
|
|
50815
52051
|
const unsupported = catalog.unsupported(query);
|
|
52052
|
+
const notes = catalog.notes(query);
|
|
50816
52053
|
const hits = catalog.search(query);
|
|
50817
|
-
if (
|
|
52054
|
+
if (hits.length === 0 && (unsupported.length || notes.length)) {
|
|
52055
|
+
throw new ToolProblem([unsupported.length ? `Can't search for: ${unsupported.join(", ")}.` : "", ...notes].filter(Boolean).join(" "));
|
|
52056
|
+
}
|
|
50818
52057
|
const detail = detailOf(args);
|
|
50819
52058
|
const limit = typeof args.limit === "number" ? args.limit : 20;
|
|
50820
52059
|
return json2({
|
|
50821
52060
|
total: hits.length,
|
|
50822
|
-
cards: hits.slice(0, limit).map((c) =>
|
|
50823
|
-
|
|
50824
|
-
|
|
50825
|
-
|
|
50826
|
-
|
|
50827
|
-
|
|
50828
|
-
|
|
50829
|
-
|
|
50830
|
-
|
|
52061
|
+
cards: hits.slice(0, limit).map((c) => {
|
|
52062
|
+
const tags = catalog.tagsOf(c.oracleId);
|
|
52063
|
+
const shown = detail === "summary" ? tags.slice(0, MAX_TAGS_SUMMARY) : tags;
|
|
52064
|
+
return {
|
|
52065
|
+
name: c.name,
|
|
52066
|
+
cost: c.manaCost,
|
|
52067
|
+
type: c.typeLine,
|
|
52068
|
+
commanderLegal: c.commanderLegal,
|
|
52069
|
+
priceUsd: c.priceUsd,
|
|
52070
|
+
...c.roles.length ? { roles: c.roles } : {},
|
|
52071
|
+
...shown.length ? { tags: shown } : {},
|
|
52072
|
+
...tags.length > shown.length ? { moreTags: tags.length - shown.length } : {},
|
|
52073
|
+
...detail !== "summary" ? { text: catalog.oracle(c.oracleId) } : {},
|
|
52074
|
+
...detail === "full" ? { identity: c.colors, cmc: c.cmc, rarity: c.rarity } : {}
|
|
52075
|
+
};
|
|
52076
|
+
}),
|
|
50831
52077
|
...unsupported.length ? { ignored: unsupported } : {},
|
|
52078
|
+
...notes.length ? { notes } : {},
|
|
52079
|
+
credit: SCRYFALL_CREDIT,
|
|
50832
52080
|
...staleNote(catalog)
|
|
50833
52081
|
});
|
|
50834
52082
|
}
|
|
@@ -50888,13 +52136,21 @@ var deckCombos2 = {
|
|
|
50888
52136
|
var rowInput = external_exports.object({
|
|
50889
52137
|
cards: external_exports.array(external_exports.string()).max(30).optional().describe("These cards (names). A commander counts from the command zone."),
|
|
50890
52138
|
group: external_exports.string().optional().describe("Or a group: Lands, Creatures, Mana creatures, Ramp, Card draw, Removal, Board wipes, Tutors, or one of the deck's tags."),
|
|
50891
|
-
|
|
52139
|
+
count: external_exports.enum(["hand", "lands", "treasures", "creatures", "mana"]).optional().describe("Or a count: cards in hand, lands on the battlefield, Treasure held, creatures out, or mana made that turn. atLeast is the number."),
|
|
52140
|
+
atLeast: external_exports.number().int().min(0).max(99).optional().describe("How many of them (or the count to reach). Default 1."),
|
|
50892
52141
|
byTurn: external_exports.number().int().min(1).max(10).describe("By this turn."),
|
|
50893
52142
|
mode: external_exports.enum(["have", "play"]).optional().describe("have: in hand (default). play: cast, with the mana counted.")
|
|
50894
52143
|
});
|
|
52144
|
+
var readInput = external_exports.object({
|
|
52145
|
+
card: external_exports.string().describe("A card in this deck, by name."),
|
|
52146
|
+
mana: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
|
|
52147
|
+
`Fields of its mana read to set, as the Odds tab's edit sheet has them. Common: makes ("G", "WUBRG"), cost, draws, treasures, drawsPerOpponent, drawsPerRound / treasuresPerRound ([{ from: turn, cards: n }]), rampLands ({ n, tapped }), ignored (true).`
|
|
52148
|
+
),
|
|
52149
|
+
tutor: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe('Fields of its tutor read: finds (a search, like "t:creature mv<=2"), to (hand, top, battlefield, graveyard), cost, off (true: not a tutor), added (true: count it as one).')
|
|
52150
|
+
});
|
|
50895
52151
|
var planOdds = {
|
|
50896
52152
|
name: "plan_odds",
|
|
50897
|
-
description: "Odds a deck's plan comes together by turn N, from the same 20,000 seeded games as the Odds tab's Plan by turn: the deck's saved plan, or rows you give. Counts the user's own card reads and tutors.",
|
|
52153
|
+
description: "Odds a deck's plan comes together by turn N, from the same 20,000 seeded games as the Odds tab's Plan by turn: the deck's saved plan, or rows you give. Counts the user's own card reads and tutors, and lists what it had to assume (weAssume). `reads` tries card reads for this run only (what-if, not saved), and the answer also gives the odds with the user's own reads.",
|
|
50898
52154
|
input: {
|
|
50899
52155
|
deck: external_exports.string().describe("Deck id, or its name."),
|
|
50900
52156
|
rows: external_exports.array(rowInput).max(8).optional().describe("Rows to ask about instead of the deck's saved plan."),
|
|
@@ -50903,13 +52159,14 @@ var planOdds = {
|
|
|
50903
52159
|
countTutors: external_exports.boolean().optional().describe("Let tutors fetch missing pieces (default yes)."),
|
|
50904
52160
|
opponents: external_exports.number().int().min(1).max(9).optional().describe("Opponents at the table."),
|
|
50905
52161
|
curve: external_exports.boolean().optional().describe("Also give the odds turn by turn, 1 to 10."),
|
|
52162
|
+
reads: external_exports.array(readInput).max(20).optional().describe("Card reads to try for this run only. Nothing is saved."),
|
|
50906
52163
|
refresh: refreshInput
|
|
50907
52164
|
},
|
|
50908
52165
|
async run(args, ctx) {
|
|
50909
52166
|
const [id, raw] = findDeck(String(args.deck), await ctx.library.decks(args.refresh === true));
|
|
50910
52167
|
const catalog = await ctx.catalog();
|
|
50911
52168
|
const lib = await ctx.library.library();
|
|
50912
|
-
const
|
|
52169
|
+
const given = {
|
|
50913
52170
|
...Array.isArray(args.rows) ? { rows: args.rows } : {},
|
|
50914
52171
|
settings: {
|
|
50915
52172
|
...typeof args.onTheDraw === "boolean" ? { onDraw: args.onTheDraw } : {},
|
|
@@ -50917,11 +52174,201 @@ var planOdds = {
|
|
|
50917
52174
|
...typeof args.countTutors === "boolean" ? { useTutors: args.countTutors } : {},
|
|
50918
52175
|
...typeof args.opponents === "number" ? { opponents: args.opponents } : {}
|
|
50919
52176
|
}
|
|
52177
|
+
};
|
|
52178
|
+
const reads = Array.isArray(args.reads) ? args.reads : [];
|
|
52179
|
+
const m = planModel(id, asDeck(raw), catalog, lib, { ...given, reads });
|
|
52180
|
+
const answer = planAnswer(m, runPlan(m), args.curve === true);
|
|
52181
|
+
const yours = reads.length ? runPlan(planModel(id, asDeck(raw), catalog, lib, given)) : null;
|
|
52182
|
+
return json2({
|
|
52183
|
+
deck: viewDeck(id, asDeck(raw), null).name,
|
|
52184
|
+
...answer,
|
|
52185
|
+
...yours ? { withYourReads: { together: `${Math.round(yours.all * 1e3) / 10}%` } } : {},
|
|
52186
|
+
...staleNote(catalog)
|
|
52187
|
+
});
|
|
52188
|
+
}
|
|
52189
|
+
};
|
|
52190
|
+
var cents = (n) => Math.round(n * 100) / 100;
|
|
52191
|
+
var day = (iso) => iso.slice(0, 10);
|
|
52192
|
+
function changes(windows) {
|
|
52193
|
+
const out = {};
|
|
52194
|
+
for (const w of TREND_WINDOWS) {
|
|
52195
|
+
const t = windows[w];
|
|
52196
|
+
if (t) out[w] = { usd: cents(t.delta), pct: Math.round(t.pct * 1e3) / 10, since: day(t.asOf) };
|
|
52197
|
+
}
|
|
52198
|
+
return out;
|
|
52199
|
+
}
|
|
52200
|
+
function printingChanges(file3, set2, number4, usd, foil) {
|
|
52201
|
+
const out = {};
|
|
52202
|
+
for (const [isFoil, now] of [[false, usd], [true, foil]]) {
|
|
52203
|
+
const w = printingTrendWindows(file3, set2, number4, isFoil, now ?? void 0);
|
|
52204
|
+
for (const k of TREND_WINDOWS) {
|
|
52205
|
+
const d = w[k]?.delta;
|
|
52206
|
+
if (d) out[`${k}${isFoil ? "Foil" : ""}`] = cents(d);
|
|
52207
|
+
}
|
|
52208
|
+
}
|
|
52209
|
+
return out;
|
|
52210
|
+
}
|
|
52211
|
+
var MAX_PRINTINGS = { summary: 5, standard: 30, full: 500 };
|
|
52212
|
+
var MAX_CARD_COMBOS = { summary: 5, standard: 15, full: 40 };
|
|
52213
|
+
async function part(missing, what, load) {
|
|
52214
|
+
if (!load) {
|
|
52215
|
+
missing.push(what);
|
|
52216
|
+
return null;
|
|
52217
|
+
}
|
|
52218
|
+
try {
|
|
52219
|
+
return await load();
|
|
52220
|
+
} catch {
|
|
52221
|
+
missing.push(what);
|
|
52222
|
+
return null;
|
|
52223
|
+
}
|
|
52224
|
+
}
|
|
52225
|
+
var cardTool = {
|
|
52226
|
+
name: "get_card",
|
|
52227
|
+
description: "Everything EDHVault knows about one card: rules text, Commander legality, Game Changer, roles and every Scryfall tag, today's price and its 1/7/30-day change, every printing with its prices, its land cycle, the combos it's in, and (with an access code) what the user owns of it and which decks use it. `comboSteps` adds how each combo works (the first time, a ~57 MB download). Needs no access code.",
|
|
52228
|
+
input: {
|
|
52229
|
+
name: external_exports.string().min(1).describe("The card's name."),
|
|
52230
|
+
detail: detailInput,
|
|
52231
|
+
comboSteps: external_exports.boolean().optional().describe("Add each combo's steps, mana needed and notes."),
|
|
52232
|
+
refresh: refreshInput
|
|
52233
|
+
},
|
|
52234
|
+
async run(args, ctx) {
|
|
52235
|
+
const catalog = await ctx.catalog();
|
|
52236
|
+
const asked = String(args.name);
|
|
52237
|
+
const c = resolveCardName(catalog.index, asked);
|
|
52238
|
+
if (!c) {
|
|
52239
|
+
let near = [];
|
|
52240
|
+
try {
|
|
52241
|
+
near = catalog.search(asked).slice(0, 5).map((x2) => x2.name);
|
|
52242
|
+
} catch {
|
|
52243
|
+
}
|
|
52244
|
+
throw new ToolProblem(`No card named "${asked}".${near.length ? ` Close: ${near.join(", ")}.` : " card_search finds cards by part of a name."}`);
|
|
52245
|
+
}
|
|
52246
|
+
const detail = detailOf(args);
|
|
52247
|
+
const missing = [];
|
|
52248
|
+
const x = ctx.extras;
|
|
52249
|
+
const [prices, printings, trend, cycles, combos] = await Promise.all([
|
|
52250
|
+
part(missing, "today's prices", x?.prices),
|
|
52251
|
+
part(missing, "printings", x?.printings),
|
|
52252
|
+
part(missing, "printing price changes", x?.printingTrend),
|
|
52253
|
+
part(missing, "land cycles", x?.landCycles),
|
|
52254
|
+
part(missing, "combos", ctx.combos)
|
|
52255
|
+
]);
|
|
52256
|
+
const stepsWereOnDisk = x?.comboStepsOnDisk() ?? false;
|
|
52257
|
+
const steps = args.comboSteps === true && combos ? await part(missing, "combo steps", x?.comboDetail) : null;
|
|
52258
|
+
const tags = catalog.tagsOf(c.oracleId);
|
|
52259
|
+
const shownTags = detail === "summary" ? tags.slice(0, MAX_TAGS_SUMMARY) : tags;
|
|
52260
|
+
const tuple2 = prices?.byOid.get(c.oracleId);
|
|
52261
|
+
const all = printings ? hydrateOraclePrintings(printings.p[c.oracleId] ?? [], printings.pr[c.oracleId]) : [];
|
|
52262
|
+
const printingRows = all.slice(0, MAX_PRINTINGS[detail]).map((p) => {
|
|
52263
|
+
const moved = printingChanges(trend, p.set, p.collectorNumber, p.priceUsd, p.priceUsdFoil);
|
|
52264
|
+
return {
|
|
52265
|
+
set: p.set,
|
|
52266
|
+
setName: p.setName,
|
|
52267
|
+
number: p.collectorNumber,
|
|
52268
|
+
rarity: p.rarity,
|
|
52269
|
+
finishes: p.finishes,
|
|
52270
|
+
...p.treatment ? { treatment: p.treatment } : {},
|
|
52271
|
+
...p.releasedAt ? { released: p.releasedAt } : {},
|
|
52272
|
+
usd: p.priceUsd,
|
|
52273
|
+
...p.finishes.some((f) => f !== "nonfoil") ? { usdFoil: p.priceUsdFoil } : {},
|
|
52274
|
+
...Object.keys(moved).length ? { change: moved } : {}
|
|
52275
|
+
};
|
|
52276
|
+
});
|
|
52277
|
+
const priced = all.filter((p) => p.priceUsd != null).sort((a, b) => a.priceUsd - b.priceUsd);
|
|
52278
|
+
const cheapest = priced[0];
|
|
52279
|
+
const cycle = cycles?.find((cy) => cy.members.some((m) => m.oracleId === c.oracleId));
|
|
52280
|
+
let comboList = null;
|
|
52281
|
+
if (combos) {
|
|
52282
|
+
const r = buildCardComboResults(combos.index, c.oracleId, /* @__PURE__ */ new Set(), (oid) => catalog.index.byOracleId.get(oid), steps ?? void 0);
|
|
52283
|
+
comboList = [...r.included, ...r.almostIncluded].sort(byPopularity);
|
|
52284
|
+
}
|
|
52285
|
+
let yours;
|
|
52286
|
+
try {
|
|
52287
|
+
yours = (await ownership(ctx, catalog, args.refresh === true)).row(c.oracleId, detail === "summary" ? "standard" : detail);
|
|
52288
|
+
} catch (e) {
|
|
52289
|
+
if (!(e instanceof LibraryError)) throw e;
|
|
52290
|
+
if (e.kind !== "not-connected") missing.push(`what you own (${e.message})`);
|
|
52291
|
+
}
|
|
52292
|
+
const stale = [...catalog.stale ? ["the card catalog"] : [], ...x?.stale() ?? []];
|
|
52293
|
+
return json2({
|
|
52294
|
+
name: c.name,
|
|
52295
|
+
cost: c.manaCost,
|
|
52296
|
+
type: c.typeLine,
|
|
52297
|
+
// EDHVault hosts its search copy of the text for now; the printed wording
|
|
52298
|
+
// is baked next (the pipeline PR after this one).
|
|
52299
|
+
text: catalog.oracle(c.oracleId),
|
|
52300
|
+
textNote: "EDHVault's search copy of the rules text: lowercase, reminder text inline.",
|
|
52301
|
+
mv: c.cmc,
|
|
52302
|
+
identity: c.colors,
|
|
52303
|
+
...c.rarity ? { rarity: c.rarity } : {},
|
|
52304
|
+
...c.keywords?.length ? { keywords: c.keywords } : {},
|
|
52305
|
+
...c.producedMana?.length ? { makes: c.producedMana } : {},
|
|
52306
|
+
commander: {
|
|
52307
|
+
legal: c.commanderLegal,
|
|
52308
|
+
...isCardBanned(c) ? { banned: true } : {},
|
|
52309
|
+
...isCompanionBannedName(c.name) ? { bannedAsCompanion: true } : {},
|
|
52310
|
+
canBeCommander: c.canBeCommander,
|
|
52311
|
+
gameChanger: isGameChangerName(c.name)
|
|
52312
|
+
},
|
|
52313
|
+
...c.roles.length ? { roles: c.roles } : {},
|
|
52314
|
+
...shownTags.length ? { tags: shownTags } : {},
|
|
52315
|
+
...tags.length > shownTags.length ? { moreTags: tags.length - shownTags.length } : {},
|
|
52316
|
+
price: {
|
|
52317
|
+
usd: c.priceUsd ?? null,
|
|
52318
|
+
eur: c.priceEur ?? null,
|
|
52319
|
+
...tuple2 && prices ? { change: changes(cardTrendWindows(tuple2, prices.asOf)) } : {},
|
|
52320
|
+
asOf: catalog.pricedAt ? day(catalog.pricedAt) : "the weekly card data",
|
|
52321
|
+
of: "the cheapest regular printing, the price EDHVault totals decks with"
|
|
52322
|
+
},
|
|
52323
|
+
...printings ? {
|
|
52324
|
+
printings: {
|
|
52325
|
+
count: all.length,
|
|
52326
|
+
// The list is the weekly bake's; prices on it are today's. A
|
|
52327
|
+
// printing newer than the bake is priced but not listed yet.
|
|
52328
|
+
listedAsOf: day(printings.builtAt),
|
|
52329
|
+
...cheapest ? { cheapestListed: `${cheapest.setName} (${cheapest.set} ${cheapest.collectorNumber}) $${cheapest.priceUsd}` } : {},
|
|
52330
|
+
...cheapest && c.priceUsd != null && c.priceUsd < cheapest.priceUsd ? { note: `Today's card price ($${c.priceUsd}) is from a printing newer than this list, which updates weekly.` } : {},
|
|
52331
|
+
newestFirst: printingRows,
|
|
52332
|
+
...all.length > printingRows.length ? { more: all.length - printingRows.length } : {}
|
|
52333
|
+
}
|
|
52334
|
+
} : {},
|
|
52335
|
+
...cycle ? {
|
|
52336
|
+
landCycle: {
|
|
52337
|
+
name: cycle.displayName,
|
|
52338
|
+
about: cycle.blurb,
|
|
52339
|
+
members: cycle.members.map((m) => m.name),
|
|
52340
|
+
// Scryfall's own syntax (is:shockland), which card_search doesn't run.
|
|
52341
|
+
onScryfall: `https://scryfall.com/search?q=${encodeURIComponent(cycle.query)}`
|
|
52342
|
+
}
|
|
52343
|
+
} : {},
|
|
52344
|
+
...comboList ? {
|
|
52345
|
+
combos: {
|
|
52346
|
+
count: comboList.length,
|
|
52347
|
+
twoCardInfinites: countTwoCardInfiniteCombos(comboList),
|
|
52348
|
+
...steps && !stepsWereOnDisk ? { stepsNote: "Downloaded the combo steps (about 57 MB) this once; later asks read the copy on disk." } : {},
|
|
52349
|
+
...!steps && comboList.length ? {
|
|
52350
|
+
howTheyWork: stepsWereOnDisk ? "Ask again with comboSteps for each combo's steps." : "Ask again with comboSteps for each combo's steps. The first time downloads about 57 MB, kept on disk after."
|
|
52351
|
+
} : {},
|
|
52352
|
+
mostPopular: comboList.slice(0, MAX_CARD_COMBOS[detail]).map((v) => ({
|
|
52353
|
+
...comboRow(v, detail),
|
|
52354
|
+
...steps && v.description ? { steps: v.description } : {},
|
|
52355
|
+
...steps && v.manaNeeded ? { manaNeeded: v.manaNeeded } : {},
|
|
52356
|
+
...steps && v.notes ? { notes: v.notes } : {}
|
|
52357
|
+
}))
|
|
52358
|
+
}
|
|
52359
|
+
} : {},
|
|
52360
|
+
...yours ? { yours } : {},
|
|
52361
|
+
links: {
|
|
52362
|
+
scryfall: `https://scryfall.com/search?q=oracleid%3A${c.oracleId}`,
|
|
52363
|
+
edhrec: `https://edhrec.com/cards/${toEdhrecSlug(c.name)}`
|
|
52364
|
+
},
|
|
52365
|
+
...missing.length ? { couldntLoad: missing } : {},
|
|
52366
|
+
...stale.length ? { olderCopy: stale } : {},
|
|
52367
|
+
credit: [SCRYFALL_CREDIT, ...comboList?.length ? [COMBO_CREDIT] : []]
|
|
50920
52368
|
});
|
|
50921
|
-
return json2({ deck: viewDeck(id, asDeck(raw), null).name, ...planAnswer(m, runPlan(m), args.curve === true), ...staleNote(catalog) });
|
|
50922
52369
|
}
|
|
50923
52370
|
};
|
|
50924
|
-
var TOOLS = [listDecks, getDeck, collectionLookup, cardSearch, deckCombos2, planOdds];
|
|
52371
|
+
var TOOLS = [listDecks, getDeck, collectionLookup, cardSearch, cardTool, deckCombos2, planOdds];
|
|
50925
52372
|
|
|
50926
52373
|
// src/server.ts
|
|
50927
52374
|
async function serve(version2, ctx) {
|
|
@@ -50951,7 +52398,7 @@ var say = (m) => process.stderr.write(`${m}
|
|
|
50951
52398
|
var transport = {
|
|
50952
52399
|
fetchImpl: ((url2, init) => fetch(`${ORIGIN}${url2}`, {
|
|
50953
52400
|
...init,
|
|
50954
|
-
headers: { ...Object.fromEntries(new Headers(init?.headers)), "user-agent": `edhvault-mcp/${"0.2.
|
|
52401
|
+
headers: { ...Object.fromEntries(new Headers(init?.headers)), "user-agent": `edhvault-mcp/${"0.2.3"}` }
|
|
50955
52402
|
}))
|
|
50956
52403
|
};
|
|
50957
52404
|
async function store(dir) {
|
|
@@ -50967,11 +52414,11 @@ async function secretFromEnv() {
|
|
|
50967
52414
|
async function main() {
|
|
50968
52415
|
const args = process.argv.slice(2);
|
|
50969
52416
|
if (args.includes("--version")) {
|
|
50970
|
-
say("0.2.
|
|
52417
|
+
say("0.2.3");
|
|
50971
52418
|
return;
|
|
50972
52419
|
}
|
|
50973
52420
|
const dir = configDir();
|
|
50974
|
-
configureLog({ file:
|
|
52421
|
+
configureLog({ file: join9(dir, "edhvault-mcp.log"), debug: args.includes("--debug") });
|
|
50975
52422
|
const secrets = await store(dir);
|
|
50976
52423
|
if (args[0] === "login") {
|
|
50977
52424
|
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
@@ -50984,14 +52431,16 @@ async function main() {
|
|
|
50984
52431
|
}
|
|
50985
52432
|
if (args[0] === "logout") {
|
|
50986
52433
|
secrets.remove();
|
|
50987
|
-
rmSync4(
|
|
52434
|
+
rmSync4(join9(dir, "view"), { recursive: true, force: true });
|
|
50988
52435
|
say("Forgotten on this machine. To block the code everywhere, remove it in Settings.");
|
|
50989
52436
|
return;
|
|
50990
52437
|
}
|
|
50991
|
-
|
|
52438
|
+
const extras = extrasLoader({ dir, origin: ORIGIN });
|
|
52439
|
+
await serve("0.2.3", {
|
|
50992
52440
|
library: new Library({ secret: await secretFromEnv() ?? loadSecret(secrets), dir, transport }),
|
|
50993
|
-
catalog: catalogLoader({ dir, origin: ORIGIN }),
|
|
50994
|
-
combos: comboLoader({ dir, origin: ORIGIN })
|
|
52441
|
+
catalog: catalogLoader({ dir, origin: ORIGIN, prices: extras.prices }),
|
|
52442
|
+
combos: comboLoader({ dir, origin: ORIGIN }),
|
|
52443
|
+
extras
|
|
50995
52444
|
});
|
|
50996
52445
|
}
|
|
50997
52446
|
main().catch((e) => {
|