MCPcopy Index your code
hub / github.com/python-websockets/websockets / playMove

Function playMove

example/tutorial/step3/connect4.js:26–43  ·  view source on GitHub ↗
(board, player, column, row)

Source from the content-addressed store, hash-verified

24}
25
26function playMove(board, player, column, row) {
27 // Check values of arguments.
28 if (player !== PLAYER1 && player !== PLAYER2) {
29 throw new Error(`player must be ${PLAYER1} or ${PLAYER2}.`);
30 }
31 const columnElement = board.querySelectorAll(".column")[column];
32 if (columnElement === undefined) {
33 throw new RangeError("column must be between 0 and 6.");
34 }
35 const cellElement = columnElement.querySelectorAll(".cell")[row];
36 if (cellElement === undefined) {
37 throw new RangeError("row must be between 0 and 5.");
38 }
39 // Place checker in cell.
40 if (!cellElement.classList.replace("empty", player)) {
41 throw new Error("cell must be empty.");
42 }
43}
44
45export { PLAYER1, PLAYER2, createBoard, playMove };

Callers 1

receiveMovesFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…