forked from WikiDeck/wikideck
Modes: follow engine core ec24437..c938407 (portalReveal, onTopicBonus array, trendDown)
Trending mode sets trendDown -25 so falling trends matter (base rules ignore them at -200). Doc examples updated and tested. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -24,7 +24,7 @@ A mode is a JSON document, at most 8 KiB:
|
||||
"name": "Trending",
|
||||
"description": "Live Wikipedia pageview trends power cards up or down.",
|
||||
"tags": ["live-data"],
|
||||
"rules": { "trendUp": 15, "trendDown": -15 },
|
||||
"rules": { "trendUp": 25, "trendDown": -25 },
|
||||
"cards": { "preset": "trending", "percentPerPoint": 25, "maxBonus": 3, "penalise": true },
|
||||
"decks": { "kind": "starter" },
|
||||
"limits": { "maxConcurrentMatches": 32, "turnSeconds": 90, "lobbyMinutes": 15 }
|
||||
@@ -83,7 +83,7 @@ Start from `server/game/modes/classic.json`, change `id`, `name` and `descriptio
|
||||
override rules. Some ideas within tonight's rules:
|
||||
|
||||
- **Blitz:** `"rules": { "turns": 4, "energyByTurn": [3, 4, 5, 6] }`
|
||||
- **On-topic:** `"rules": { "onTopicBonus": 4, "trendUp": 10, "trendDown": -10 }`
|
||||
- **On-topic:** `"rules": { "onTopicBonus": [0, 2, 2, 3, 3, 4, 4], "trendUp": 10, "trendDown": -10 }`
|
||||
- **Slow play:** `"rules": { "turns": 6, "turnSeconds": 40 }` (the engine caps turns × turnSeconds at 240)
|
||||
- **Big decks:** `"rules": { "deckSize": 16, "maxLoaners": 16 }` with `"decks": { "kind": "draft", "poolSize": 40 }`.
|
||||
Starter decks are 12 cards, so a non-draft mode with another deck size is rejected at startup.
|
||||
@@ -152,7 +152,7 @@ A mode is rejected at node startup, never handed to the engine half-checked, if:
|
||||
- it fails the mode schema (section 1), or
|
||||
- the merged ruleset fails the engine's strict `parseRuleset`, or
|
||||
- it fails the host-side checks in `server/game/engine-binding.ts`: `distinctStats` requires
|
||||
`topicCount` 3; every `revealSchedule` turn ≤ `turns`; `energyByTurn` has an entry per turn;
|
||||
`topicCount` 3; every `portalReveal` turn ≤ `turns`; `energyByTurn` has an entry per turn;
|
||||
`turns × turnSeconds ≤ 240`; `powerByCost` has 7 entries; or
|
||||
- its deck policy can't produce legal decks (starter decks illegal under its rules, or a draft
|
||||
pool smaller than 2 × `deckSize`).
|
||||
|
||||
@@ -25,7 +25,7 @@ export function parseModeRuleset(value: unknown): Ruleset {
|
||||
const rules = parseRuleset(value);
|
||||
const problems: string[] = [];
|
||||
if (rules.distinctStats && rules.topicCount !== 3) problems.push('distinctStats requires topicCount 3');
|
||||
if (rules.revealSchedule.some(turn => turn > rules.turns)) problems.push('every revealSchedule turn must be ≤ turns');
|
||||
if (rules.portalReveal.some(turn => turn > rules.turns)) problems.push('every portalReveal turn must be ≤ turns');
|
||||
if (rules.energyByTurn.length < rules.turns) problems.push('energyByTurn needs one entry per turn');
|
||||
if (rules.turns * rules.turnSeconds > 240) problems.push('turns × turnSeconds must be ≤ 240');
|
||||
if (rules.powerByCost.length !== 7) problems.push('powerByCost needs 7 entries');
|
||||
|
||||
@@ -3,10 +3,27 @@
|
||||
"id": "trending",
|
||||
"version": 1,
|
||||
"name": "Trending",
|
||||
"description": "Base rules, but live Wikipedia pageview trends power cards up or down: +1 power for every 25% rise in monthly views, -1 for every 25% fall, capped at 3 either way.",
|
||||
"tags": ["live-data", "starter"],
|
||||
"rules": {},
|
||||
"cards": { "preset": "trending", "percentPerPoint": 25, "maxBonus": 3, "penalise": true },
|
||||
"decks": { "kind": "starter" },
|
||||
"limits": { "maxConcurrentMatches": 32, "turnSeconds": 90, "lobbyMinutes": 15 }
|
||||
"description": "Live Wikipedia pageview trends matter both ways: cards get the live trend arrow (up at +25%, down at -25%, where the base rules ignore falls), plus +1 power per 25% rise and -1 per 25% fall, capped at 3 either way.",
|
||||
"tags": [
|
||||
"live-data",
|
||||
"starter"
|
||||
],
|
||||
"rules": {
|
||||
"trendUp": 25,
|
||||
"trendDown": -25
|
||||
},
|
||||
"cards": {
|
||||
"preset": "trending",
|
||||
"percentPerPoint": 25,
|
||||
"maxBonus": 3,
|
||||
"penalise": true
|
||||
},
|
||||
"decks": {
|
||||
"kind": "starter"
|
||||
},
|
||||
"limits": {
|
||||
"maxConcurrentMatches": 32,
|
||||
"turnSeconds": 90,
|
||||
"lobbyMinutes": 15
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ test('modes api: draft preview pool is deterministic and deck-legal', () => {
|
||||
test('modes api: the rule examples in HOSTING.md are valid modes', () => {
|
||||
for (const rules of [
|
||||
{ turns: 4, energyByTurn: [3, 4, 5, 6] },
|
||||
{ onTopicBonus: 4, trendUp: 10, trendDown: -10 },
|
||||
{ onTopicBonus: [0, 2, 2, 3, 3, 4, 4], trendUp: 10, trendDown: -10 },
|
||||
{ deckSize: 16, maxCopiesPerPage: 2, maxLoaners: 16 },
|
||||
{ turns: 6, turnSeconds: 40 },
|
||||
]) {
|
||||
@@ -159,7 +159,8 @@ test('modes api: mode rules that make starter decks illegal fail at startup; liv
|
||||
store: new MatchStore(null) }), /starter decks are illegal/);
|
||||
const card = engineBinding.starterDeck(DEFAULT_RULESET, 's')[0]!;
|
||||
assert.equal(engineBinding.applyLive!(DEFAULT_RULESET, card, { trendPercent: 30 }).trend, 1);
|
||||
assert.equal(engineBinding.applyLive!(DEFAULT_RULESET, card, { trendPercent: -30 }).trend, -1);
|
||||
assert.equal(engineBinding.applyLive!(DEFAULT_RULESET, card, { trendPercent: DEFAULT_RULESET.trendDown - 1 }).trend, -1);
|
||||
assert.equal(engineBinding.applyLive!({ ...DEFAULT_RULESET, trendDown: -25 }, card, { trendPercent: -30 }).trend, -1);
|
||||
assert.equal(engineBinding.applyLive!(DEFAULT_RULESET, card, { trendPercent: 5 }).trend, 0);
|
||||
assert.equal(engineBinding.applyLive!(DEFAULT_RULESET, card, { trendPercent: null }).trend, 0);
|
||||
assert.equal(engineBinding.withPower(card, 99).power, 30, 'power stays within engine bounds');
|
||||
@@ -193,9 +194,9 @@ test('modes api: turn timer applies the engine timeout action; AFK forfeits are
|
||||
test('modes api: mode rules are checked beyond the engine schema and rejected, not passed on', async () => {
|
||||
const { parseModeRuleset } = await import('../server/game/engine-binding.ts');
|
||||
const bad = [
|
||||
{ turns: 2, energyByTurn: [1, 2] }, // revealSchedule [1,2,3] has a turn > 2
|
||||
{ distinctStats: true, topicCount: 2, revealSchedule: [1, 2] },
|
||||
{ turns: 12, turnSeconds: 25, energyByTurn: Array(12).fill(3), revealSchedule: [1, 2, 3] },
|
||||
{ turns: 2, energyByTurn: [1, 2] }, // portalReveal has a turn > 2
|
||||
{ distinctStats: true, topicCount: 2, portalReveal: [1, 2] },
|
||||
{ turns: 12, turnSeconds: 25, energyByTurn: Array(12).fill(3), portalReveal: [1, 2, 3] },
|
||||
{ powerByCost: [0, 1, 2] },
|
||||
{ mulligan: true },
|
||||
{ keywordParams: { notAKeyword: { amount: 1 } } },
|
||||
|
||||
Reference in New Issue
Block a user