UNPKG

@jeremyckahn/farmhand

Version:
19 lines (15 loc) 454 B
// TODO: Add tests for this reducer. export const modifyFieldPlotAt = ( state: farmhand.state, x: number, y: number, modifierFn: (arg0: farmhand.plotContent | null) => farmhand.plotContent | null ): farmhand.state => { const { field } = state const row = [...field[y]] const plotContent = modifierFn(row[x]) row[x] = plotContent const modifiedField = [...field] modifiedField[y] = row return { ...state, field: modifiedField } }