const order = document.getElementById("graphOrder"); //TODO: read in player's name function foo(){ console.log(order.valueAsNumber); } function getNimber(length){ //TODO: copy from fast_p_sage //TODO: put in seperate file } function createGame(length){ const game = { board: Array(length).fill(1), turn: getNimber(length) > 0 ? "computer" : "human", finished: false, result: "In Progress...", //FIXME: turn shouldn't be an argument, //FIXME: human and computer Play needs the game as an argument nextTurn: (turn) => { if(turn === "computer") computerPlay() else humanPlay() } } //TODO: create game in DOM return game; } function computerPlay(game){ } function humanPlay(game){ } function renderGame(game){ //TODO: update game in DOM } function displayMessage(text){ } function playGame(){ const length = order.valueAsNumber; const game = createGame(length); while(!game.finished){ game.nextTurn(game.turn); } displayMessage(game.result); }