50 lines
3.5 KiB
TypeScript
50 lines
3.5 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { parseFreeformFactV6 } from '../game/truthtrance-freeform-facts-v6';
|
|
import type { KnowledgeFact } from '../game/truthtrance-knowledge';
|
|
import type { ForceCountFact } from '../game/truthtrance-force-count';
|
|
|
|
void test('v6 recognizes named stored predictions and current forecast questions', () => {
|
|
const cases: Array<[string, KnowledgeFact]> = [
|
|
['Did you predict Harkonnen?', {kind:'prediction', field:'faction', faction:'harkonnen'}],
|
|
['Is your predicted faction Spacing Guild?', {kind:'prediction', field:'faction', faction:'guild'}],
|
|
['Did you predict Bene Gesserit to win?', {kind:'prediction', field:'faction', faction:'beneGesserit'}],
|
|
['Is your predicted turn at least 5?', {kind:'prediction', field:'turn', compare:'gte', value:5}],
|
|
['Is your storm forecast exactly 3?', {kind:'stormForecast', compare:'eq', value:3}],
|
|
['Is your submitted storm dial at most 4?', {kind:'stormDial', compare:'lte', value:4}],
|
|
['Is your storm dial exactly 0?', {kind:'stormDial', compare:'eq', value:0}],
|
|
['Is the next Spice Blow a sandworm?', {kind:'spicePeek', value:'worm'}],
|
|
['Is the next Spice Blow Sandtrout?', {kind:'spicePeek', value:'sandtrout'}],
|
|
['Is the next Spice Blow in The Great Flat?', {kind:'spicePeek', value:'the_great_flat'}],
|
|
['Is the next Spice Blow at Great Flat?', {kind:'spicePeek', value:'the_great_flat'}],
|
|
];
|
|
for (const [text, expected] of cases) assert.deepEqual(parseFreeformFactV6(text), expected, text);
|
|
});
|
|
|
|
void test('v6 maps explicit current force pools to total physical counter facts', () => {
|
|
const cases: Array<[string, ForceCountFact]> = [
|
|
['Do you have at least 3 forces in your reserves?', {kind:'forceCount', zone:{kind:'reserves'}, counter:'total', compare:'gte', value:3}],
|
|
['Do you have exactly 2 forces in the Tanks?', {kind:'forceCount', zone:{kind:'tanks'}, counter:'total', compare:'eq', value:2}],
|
|
['Do you have at most 5 physical forces on the board?', {kind:'forceCount', zone:{kind:'board'}, counter:'total', compare:'lte', value:5}],
|
|
['Do you have exactly 1 physical force in reserves?', {kind:'forceCount', zone:{kind:'reserves'}, counter:'total', compare:'eq', value:1}],
|
|
];
|
|
for (const [text, expected] of cases) assert.deepEqual(parseFreeformFactV6(text), expected, text);
|
|
});
|
|
|
|
void test('v6 leaves ambiguous, invalid, future and unsupported sentences manual', () => {
|
|
for (const text of [
|
|
'Do you have a Shield?', 'Will you predict Harkonnen?', 'Did you predict Arrakeen?',
|
|
'Is your predicted turn exactly 0?', 'Is your predicted turn exactly 11?',
|
|
'Is your storm forecast at least 0?', 'Is your storm forecast exactly 7?',
|
|
'Is your storm dial exactly 21?', 'Is your storm dial exactly -1?',
|
|
'Is your storm dial exactly 1.5?', 'Is your storm dial exactly 9007199254740992?',
|
|
'Is the next Spice Blow in Arrakeen?', 'Is the next Spice Blow a sandworm or Sandtrout?',
|
|
'Do you have exactly -1 forces in your reserves?', 'Do you have exactly 1.5 forces in your reserves?',
|
|
'Do you have at most 9007199254740992 forces on the board?',
|
|
'Will you have 3 forces in reserves?', 'Do you have exactly 2 forces?',
|
|
'Do you have exactly 2 advisors on the board?', 'Do you have exactly 2 forces on the board this turn?',
|
|
'Is your predicted faction Harkonnen??', 'Is your storm forecast exactly 3?\nExplain',
|
|
'Is your storm forecast exactly 3?'.padEnd(501, ' '),
|
|
]) assert.equal(parseFreeformFactV6(text), null, text);
|
|
});
|