Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/__tests__/builderReducer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ test('short word warning', () => {
`);
});

test('isolated cell warning', () => {
const state = getState(['.', '.', '.', '.', 'A', '.', '.', '.', '.'], {});
expect(builderReducer(state, publish).publishWarnings).toMatchInlineSnapshot(`
[
"Some cells are isolated and cannot be clued",
]
`);
});

test('basic enum warnings', () => {
const state = getState(['a', 'b', 'c', 'g', '', '', 'd', 'e', 'f'], {
abc: 'test with good enum (3)',
Expand Down
3 changes: 3 additions & 0 deletions app/reducers/builderReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,9 @@ function _builderReducer(
if (stats.hasUnches) {
warnings.push('UNCHES'); // A bit of a hack but PublishWarningsList handles rendering this one
}
if (stats.hasIsolatedCells) {
warnings.push('Some cells are isolated and cannot be clued');
}
if (stats.unmatchedRefs.size > 0) {
warnings.push(
`Some clues reference entries that don't exist: (${Array.from(
Expand Down
9 changes: 9 additions & 0 deletions app/reducers/builderUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { entryWord, hasUnches } from '../lib/gridBase.js';
import { parseClueEnumeration, parseClueReferences } from '../lib/parse.js';
import { emptySelection, hasMultipleCells } from '../lib/selection.js';
import { BLOCK } from '../lib/types.js';
import { ViewableEntry, entryString } from '../lib/viewableGrid.js';
import type { BuilderState } from './builderReducer.js';
import type { GridInterfaceState } from './gridReducer.js';
Expand Down Expand Up @@ -128,8 +129,16 @@ export function getWarningStats(state: BuilderState) {
});
const enumsExpected = missingEnums.size < numValidClues / 2;

const hasIsolatedCells = grid.entriesByCell.some(
([across, down], index) =>
grid.cells[index] !== BLOCK &&
across.entryIndex === null &&
down.entryIndex === null
);

return {
shortWords,
hasIsolatedCells,
hasUnches: hasUnches(grid) && !state.userTags.includes('cryptic'),
unmatchedRefs,
missingEnums: enumsExpected ? missingEnums : null,
Expand Down
Loading