forked from WikiDeck/wikideck
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:
@@ -46,7 +46,7 @@ export const RulesetSchema = z.object({
|
|||||||
vanillaBonus: int(0, 10),
|
vanillaBonus: int(0, 10),
|
||||||
keywordsEnabled: z.array(z.enum(KEYWORD_IDS)).max(KEYWORD_IDS.length),
|
keywordsEnabled: z.array(z.enum(KEYWORD_IDS)).max(KEYWORD_IDS.length),
|
||||||
ownedCards: z.boolean(),
|
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),
|
trendUp: z.number().finite().min(-1000).max(1000),
|
||||||
trendDown: z.number().finite().min(-1000).max(1000),
|
trendDown: z.number().finite().min(-1000).max(1000),
|
||||||
trendMinDaily: z.number().finite().min(0).max(1e9),
|
trendMinDaily: z.number().finite().min(0).max(1e9),
|
||||||
|
|||||||
@@ -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);
|
const b = deriveCard(input({ attention: 81, depth: 71, reach: 61 }), TABLE);
|
||||||
assert.deepEqual(a, b);
|
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);
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user