summaryrefslogtreecommitdiff
path: root/src/engine/turns.js
blob: 0906932a3687026d2161acbac47289d1f8ab5c2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { PLAYER } from "../constants.js"
import { placeLinks } from "../engine/placeLinks.js"
import { removeDeadStones } from "../engine/death.js"

export let playerTurn = "black"

export function nextTurn({move = null}) {
    if (move != null) removeDeadStones(move)
    changeTurn()
    startTurn()
}

export function startTurn() {
    placeLinks()
}

function changeTurn() {
    playerTurn = playerTurn == PLAYER.BLACK ? PLAYER.WHITE : PLAYER.BLACK
}