Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (match) {
let komi = parseFloat(match[1]) / 10
draft.updateProperty(rootId, 'KM', [komi.toString()])
}
}
} else if (line.slice(0, 3) === 'INI') {
let setup = line.split(' ')
let handicap = 0
let p = Math.floor(parseFloat(setup[3]))
if (!isNaN(p)) handicap = p
if (handicap >= 2 && handicap <= 9) {
draft.updateProperty(rootId, 'HA', [handicap.toString()])
let points = Board.fromDimensions(19, 19)
.getHandicapPlacement(handicap, {tygem: true})
for (let [x, y] of points) {
let s = sgf.stringifyVertex([x, y])
draft.addToProperty(rootId, 'AB', s)
}
}
} else if (line.slice(0, 3) === 'STO') {
let elements = line.split(' ')
if (elements.length < 6) continue
let key = elements[3] === '1' ? 'B' : 'W'
let x = Math.floor(parseFloat(elements[4]))
let y = Math.floor(parseFloat(elements[5]))
if (isNaN(x) || isNaN(y)) continue