From b366c2cdcbc75ada29d3fe5ab593c55ee036a9e4 Mon Sep 17 00:00:00 2001 From: AUnicornWithNoLife Date: Mon, 12 Apr 2021 11:28:49 +0100 Subject: [PATCH] info --- src/code.js | 60 +++++++++++++++----------------------------------- src/index.html | 9 ++++++-- src/style.css | 6 +++++ src/var.js | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+), 44 deletions(-) create mode 100644 src/var.js diff --git a/src/code.js b/src/code.js index 199e799..3ded689 100644 --- a/src/code.js +++ b/src/code.js @@ -1,44 +1,3 @@ -var board; - -function load() -{ - board = - [ - [ - [0, document.getElementById("id00")], - [0, document.getElementById("id01")], - [0, document.getElementById("id02")] - ], - [ - [0, document.getElementById("id10")], - [0, document.getElementById("id11")], - [0, document.getElementById("id12")] - ], - [ - [0, document.getElementById("id20")], - [0, document.getElementById("id21")], - [0, document.getElementById("id22")] - ] - ]; -} - -var ids = -{ - '00': [0, 0], - '01': [0, 1], - '02': [0, 2], - - '10': [1, 0], - '11': [1, 1], - '12': [1, 2], - - '20': [2, 0], - '21': [2, 1], - '22': [2, 2] -}; - -var ptm = 1; - function move(id) { if (board[ids[id][0]][ids[id][1]][0] != 0) @@ -68,10 +27,27 @@ function move(id) if (winner != 0) { - alert(winner); + score[winner - 1]++; + + info['score'].innerHTML = score[0] + " | " + score[1]; + info['go'] = "X's Go"; + + ptm = 1; reset(); + return; } + + if (ptm == 1) + { + charater = "X"; + } + else + { + charater = "O"; + } + + info['go'].innerHTML = charater + "'s Go"; } function win() diff --git a/src/index.html b/src/index.html index f7f03f7..09fd717 100644 --- a/src/index.html +++ b/src/index.html @@ -6,6 +6,7 @@ + @@ -52,11 +53,15 @@ -

Score:

+

0 | 0


-

X Go

+

X's Go

+ +
+ + diff --git a/src/style.css b/src/style.css index 2626c12..b8955a5 100644 --- a/src/style.css +++ b/src/style.css @@ -23,6 +23,12 @@ button margin-right: auto; } +#reset +{ + height: 50px; + width: 150px; +} + * { background-color: black; diff --git a/src/var.js b/src/var.js new file mode 100644 index 0000000..7256c6e --- /dev/null +++ b/src/var.js @@ -0,0 +1,56 @@ +var board; +var info; +var score; +var ids; +var ptm; + +function load() +{ + board = + [ + [ + [0, document.getElementById("id00")], + [0, document.getElementById("id01")], + [0, document.getElementById("id02")] + ], + [ + [0, document.getElementById("id10")], + [0, document.getElementById("id11")], + [0, document.getElementById("id12")] + ], + [ + [0, document.getElementById("id20")], + [0, document.getElementById("id21")], + [0, document.getElementById("id22")] + ] + ]; + + info = + { + "score": document.getElementById("score"), + "go": document.getElementById("go") + }; + + score = + [ + 0, + 0 + ]; + + ids = + { + '00': [0, 0], + '01': [0, 1], + '02': [0, 2], + + '10': [1, 0], + '11': [1, 1], + '12': [1, 2], + + '20': [2, 0], + '21': [2, 1], + '22': [2, 2] + }; + + ptm = 1; +} \ No newline at end of file