diff --git a/src/main/client/src/Game.jsx b/src/main/client/src/Game.jsx index b06950a..2fd856c 100644 --- a/src/main/client/src/Game.jsx +++ b/src/main/client/src/Game.jsx @@ -12,7 +12,7 @@ import { import { StompContext, BLACK, - ANY_TERRITORY, + TERRITORY, TERRITORY_B, REMOVED_B, ANY_REMOVED, @@ -362,8 +362,8 @@ function paintStonesCounting(context, board, countingGroup) { "rgba(255,255,255,0.25)" showShadow(context, grid_x, grid_y, style) } - if (color & ANY_TERRITORY) { - let style = (color & ANY_TERRITORY) === TERRITORY_B ? + if (color & TERRITORY) { + let style = (color & TERRITORY) === TERRITORY_B ? "rgba(0,0,0)" : "rgba(255,255,255)" showTerritory(context, grid_x, grid_y, style) diff --git a/src/main/client/src/model/board.js b/src/main/client/src/model/board.js index 3e49c03..0783159 100644 --- a/src/main/client/src/model/board.js +++ b/src/main/client/src/model/board.js @@ -89,9 +89,9 @@ export function getGroupInfo(board, xx, yy) { export function rehydrate(board) { let dim = board.length - let result = [] + let result = Array(dim) for (let i = 0; i < board.length; i++) { - result.push([]) + result[i] = Array(dim) } for (let y = 0; y < board.length; y++) { for (let x = 0; x < board[y].length; x++) { diff --git a/src/main/client/src/util.js b/src/main/client/src/util.js index b35668b..9b59966 100644 --- a/src/main/client/src/util.js +++ b/src/main/client/src/util.js @@ -6,17 +6,18 @@ import toast from "react-hot-toast" export const StompContext = createContext() export const base = "/app" + export const BLACK = 32 export const WHITE = 64 export const TERRITORY_B = 2 export const TERRITORY_W = 4 -export const ANY_TERRITORY = TERRITORY_W | TERRITORY_B export const REMOVED_B = 8 export const REMOVED_W = 16 + +export const TERRITORY = TERRITORY_W | TERRITORY_B export const ANY_REMOVED = REMOVED_W | REMOVED_B -const COLORS = BLACK | WHITE; -const MARKERS = ~COLORS; +export const COLORS = BLACK | WHITE; export async function tfetch(url, options) { let response @@ -60,7 +61,7 @@ function dec2hex(dec) { } export function hasStone(color) { - return (color & COLORS) != 0 && (color & MARKERS) == 0; + return (color & COLORS) !== 0 } export function getBaseColor(color) { @@ -87,6 +88,8 @@ export async function doTry(task, onError) { } catch (e) { if (onError) { onError() + } else { + console.log(e) } toast.error(e.message) }