Merge commit '4623930'; commit '067de83' into night2/ui-duel/engine-preview

This commit is contained in:
2026-11-17 23:29:20 -05:00
10 changed files with 172 additions and 33 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ Built by duel-cards (`derive()`), frozen by the host at match start. Shape agree
## Rules (defaults: `DEFAULT_DUEL_RULESET`; details in DUEL_DESIGN §2)
- 40-card decks (`deckSize`), ≤ 4 per `pageId`, unique `cardId`s, no tokens. 20 Notability. Drawing from an empty library loses (`libraryEmpty: 'lose'`; `'reshuffle'` and `'fatigue'` exist as data).
- Opening hand 7. Up to `mulligans` (1): shuffle in, draw 7, then on `keep` put one card per mulligan on the bottom (the last in hand order). Seat 0 decides first, then seat 1.
- First player (from the seed) skips their first draw.
- First player (from the seed) skips their first draw. Balance levers (data only): `firstPlayerDraws`, and `secondPlayerCitations` (extra Citations on the second player's first turn, default 0).
- **Turn:** refresh (base max +1 to 10, plus Territory ≤ 2; refill; untap; Pending review ends; Stub and `startOfTurn` triggers) → draw → **main** → **attack** → **block** → damage → end (damage and "until end of turn" clear; discard down to `handSize` 7, **highest cost first**, automatically).
- Locations: `locationsPerTurn` (1), can't attack. Garrison Locations (toughness > 0) block as 0-power.
- Combat: attack the opponent only; each blocker blocks one attacker, at most one blocker per attacker; simultaneous damage; destroy triggers after all combat damage. No trample, first strike, stack or instants.
+120 -22
View File
@@ -851,9 +851,14 @@
"trigger": "onPlay",
"op": "attach",
"target": "figure",
"template": "T12"
},
{
"trigger": "static",
"op": "pump",
"target": "attached",
"power": -3,
"toughness": -3,
"duration": "permanent",
"template": "T12"
}
],
@@ -943,15 +948,19 @@
"trigger": "onPlay",
"op": "attach",
"target": "ownFigure",
"template": "T11"
},
{
"trigger": "static",
"op": "pump",
"target": "attached",
"power": 3,
"toughness": 3,
"duration": "permanent",
"template": "T11"
},
{
"trigger": "onCombatDamageToPlayer",
"op": "draw",
"target": "attached",
"amount": 1,
"template": "T11"
}
@@ -1272,15 +1281,19 @@
"trigger": "onPlay",
"op": "attach",
"target": "ownFigure",
"template": "T11"
},
{
"trigger": "static",
"op": "pump",
"target": "attached",
"power": 3,
"toughness": 3,
"duration": "permanent",
"template": "T11"
},
{
"trigger": "onCombatDamageToPlayer",
"op": "draw",
"target": "attached",
"amount": 1,
"template": "T11"
}
@@ -3753,9 +3766,14 @@
"trigger": "onPlay",
"op": "attach",
"target": "ownFigure",
"template": "T11"
},
{
"trigger": "static",
"op": "pump",
"target": "attached",
"power": 3,
"toughness": 3,
"duration": "permanent",
"template": "T11"
}
],
@@ -4189,9 +4207,14 @@
"trigger": "onPlay",
"op": "attach",
"target": "ownFigure",
"template": "T11"
},
{
"trigger": "static",
"op": "pump",
"target": "attached",
"power": 2,
"toughness": 2,
"duration": "permanent",
"template": "T11"
}
],
@@ -4325,9 +4348,14 @@
"trigger": "onPlay",
"op": "attach",
"target": "ownFigure",
"template": "T11"
},
{
"trigger": "static",
"op": "pump",
"target": "attached",
"power": 3,
"toughness": 3,
"duration": "permanent",
"template": "T11"
}
],
@@ -4787,9 +4815,14 @@
"trigger": "onPlay",
"op": "attach",
"target": "ownFigure",
"template": "T11"
},
{
"trigger": "static",
"op": "pump",
"target": "attached",
"power": 2,
"toughness": 2,
"duration": "permanent",
"template": "T11"
}
],
@@ -5010,9 +5043,14 @@
"trigger": "onPlay",
"op": "attach",
"target": "ownFigure",
"template": "T11"
},
{
"trigger": "static",
"op": "pump",
"target": "attached",
"power": 3,
"toughness": 3,
"duration": "permanent",
"grant": [
"Well-sourced"
],
@@ -5059,9 +5097,14 @@
"trigger": "onPlay",
"op": "attach",
"target": "ownFigure",
"template": "T11"
},
{
"trigger": "static",
"op": "pump",
"target": "attached",
"power": 3,
"toughness": 3,
"duration": "permanent",
"template": "T11"
}
],
@@ -5196,9 +5239,14 @@
"trigger": "onPlay",
"op": "attach",
"target": "ownFigure",
"template": "T11"
},
{
"trigger": "static",
"op": "pump",
"target": "attached",
"power": 3,
"toughness": 3,
"duration": "permanent",
"grant": [
"Well-sourced"
],
@@ -6030,9 +6078,14 @@
"trigger": "onPlay",
"op": "attach",
"target": "ownFigure",
"template": "T11"
},
{
"trigger": "static",
"op": "pump",
"target": "attached",
"power": 2,
"toughness": 2,
"duration": "permanent",
"template": "T11"
}
],
@@ -7070,9 +7123,14 @@
"trigger": "onPlay",
"op": "attach",
"target": "ownFigure",
"template": "T11"
},
{
"trigger": "static",
"op": "pump",
"target": "attached",
"power": 2,
"toughness": 2,
"duration": "permanent",
"grant": [
"Well-sourced"
],
@@ -7120,9 +7178,14 @@
"trigger": "onPlay",
"op": "attach",
"target": "figure",
"template": "T12"
},
{
"trigger": "static",
"op": "pump",
"target": "attached",
"power": -2,
"toughness": -2,
"duration": "permanent",
"template": "T12"
}
],
@@ -7830,9 +7893,14 @@
"trigger": "onPlay",
"op": "attach",
"target": "figure",
"template": "T12"
},
{
"trigger": "static",
"op": "pump",
"target": "attached",
"power": -2,
"toughness": -2,
"duration": "permanent",
"template": "T12"
}
],
@@ -8132,9 +8200,14 @@
"trigger": "onPlay",
"op": "attach",
"target": "ownFigure",
"template": "T11"
},
{
"trigger": "static",
"op": "pump",
"target": "attached",
"power": 1,
"toughness": 1,
"duration": "permanent",
"template": "T11"
}
],
@@ -8552,9 +8625,14 @@
"trigger": "onPlay",
"op": "attach",
"target": "ownFigure",
"template": "T11"
},
{
"trigger": "static",
"op": "pump",
"target": "attached",
"power": 2,
"toughness": 2,
"duration": "permanent",
"grant": [
"Well-sourced"
],
@@ -9028,9 +9106,14 @@
"trigger": "onPlay",
"op": "attach",
"target": "ownFigure",
"template": "T11"
},
{
"trigger": "static",
"op": "pump",
"target": "attached",
"power": 2,
"toughness": 2,
"duration": "permanent",
"template": "T11"
}
],
@@ -9074,9 +9157,14 @@
"trigger": "onPlay",
"op": "attach",
"target": "ownFigure",
"template": "T11"
},
{
"trigger": "static",
"op": "pump",
"target": "attached",
"power": 3,
"toughness": 3,
"duration": "permanent",
"template": "T11"
}
],
@@ -9384,9 +9472,14 @@
"trigger": "onPlay",
"op": "attach",
"target": "ownFigure",
"template": "T11"
},
{
"trigger": "static",
"op": "pump",
"target": "attached",
"power": 3,
"toughness": 3,
"duration": "permanent",
"template": "T11"
}
],
@@ -9559,9 +9652,14 @@
"trigger": "onPlay",
"op": "attach",
"target": "ownFigure",
"template": "T11"
},
{
"trigger": "static",
"op": "pump",
"target": "attached",
"power": 1,
"toughness": 1,
"duration": "permanent",
"template": "T11"
}
],
+9 -6
View File
@@ -116,12 +116,15 @@ function baseEffects(type: CardType, subtype: string | null, cost: number): Effe
default: return [{ trigger: 'static', op: 'pump', target: 'ownFigures', power: 1, toughness: 0, condition: { maxPower: 2 } }];
}
case 'Doctrine': {
if (subtype === 'pathology') return [{ trigger: 'onPlay', op: 'attach', target: 'figure', power: -k, toughness: -k, duration: 'permanent' }];
const attach: EffectSpec = { trigger: 'onPlay', op: 'attach', target: 'ownFigure', power: k, toughness: k, duration: 'permanent' };
if (subtype === 'mathematics') return [{ ...attach, grant: ['Well-sourced'] }];
if (subtype === 'language') return [attach, { trigger: 'onCombatDamageToPlayer', op: 'draw', target: 'attached', amount: 1 }];
if (subtype === 'ideology') return [attach, { trigger: 'static', op: 'pump', target: 'ownFigures', power: 1, toughness: 0, condition: { samePortal: true } }];
return [attach];
// DUEL_API "Doctrine": `attach` picks the Figure; the buff is a static pump on `attached`.
const pathology = subtype === 'pathology';
const attach: EffectSpec = { trigger: 'onPlay', op: 'attach', target: pathology ? 'figure' : 'ownFigure' };
const buff: EffectSpec = { trigger: 'static', op: 'pump', target: 'attached', power: pathology ? -k : k, toughness: pathology ? -k : k };
if (pathology) return [attach, buff];
if (subtype === 'mathematics') return [attach, { ...buff, grant: ['Well-sourced'] }];
if (subtype === 'language') return [attach, buff, { trigger: 'onCombatDamageToPlayer', op: 'draw', amount: 1 }];
if (subtype === 'ideology') return [attach, buff, { trigger: 'static', op: 'pump', target: 'ownFigures', power: 1, toughness: 0, condition: { samePortal: true } }];
return [attach, buff];
}
default: return [];
}
+1
View File
@@ -623,6 +623,7 @@ function startTurn(state: DuelState, seat: Seat): void {
p.locationsThisTurn = 0;
p.baseCitations = Math.min(state.rules.maxCitations, p.baseCitations + state.rules.citationsPerTurn);
p.citations = maxCitations(state, seat);
if (state.turn === 2 && seat !== state.firstSeat) p.citations += state.rules.secondPlayerCitations;
for (const perm of state.battlefield) {
perm.shielded = false;
if (perm.controller === seat) { perm.tapped = false; perm.sick = false; }
+2
View File
@@ -18,6 +18,7 @@ export const DuelRulesetSchema = z.object({
handSize: int(1, 15),
mulligans: int(0, 3),
firstPlayerDraws: z.boolean(),
secondPlayerCitations: int(0, 5),
maxCitations: int(1, 20),
citationsPerTurn: int(1, 5),
territoryCap: int(0, 10),
@@ -46,6 +47,7 @@ export const DEFAULT_DUEL_RULESET: DuelRuleset = Object.freeze({
handSize: 7,
mulligans: 1,
firstPlayerDraws: false,
secondPlayerCitations: 0,
maxCitations: 10,
citationsPerTurn: 1,
territoryCap: 2,
+12 -3
View File
@@ -75,8 +75,16 @@ export function effectText(effects: readonly EffectSpec[]): string[] {
for (let i = 0; i < effects.length; i++) {
const e = effects[i];
if (e.op === 'attach') {
const grant = e.grant?.length ? ` and has ${keywordsAsText(e.grant)}` : '';
lines.push(`Attach to ${e.target === 'figure' ? 'target Figure' : 'target Figure you control'}. It gets ${pt(e.power, e.toughness)}${grant}.`);
// The Doctrine's buff is the static pump on `attached` that follows (DUEL_API "Doctrine").
const next = effects[i + 1];
const buff = next && next.trigger === 'static' && next.op === 'pump' && next.target === 'attached' ? next : null;
let line = `Attach to ${e.target === 'figure' ? 'target Figure' : 'target Figure you control'}.`;
if (buff) {
const grant = buff.grant?.length ? ` and has ${keywordsAsText(buff.grant)}` : '';
line += ` It gets ${pt(buff.power, buff.toughness)}${grant}.`;
i++;
}
lines.push(line);
continue;
}
if (e.op === 'fight' && i > 0 && effects[i - 1].op === 'pump') {
@@ -95,7 +103,8 @@ export function effectText(effects: readonly EffectSpec[]): string[] {
break;
}
case 'onCombatDamageToPlayer':
lines.push(`Whenever ${e.target === 'attached' ? 'it' : 'this'} deals combat damage to a player, ${actionText(e)}.`);
// On a Doctrine the trigger belongs to the attached Figure ("it"); on a Figure, to "this".
lines.push(`Whenever ${effects.some(x => x.op === 'attach') ? 'it' : 'this'} deals combat damage to a player, ${actionText(e)}.`);
break;
}
}
+1
View File
@@ -166,6 +166,7 @@ export interface DuelRuleset {
handSize: number; // 7: hand limit at end of turn (DUEL_DESIGN `handLimit`); excess discarded highest cost first
mulligans: number; // 1: shuffle, draw openingHand, bottom one per mulligan taken
firstPlayerDraws: boolean; // false
secondPlayerCitations: number; // 0: extra Citations on the second player's first turn (designer's "Second Opinion" lever)
maxCitations: number; // 10
citationsPerTurn: number; // 1
territoryCap: number; // 2
+16
View File
@@ -203,3 +203,19 @@ test('Connected fires in a plausible share of sample pairs (BRIEF target 15–30
const rate = hits / pairs;
assert.ok(rate > 0.1 && rate < 0.4, `rate ${rate}`);
});
test('Doctrines use the engine encoding: attach picks the Figure, a static pump on `attached` carries ±k (DUEL_API)', () => {
for (const c of CARDS.filter(x => x.type === 'Doctrine')) {
assert.equal(c.effects[0].op, 'attach', c.title);
const buff = c.effects[1];
assert.equal(buff.trigger, 'static', c.title);
assert.equal(buff.op, 'pump');
assert.equal(buff.target, 'attached');
const magnitude = c.basis.magnitude;
const sign = c.subtype === 'pathology' ? -1 : 1;
assert.deepEqual([buff.power, buff.toughness], [sign * magnitude, sign * magnitude], c.title);
assert.equal(c.effects[0].target, c.subtype === 'pathology' ? 'figure' : 'ownFigure');
}
assert.deepEqual(byTitle('Heart rot').effects.map(e => [e.trigger, e.op, e.target, e.power ?? null]),
[['onPlay', 'attach', 'figure', null], ['static', 'pump', 'attached', -3]]);
});
+9
View File
@@ -150,3 +150,12 @@ test('three consecutive timeouts lose; turnCap decides by Notability', () => {
c = pass(c);
assert.deepEqual(c.result, { winner: 0, reason: 'turnCap' });
});
test('secondPlayerCitations gives the second player extra Citations on their first turn only', () => {
let s = scenario([[], []], { citationsPerTurn: 1, secondPlayerCitations: 1 });
assert.equal(s.players[0].citations, 1);
s = pass(s);
assert.equal(s.players[1].citations, 2);
s = pass(s); s = pass(s);
assert.equal(s.players[1].citations, 2, 'turn 4: base 2, no bonus');
});
+1 -1
View File
@@ -206,4 +206,4 @@ test('golden match', () => {
});
// Regenerate deliberately (an engine rule change) and say so in the PR.
const GOLDEN = { actions: 60, turn: 11, result: { winner: 1, reason: 'life' }, log: 83, digest: 'eb83865b9b4e30c9' };
const GOLDEN = { actions: 60, turn: 11, result: { winner: 1, reason: 'life' }, log: 83, digest: '4f4296d6951a616b' };