Skip to content

Commit a2880da

Browse files
committed
allow values to be zero
1 parent 64c8e75 commit a2880da

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/components/Goban.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ export default class Goban extends Component {
420420
for (const v in board.childrenInfo) {
421421
const [x, y] = v.split(',').map(x => +x)
422422
const {visits, winrate, scoreLead} = board.childrenInfo[v]
423-
if (visits && winrate) {
423+
if (isFinite(visits) && isFinite(winrate)) {
424424
variations.push({vertex: [x, y], visits, winrate, scoreLead})
425425
}
426426
}

src/modules/gametree.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,18 @@ export function getBoard(tree, id) {
358358
type = 'good'
359359
}
360360

361-
const visits = node.data.VISITS || null
362-
const winrate =
363-
(node.data.WINRATE && (0.5 + sign * (node.data.WINRATE - 0.5)) * 100) ||
364-
null
365-
const scoreLead =
366-
(node.data.SCORELEAD && node.data.SCORELEAD * sign) || null
361+
let visits = null
362+
let winrate = null
363+
let scoreLead = null
364+
if (isFinite(node.data.VISITS)) {
365+
visits = +node.data.VISITS
366+
}
367+
if (isFinite(node.data.WINRATE)) {
368+
winrate = (0.5 + sign * (node.data.WINRATE - 0.5)) * 100
369+
}
370+
if (isFinite(node.data.SCORELEAD)) {
371+
scoreLead = node.data.SCORELEAD * sign
372+
}
367373

368374
list[v] = {sign, type, visits, winrate, scoreLead}
369375
}

0 commit comments

Comments
 (0)