fix snapback bug

This commit is contained in:
Sorrel Bri 2019-08-09 16:09:27 -07:00
parent 95898b7bbd
commit 91653a650b

View file

@ -474,8 +474,8 @@ function resolveCaptures(point) {
if(point.capturing.length) { if(point.capturing.length) {
point.capturing.forEach(cap => { point.capturing.forEach(cap => {
gameState.playerState[gameState.turn > 0 ? 'bCaptures' : 'wCaptures']++; gameState.playerState[gameState.turn > 0 ? 'bCaptures' : 'wCaptures']++;
cap.stone = checkKo(point) ? 'k' : 0;
cap.groupMembers = []; cap.groupMembers = [];
cap.stone = checkKo(point, cap) ? 'k' : 0;
}) })
} }
} }
@ -502,9 +502,9 @@ function clearOverlay() {
} }
} }
function checkKo(point, cap) { // currently prevents snapback //
if (!point.getLiberties().length && cap.checkNeighbors().filter(stone => stone.stone === gameState.turn * -1) function checkKo(point) { // currently prevents snapback // capturing point has no liberties and is only capturing one stone and
&& point.capturing.length === 1) return true; if (!point.getLiberties().length && point.capturing.length === 1 && !point.checkNeighbors().some(stone => stone.stone === gameState.turn)) return true;
} }
function playSound(point) { //plays louder sounds for tenuki and for captures function playSound(point) { //plays louder sounds for tenuki and for captures