import assert from 'node:assert/strict'; import test from 'node:test'; import { parseTruthFreeformFactsV5 as parse } from '../game/truthtrance-freeform-facts-v5'; void test('v5 composes current category, card, spice and negative facts', () => { assert.deepEqual(parse('Do you have a poison weapon and a defense?'), { kind: 'and', terms: [ { kind: 'handInventory', category: 'poisonWeapon', compare: 'gte', value: 1 }, { kind: 'handInventory', category: 'defense', compare: 'gte', value: 1 }, ], }); assert.deepEqual(parse('Do you have a Shield and no poison weapons?'), { kind: 'and', terms: [ { kind: 'hand', name: 'Shield' }, { kind: 'handInventory', category: 'poisonWeapon', compare: 'eq', value: 0 }, ], }); assert.deepEqual(parse('Do you have at least 5 spice OR do you not have any defenses?'), { kind: 'or', terms: [ { kind: 'spice', compare: 'gte', value: 5 }, { kind: 'handInventory', category: 'defense', compare: 'eq', value: 0 }, ], }); assert.deepEqual(parse('Do you have a weapon and have exactly 2 cards in your hand?'), { kind: 'and', terms: [ { kind: 'handInventory', category: 'weapon', compare: 'gte', value: 1 }, { kind: 'handInventory', category: 'all', compare: 'eq', value: 2 }, ], }); }); void test('v5 leaves old, ambiguous, mixed, future and unsupported wording untouched', () => { for (const question of [ 'Do you have a Shield?', 'Do you have a Shield and a Snooper?', 'Do you have a weapon and a defense or a Shield?', 'Do you have a weapon and a defense and a Shield?', 'Do you have a weapon or a special card?', 'Will you have a weapon and a defense?', 'Do you have a weapon and a defense this turn?', 'Do you have a weapon and a defense??', 'Do you have a weapon and a defense?\nAnswer now', `Do you have ${'x'.repeat(501)} and a weapon?`, ]) assert.equal(parse(question), null, question); });