ruleset: cultureKeyword defaults to 'faction' so stored pre-v1.1 rulesets still parse (night-review)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 00:11:50 -05:00
co-authored by Claude Opus 5.5
parent e04ee31788
commit 4e53a54264
2 changed files with 9 additions and 1 deletions
+1 -1
View File
@@ -46,7 +46,7 @@ export const RulesetSchema = z.object({
vanillaBonus: int(0, 10),
keywordsEnabled: z.array(z.enum(KEYWORD_IDS)).max(KEYWORD_IDS.length),
ownedCards: z.boolean(),
cultureKeyword: z.enum(['faction', 'home']),
cultureKeyword: z.enum(['faction', 'home']).default('faction'), // default keeps pre-v1.1 stored rulesets parseable
trendUp: z.number().finite().min(-1000).max(1000),
trendDown: z.number().finite().min(-1000).max(1000),
trendMinDaily: z.number().finite().min(0).max(1e9),
+8
View File
@@ -162,3 +162,11 @@ test('a full Ruleset works as DerivationRules (hosts can derive with the mode ru
const b = deriveCard(input({ attention: 81, depth: 71, reach: 61 }), TABLE);
assert.deepEqual(a, b);
});
test('parseRuleset accepts a stored pre-v1.1 ruleset without cultureKeyword (defaults to faction)', async () => {
const { parseRuleset, RULESET_V1_0 } = await import('../shared/game/index.ts');
const { cultureKeyword: _omit, ...old } = structuredClone(RULESET_V1_0);
const parsed = parseRuleset(old);
assert.equal(parsed.cultureKeyword, 'faction');
assert.deepEqual(parsed, RULESET_V1_0);
});