Skip to content

Commit f0799bb

Browse files
committed
some refactoring
1 parent 9378dbc commit f0799bb

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/main/client/src/Game.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
import {
1313
StompContext,
1414
BLACK,
15-
ANY_TERRITORY,
15+
TERRITORY,
1616
TERRITORY_B,
1717
REMOVED_B,
1818
ANY_REMOVED,
@@ -362,8 +362,8 @@ function paintStonesCounting(context, board, countingGroup) {
362362
"rgba(255,255,255,0.25)"
363363
showShadow(context, grid_x, grid_y, style)
364364
}
365-
if (color & ANY_TERRITORY) {
366-
let style = (color & ANY_TERRITORY) === TERRITORY_B ?
365+
if (color & TERRITORY) {
366+
let style = (color & TERRITORY) === TERRITORY_B ?
367367
"rgba(0,0,0)" :
368368
"rgba(255,255,255)"
369369
showTerritory(context, grid_x, grid_y, style)

src/main/client/src/model/board.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ export function getGroupInfo(board, xx, yy) {
8989

9090
export function rehydrate(board) {
9191
let dim = board.length
92-
let result = []
92+
let result = Array(dim)
9393
for (let i = 0; i < board.length; i++) {
94-
result.push([])
94+
result[i] = Array(dim)
9595
}
9696
for (let y = 0; y < board.length; y++) {
9797
for (let x = 0; x < board[y].length; x++) {

src/main/client/src/util.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,18 @@ import toast from "react-hot-toast"
66
export const StompContext = createContext()
77

88
export const base = "/app"
9+
910
export const BLACK = 32
1011
export const WHITE = 64
1112
export const TERRITORY_B = 2
1213
export const TERRITORY_W = 4
13-
export const ANY_TERRITORY = TERRITORY_W | TERRITORY_B
1414
export const REMOVED_B = 8
1515
export const REMOVED_W = 16
16+
17+
export const TERRITORY = TERRITORY_W | TERRITORY_B
1618
export const ANY_REMOVED = REMOVED_W | REMOVED_B
1719

18-
const COLORS = BLACK | WHITE;
19-
const MARKERS = ~COLORS;
20+
export const COLORS = BLACK | WHITE;
2021

2122
export async function tfetch(url, options) {
2223
let response
@@ -60,7 +61,7 @@ function dec2hex(dec) {
6061
}
6162

6263
export function hasStone(color) {
63-
return (color & COLORS) != 0 && (color & MARKERS) == 0;
64+
return (color & COLORS) !== 0
6465
}
6566

6667
export function getBaseColor(color) {
@@ -87,6 +88,8 @@ export async function doTry(task, onError) {
8788
} catch (e) {
8889
if (onError) {
8990
onError()
91+
} else {
92+
console.log(e)
9093
}
9194
toast.error(e.message)
9295
}

0 commit comments

Comments
 (0)