@champions-digital-game/mod-sdk 0.54.0 → 1.0.0
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 +3 -3
- package/dist/build.js +1 -1
- package/dist/chunks/{chunk-DX44O32N.js → chunk-MRZL7PHD.js} +1 -1
- package/dist/chunks/{chunk-S3JH4WL4.js → chunk-N2HMNYPQ.js} +1 -1
- package/dist/chunks/{chunk-ACT4TJXC.js → chunk-NHQRL3H2.js} +3 -3
- package/dist/chunks/{chunk-3SR23UJ7.js → chunk-PHTEP3BC.js} +1 -1
- package/dist/chunks/{chunk-WFEXO5DU.js → chunk-RBTO2IFX.js} +1 -1
- package/dist/chunks/chunk-SCRIASBU.js +1 -0
- package/dist/chunks/{chunk-7NRC6TLV.js → chunk-SG4DMEG6.js} +1 -1
- package/dist/import.js +1 -1
- package/dist/index.js +1 -1
- package/dist/mc-pack.js +2 -2
- package/dist/testing.js +1 -1
- package/package.json +1 -1
- package/types/cards/src/dsl/abilities.d.ts +6 -3
- package/types/cards/src/dsl/effects.d.ts +22 -2
- package/types/cards/src/dsl/values.d.ts +11 -0
- package/types/cards/src/index.d.ts +3 -2
- package/types/cards/src/testing/driver.d.ts +16 -1
- package/types/cards/src/wave10/competitive.d.ts +49 -0
- package/types/cards/src/wave10/cw/competitive/leader-cards.d.ts +5 -7
- package/types/cards/src/wave10/cw/competitive/standard-pvp.d.ts +3 -3
- package/types/cards/src/wave10/cw/leaders/captain-marvel.d.ts +4 -2
- package/types/cards/src/wave10/cw/modular/dangerous-recruits.d.ts +0 -29
- package/types/cards/src/wave10/cw/modular/secret-avengers.d.ts +3 -4
- package/types/cards/src/wave10/cw/modular/the-initiative.d.ts +0 -31
- package/types/cards/src/wave10/index.d.ts +2 -0
- package/types/cards/src/wave10/setup.d.ts +7 -0
- package/types/cards/src/wave10/synthezoid/competitive/leader-cards.d.ts +22 -11
- package/types/cards/src/wave9/index.d.ts +1 -1
- package/types/cards/src/wave9/setup.d.ts +20 -1
- package/types/content/src/index.d.ts +1 -1
- package/types/engine/src/actions.d.ts +5 -0
- package/types/engine/src/commands.d.ts +53 -1
- package/types/engine/src/competitive-outcome.d.ts +159 -0
- package/types/engine/src/competitive-setup.d.ts +73 -0
- package/types/engine/src/effects.d.ts +32 -6
- package/types/engine/src/errors.d.ts +18 -2
- package/types/engine/src/event-sides.d.ts +21 -0
- package/types/engine/src/events.d.ts +127 -3
- package/types/engine/src/flow.d.ts +1 -1
- package/types/engine/src/game-fingerprint.d.ts +2 -2
- package/types/engine/src/index.d.ts +12 -4
- package/types/engine/src/lasting.d.ts +6 -1
- package/types/engine/src/pod-commands.d.ts +81 -0
- package/types/engine/src/pod-coordinator.d.ts +136 -0
- package/types/engine/src/pod.d.ts +276 -2
- package/types/engine/src/query.d.ts +7 -0
- package/types/engine/src/resolve/pod.d.ts +67 -1
- package/types/engine/src/resolve/triggers.d.ts +11 -0
- package/types/engine/src/select.d.ts +27 -7
- package/types/engine/src/setup-steps.d.ts +8 -0
- package/types/engine/src/setup.d.ts +10 -2
- package/types/engine/src/spec.d.ts +83 -10
- package/types/engine/src/state.d.ts +120 -2
- package/types/engine/src/team-phases.d.ts +106 -0
- package/types/engine/src/team.d.ts +34 -0
- package/types/engine/src/trigger-events.d.ts +50 -3
- package/types/engine/src/villain/authority.d.ts +16 -3
- package/types/engine/src/villain-phase-begun.d.ts +24 -0
- package/dist/chunks/chunk-3YMCANI3.js +0 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @champions-digital-game/mod-sdk
|
|
2
2
|
|
|
3
3
|
The mod SDK for [Marvel Champions Digital](https://github.com/quincarter/marvel-champions-digital-game) content
|
|
4
|
-
packs, version 0.
|
|
4
|
+
packs, version 1.0.0: the pack schema, the ability DSL the game's own cards are written in, and the `mc-pack`
|
|
5
5
|
tool that validates, builds, tests and imports packs. It carries the game's rules engine, so `mc-pack test` plays
|
|
6
6
|
real headless games.
|
|
7
7
|
|
|
@@ -11,10 +11,10 @@ of Fantasy Flight Games and Marvel.
|
|
|
11
11
|
## Install
|
|
12
12
|
|
|
13
13
|
```sh
|
|
14
|
-
npm install --save-dev @champions-digital-game/mod-sdk@0.
|
|
14
|
+
npm install --save-dev @champions-digital-game/mod-sdk@1.0.0
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
The SDK is versioned with the game: a pack built with SDK 0.
|
|
17
|
+
The SDK is versioned with the game: a pack built with SDK 1.0.0 runs on app 1.0.0 and later. Every game
|
|
18
18
|
release also carries this package as a tarball, which installs the same way (`npm install --save-dev ./<file>.tgz`).
|
|
19
19
|
|
|
20
20
|
## A pack's source folder
|
package/dist/build.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PackBuildError,assemblePack,buildPack,loadPackSource,zipPack}from"./chunks/chunk-
|
|
1
|
+
import{PackBuildError,assemblePack,buildPack,loadPackSource,zipPack}from"./chunks/chunk-RBTO2IFX.js";import"./chunks/chunk-PHTEP3BC.js";import"./chunks/chunk-NHQRL3H2.js";export{PackBuildError,assemblePack,buildPack,loadPackSource,zipPack};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{assemblePack}from"./chunk-
|
|
1
|
+
import{assemblePack}from"./chunk-RBTO2IFX.js";import{abilityRefsOf,readPackInput,splitIssues,validatePack}from"./chunk-PHTEP3BC.js";import{PACK_KINDS,isLanguageTag,isPackId,packCardImagePath}from"./chunk-NHQRL3H2.js";import{copyFileSync,existsSync,mkdirSync,readFileSync,readdirSync,rmSync,writeFileSync}from"node:fs";import{basename,dirname,join}from"node:path";var isObj=value=>typeof value=="object"&&value!==null&&!Array.isArray(value),str=value=>typeof value=="string"&&value!==""?value:void 0,normalizer;function registerMarvelCdbNormalizer(normalize){normalizer=normalize}async function loadNormalizer(){if(normalizer)return normalizer;let module=await import(new URL("../../content/scripts/marvelcdb/normalize.ts",import.meta.url).href);if(typeof module.normalizePack!="function")throw new Error("the content package's normalizePack is missing");return normalizer=module.normalizePack}var kebab=text=>text.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),KIND_ALIASES=Object.fromEntries(PACK_KINDS.flatMap(kind=>[[kind,kind],[`${kind}_pack`,kind]]));function dataFileOf(srcDir,modId){let named=join(srcDir,`${modId}.json`);if(existsSync(named))return named;let others=readdirSync(srcDir).filter(name=>name.endsWith(".json")&&name!=="mod.json");if(others.length!==1)throw new Error(`${srcDir}: expected ${modId}.json (or one .json besides mod.json)`);return join(srcDir,others[0])}var tailOf=code=>{let match=/^(.*\d)([a-z])$/.exec(code);return match?{key:match[1],letter:match[2]}:{key:code,letter:""}};function planCodes(records,packId){let order=[],visit=record2=>{let code=str(record2.code);if(code===void 0)throw new Error("a card record has no code");order.push(code),isObj(record2.linked_card)&&visit(record2.linked_card)};records.forEach(visit);let numbers=new Map,out=new Map;for(let code of order){if(out.has(code))throw new Error(`card code ${code} appears twice`);let{key,letter}=tailOf(code);numbers.has(key)||numbers.set(key,numbers.size+1);let n=numbers.get(key);out.set(code,`x.${packId}.${String(n).padStart(numbers.size>99?3:2,"0")}${letter}`)}return out}function planSets(records,packId){let all=records.flatMap(r=>isObj(r.linked_card)?[r,r.linked_card]:[r]),heroSet=all.map(r=>r.type_code==="hero"?str(r.card_set_code):void 0).find(Boolean),out=new Map;for(let record2 of all){let set=str(record2.card_set_code);if(!(set===void 0||out.has(set)))if(set===heroSet)out.set(set,packId);else{let rest=heroSet!==void 0&&set.startsWith(`${heroSet}_`)?set.slice(heroSet.length+1):set;out.set(set,`${packId}-${kebab(rest)}`)}}let finals=[...out.values()];if(new Set(finals).size!==finals.length)throw new Error("two source sets map to the same encounter set id");return out}var escapeRegExp=text=>text.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function makeRewriter(map){let keys=[...map.keys()].sort((a,b)=>b.length-a.length).map(escapeRegExp),pattern=new RegExp(`(?<![A-Za-z0-9_])(?:${keys.join("|")})(?![A-Za-z0-9_])`,"g"),walk=node=>typeof node=="string"?node.replace(pattern,hit=>map.get(hit)??hit):Array.isArray(node)?node.map(walk):isObj(node)?Object.fromEntries(Object.entries(node).filter(([key])=>key!=="images"&&key!=="image").map(([key,child])=>[key,walk(child)])):node;return walk}var collectorOf=finalCode=>(/\.(\d+[a-z]?)$/.exec(finalCode)?.[1]??finalCode).replace(/^0+(?=\d)/,"").toUpperCase();function toSourceCodes(curation,finalToSource){let source=code=>finalToSource.get(code)??code,pattern=new RegExp(`^(${[...finalToSource.keys()].map(escapeRegExp).join("|")})(?=\\.|$)`),fixKeys=record2=>isObj(record2)?Object.fromEntries(Object.entries(record2).map(([key,value])=>[key.replace(pattern,m=>source(m)),value])):record2,fixCode=list=>Array.isArray(list)?list.map(e=>isObj(e)&&typeof e.code=="string"?{...e,code:source(e.code)}:e):list,out={...curation};for(let key of["corrections","errata","ignoredRecords"])key in out&&(out[key]=fixCode(out[key]));for(let key of["cardNotes","scriptingNotes"])key in out&&(out[key]=fixKeys(out[key]));return out}function markFlipSides(records,notes,codes){let IDENTITY_TYPES=new Set(["hero","alter_ego","villain","main_scheme"]);return records.map(record2=>{let back=record2.linked_card,type=record2.type_code;if(!isObj(back)||back.hidden!==void 0||IDENTITY_TYPES.has(type)||IDENTITY_TYPES.has(back.type_code))return record2;let code=str(back.code)??"?";return notes.push(`marked ${codes.get(code)??code} as the hidden flip side of ${str(record2.name)??"?"}, as the API does`),{...record2,linked_card:{...back,hidden:!0}}})}function dashCostCorrections(records,finalOf,skip){let found=[];for(let record2 of records){let code=str(record2.code);if(code===void 0||skip.has(code))continue;let noCost=record2.cost===void 0||record2.cost===null;if(record2.permanent!==!0||!noCost||record2.cost_per_hero===!0||record2.type_code!=="upgrade"&&record2.type_code!=="support")continue;let what=`${String(record2.name)}: a permanent ${String(record2.type_code)} with no cost in the source reads as a printed dash cost (cannot be played, enters play through its own text)`;found.push({correction:{code,reason:what,evidence:"pack importer: permanent card, no cost in the MarvelCDB-shaped record; check the card image",specialCost:"dash"},auto:{code,finalCode:finalOf(code),what}})}return found}var APPENDED=new Set(["corrections","errata","scenarios","starterDecks","separateDecks","ignoredRecords"]);function mergeCuration(base,extra){let out={...base};for(let[key,value]of Object.entries(extra)){let current=out[key];APPENDED.has(key)&&Array.isArray(current)&&Array.isArray(value)?out[key]=[...current,...value]:isObj(current)&&isObj(value)?out[key]={...current,...value}:out[key]=value}return out}function semverOf(text){let match=/^\s*v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?![\d.])/.exec(text);return match?`${match[1]}.${match[2]??"0"}.${match[3]??"0"}`:void 0}function readMod(srcDir){let mod=JSON.parse(readFileSync(join(srcDir,"mod.json"),"utf8"));if(!isObj(mod)||!str(mod.id)||!str(mod.name)||!str(mod.kind)||!str(mod.author))throw new Error(`${join(srcDir,"mod.json")}: needs id, name, kind and author`);return mod}var subDirs=dir=>existsSync(dir)?readdirSync(dir,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name):[];function mapPictures(srcDir,codes){let copies=[],missing=[],unmatched=[],languages=subDirs(join(srcDir,"images")).sort();for(let lang of languages){let dir=join(srcDir,"images",lang),present=new Set(readdirSync(dir));for(let[source,final]of codes)present.delete(`${source}.webp`)?copies.push({from:join(dir,`${source}.webp`),to:packCardImagePath(lang,final)}):missing.push(`${lang}/${source}`);unmatched.push(...[...present].sort().map(name=>`images/${lang}/${name}`))}let altArt={};for(let lang of subDirs(join(srcDir,"alt-art")).sort()){let dir=join(srcDir,"alt-art",lang);for(let name of readdirSync(dir).sort()){let match=/^(.+)\.webp$/.exec(name);if(!match){unmatched.push(`alt-art/${lang}/${name}`);continue}let stem=match[1],own=codes.get(stem.replace(/-alt$/,"")),code=own!==void 0&&stem.endsWith("-alt")?own:stem,to=`alt-art/${lang}/${code}.webp`;(altArt[lang]??={})[code]=to,copies.push({from:join(dir,name),to})}}return{copies,languages,missing,unmatched,altArt}}var bytesOf=path=>new Uint8Array(readFileSync(path));function creditsMarkdown(mod,packId,languages,base){let translators=Object.entries(mod.languages??{}).filter(([lang,who])=>lang!=="base"&&who!=="author");return["# Credits","",`${mod.name} (\`${packId}\`) is a fan-made pack by ${mod.author}.`,"",`- Card design and art direction: ${mod.author}.`,...mod.template?[`- Card template: ${mod.template}.`]:[],...translators.map(([lang,who])=>`- Translation and layout (${lang}): ${who}.`),`- Pictures: ${languages.join(", ")} (base language ${base}).`,...mod.version?[`- Source version: ${mod.version}.`]:[],"","The card data was converted from MarvelCDB-shaped records with the mod SDK's `importMarvelCdbPack`.","Character art is Marvel comics art, as used by each author.","","Marvel Champions: The Card Game is the property of Fantasy Flight Games and Marvel.",""].join(`
|
|
2
2
|
`)}function permissionMarkdown(mod,granted){let p=mod.permission??{};return["# Permission","",granted?`${mod.author}, the author of ${mod.name}, gave permission for this pack to be distributed through the mod store.`:`**Permission is not recorded as granted for this pack (status: ${p.status??"none"}). Do not publish it.**`,"",`- Status: ${p.status??"not recorded"}`,`- Scope: ${p.scope??"not recorded"}`,`- Date: ${p.date??"not recorded"}`,"","Recorded in the pack's draft `mod.json`. The registry review asks for the evidence (a link or a quoted message).",""].join(`
|
|
3
3
|
`)}function abilityFacesOf(card){let faces=[],walk=(node,title)=>{if(Array.isArray(node))return void node.forEach(n=>walk(n,title));if(!isObj(node))return;let ids=Array.isArray(node.abilities)?node.abilities.flatMap(a=>isObj(a)&&typeof a.id=="string"?[a.id]:[]):[],here=str(node.faceName)??str(node.name)??title;if(ids.length>0){let text=isObj(node.text)?str(node.text.printed)??"":"";faces.push({title:here,text,ids})}for(let[key,child]of Object.entries(node))key!=="abilities"&&key!=="text"&&walk(child,here)};return walk(card,card.name),faces}function abilitiesStub(cards,packName){let ids=[],blocks=[];for(let card of cards)for(let face of abilityFacesOf(card)){let fresh=face.ids.filter(id=>!ids.includes(id));if(fresh.length===0)continue;ids.push(...fresh);let text=face.text.split(`
|
|
4
4
|
`).map(line=>` // ${line}`);blocks.push([` // ${String(card.id)} ${face.title} (${card.type})`,...text,...fresh.map(id=>` // ${id}`)].join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{customModularSetChoices,playableScenarioWithCustom}from"./chunk-
|
|
1
|
+
import{customModularSetChoices,playableScenarioWithCustom}from"./chunk-NHQRL3H2.js";function gameDepsWithPack(base,pack){for(let id of Object.keys(pack.abilities))if(Object.hasOwn(base.abilities,id))throw new Error(`pack ability ${id} is already defined by the base game`);return{...base,abilities:{...base.abilities,...pack.abilities}}}function cardPoolWithPack(pool,pack){let known=new Set(pool.map(card=>card.id));for(let card of pack.cards)if(known.has(card.id))throw new Error(`pack card ${card.id} is already in the pool`);return[...pool,...pack.cards]}function gameDepsWithPacks(base,packs){return packs.reduce((deps,pack)=>gameDepsWithPack(deps,pack),base)}function packScenarioRecords(packs){return packs.flatMap(pack=>pack.scenarios??[])}function packEncounterSetRecords(packs){return packs.flatMap(pack=>pack.encounterSets??[])}function customContentOfPacks(packs){return{cards:packs.flatMap(pack=>pack.cards),encounterSets:packEncounterSetRecords(packs),scenarios:packScenarioRecords(packs)}}function packModularSetChoices(scenario,packs){return customModularSetChoices(scenario,customContentOfPacks(packs))}function scenarioWithPacks(scenarioId,options,packs){return playableScenarioWithCustom(scenarioId,options,customContentOfPacks(packs))}function packCampaignRecords(packs){return packs.flatMap(pack=>pack.campaigns??[])}function packCampaignDefinitionOf(packs,campaignId){return packCampaignRecords(packs).find(campaign=>campaign.id===campaignId)?.definition}function packCampaignDefinitions(packs){return Object.fromEntries(packCampaignRecords(packs).map(campaign=>[campaign.id,campaign.definition]))}function campaignDepsWithPacks(pool,packs){return{pool:cardPoolWithPacks(pool,packs)}}function cardPoolWithPacks(pool,packs){return packs.reduce((all,pack)=>cardPoolWithPack(all,pack),pool)}function campaignGameWithPacks(start,packs,options={}){if(start.scenarioId===null)throw new Error(`campaign node "${start.nodeId}" has no fixed scenario`);return{...scenarioWithPacks(start.scenarioId,{players:start.input.seats.map(seat=>({identityCardId:seat.identityCardId,deck:[...seat.deck],aspects:seat.aspects})),seed:start.input.seed,difficulty:options.difficulty??"standard",...options.modularSetIds?{modularSetIds:[...options.modularSetIds]}:{}},packs),campaign:start.input}}export{gameDepsWithPack,cardPoolWithPack,gameDepsWithPacks,packScenarioRecords,packEncounterSetRecords,customContentOfPacks,packModularSetChoices,scenarioWithPacks,packCampaignRecords,packCampaignDefinitionOf,packCampaignDefinitions,campaignDepsWithPacks,cardPoolWithPacks,campaignGameWithPacks};
|