browser-go-proto/js/main.js

31 lines
708 B
JavaScript
Raw Normal View History

2019-07-26 17:17:23 +00:00
/*----- constants -----*/
2019-07-26 18:02:30 +00:00
const COLORS = {
'0': 'white',
'1': 'purple',
'-1': 'lime'
};
2019-07-26 17:17:23 +00:00
/*----- app's state (variables) -----*/
2019-07-26 18:02:30 +00:00
let board, turn, winner;
2019-07-26 17:17:23 +00:00
/*----- cached element references -----*/
/*----- event listeners -----*/
2019-07-26 18:02:30 +00:00
/*----- functions -----*/
function init() {
board = [
[0, 0, 0, 0, 0, 0], // column 1 (index 0)
[0, 0, 0, 0, 0, 0], // column 2 (index 1)
[0, 0, 0, 0, 0, 0], // column 3 (index 2)
[0, 0, 0, 0, 0, 0], // column 4 (index 3)
[0, 0, 0, 0, 0, 0], // column 5 (index 4)
[0, 0, 0, 0, 0, 0], // column 6 (index 5)
[0, 0, 0, 0, 0, 0], // column 7 (index 6)
];
turn = 1;
winner = null; // 1, -1, null (no winner), 'T' (tie)
}