diff --git a/app/__tests__/builderReducer.test.ts b/app/__tests__/builderReducer.test.ts index 0a2b53ab..d3a4fbf5 100644 --- a/app/__tests__/builderReducer.test.ts +++ b/app/__tests__/builderReducer.test.ts @@ -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)', diff --git a/app/reducers/builderReducer.ts b/app/reducers/builderReducer.ts index 4f23565e..b3f1392c 100644 --- a/app/reducers/builderReducer.ts +++ b/app/reducers/builderReducer.ts @@ -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( diff --git a/app/reducers/builderUtils.ts b/app/reducers/builderUtils.ts index 8401139d..ba045a13 100644 --- a/app/reducers/builderUtils.ts +++ b/app/reducers/builderUtils.ts @@ -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'; @@ -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,