aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/site/game.js
diff options
context:
space:
mode:
authorJean-Pierre Appel <jeanpierre.appel01@gmail.com>2023-10-23 01:34:33 -0400
committerJean-Pierre Appel <jeanpierre.appel01@gmail.com>2023-10-23 01:34:33 -0400
commit424be4138123e7d8e2e9fef36c71e1638d4e6b2a (patch)
treebc7339af6966ff78fd3ee7fbfe05c4e7974bb256 /site/game.js
parent7815a927374db87393d104d095b5de8dfd3a3488 (diff)
testing wsgi post
Diffstat (limited to 'site/game.js')
-rw-r--r--site/game.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/site/game.js b/site/game.js
new file mode 100644
index 0000000..4a5eff9
--- /dev/null
+++ b/site/game.js
@@ -0,0 +1,56 @@
+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);
+}