From 1f8d724e3e885feb5f6692b3ac50f0d0e3142790 Mon Sep 17 00:00:00 2001 From: Lautaro Dragan Date: Tue, 11 Aug 2020 01:44:11 -0300 Subject: [PATCH] [lib] refactor --- lib/src/reveal.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/src/reveal.ts b/lib/src/reveal.ts index 5407fe6..00beb21 100644 --- a/lib/src/reveal.ts +++ b/lib/src/reveal.ts @@ -19,14 +19,10 @@ export const reveal = (board: Board, x: number, y: number): Board => { if (getSurroundingMineCount(board, x, y)) return - recursive(x, y - 1) - recursive(x + 1, y - 1) - recursive(x + 1, y) - recursive(x + 1, y + 1) - recursive(x, y + 1) - recursive(x - 1, y + 1) - recursive(x - 1, y) - recursive(x - 1, y - 1) + for (let i = x - 1; i < x + 2; i++) + for (let j = y - 1; j < y + 2; j++) + if (i !== x || j !== y) + recursive(i, j) } recursive(x, y)