quantum-chess

git clone git://git.codymlewis.com/quantum-chess.git
Log | Files | Refs | LICENSE

commit 42c583fe1aa499b595ab812ebf3dd99395553e61
parent 17654875594f653c4667b6689e765f6bab86b1aa
Author: Cody Lewis <luxdotsugi@gmail.com>
Date:   Thu,  9 Aug 2018 09:46:05 +1000

Cleanup of files

Diffstat:
A.gitignore | 14++++++++++++++
Msrc/WebApp/Board.py | 7+++++--
Msrc/WebApp/Main.py | 2+-
Dsrc/WebApp/__pycache__/Board.cpython-36.pyc | 0
Dsrc/WebApp/__pycache__/Functions.cpython-36.pyc | 0
Dsrc/WebApp/__pycache__/Main.cpython-36.pyc | 0
Dsrc/WebApp/__pycache__/Piece.cpython-36.pyc | 0
Dsrc/WebApp/__pycache__/__init__.cpython-36.pyc | 0
Msrc/WebApp/static/scripts/chess.js | 20++++++++++++++------
Dsrc/cmd/__pycache__/bishop.cpython-36.pyc | 0
Dsrc/cmd/__pycache__/board.cpython-36.pyc | 0
Dsrc/cmd/__pycache__/functions.cpython-36.pyc | 0
Dsrc/cmd/__pycache__/king.cpython-36.pyc | 0
Dsrc/cmd/__pycache__/knight.cpython-36.pyc | 0
Dsrc/cmd/__pycache__/pawn.cpython-36.pyc | 0
Dsrc/cmd/__pycache__/piece.cpython-36.pyc | 0
Dsrc/cmd/__pycache__/queen.cpython-36.pyc | 0
Dsrc/cmd/__pycache__/rook.cpython-36.pyc | 0
Msrc/cmd/play.py | 2+-
19 files changed, 35 insertions(+), 10 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1,14 @@ +venv/ + +*.pyc +__pycache__/ + +instance/ + +.pytest_cache/ +.coverage +htmlcov/ + +dist/ +build/ +*.egg-info/ diff --git a/src/WebApp/Board.py b/src/WebApp/Board.py @@ -267,4 +267,7 @@ def reset_board(): INSTANCEBOARD.reset() def play(start, end, colour, sp): - return INSTANCEBOARD.play(start, end, colour, sp)- \ No newline at end of file + return INSTANCEBOARD.play(start, end, colour, sp) + +def win(): + return INSTANCEBOARD.win()+ \ No newline at end of file diff --git a/src/WebApp/Main.py b/src/WebApp/Main.py @@ -17,6 +17,6 @@ def home(): start = clean(request.form["start"]) end = clean(request.form["end"]) success, sup_kill = Board.play(start, end, colour, sp) - return "{},{}".format("success" if success else "fail", "success" if sup_kill else "fail") + return "{},{},{}".format("success" if success else "fail", "success" if sup_kill else "fail", Board.win()) Board.reset_board() return render_template("index.html") diff --git a/src/WebApp/__pycache__/Board.cpython-36.pyc b/src/WebApp/__pycache__/Board.cpython-36.pyc Binary files differ. diff --git a/src/WebApp/__pycache__/Functions.cpython-36.pyc b/src/WebApp/__pycache__/Functions.cpython-36.pyc Binary files differ. diff --git a/src/WebApp/__pycache__/Main.cpython-36.pyc b/src/WebApp/__pycache__/Main.cpython-36.pyc Binary files differ. diff --git a/src/WebApp/__pycache__/Piece.cpython-36.pyc b/src/WebApp/__pycache__/Piece.cpython-36.pyc Binary files differ. diff --git a/src/WebApp/__pycache__/__init__.cpython-36.pyc b/src/WebApp/__pycache__/__init__.cpython-36.pyc Binary files differ. diff --git a/src/WebApp/static/scripts/chess.js b/src/WebApp/static/scripts/chess.js @@ -99,13 +99,21 @@ function postMovement(start, end) { var superpos = sp.checked ? "True" : "False"; $.post("/home", { "sp" : superpos, "colour" : colour, "start" : start, "end" : end }, function(data) { result = data.split(","); - if(result[0] == "success") { // if backend function returns true - if(result[1] == "success") { - findAndDestroy(document.getElementById(end).getElementsByClassName("piece")[0].id); - } - makeMove(start, end); + if(result[2] != "0") { // someone won + var winner = result[2] == "W" ? "Blue" : "Red"; + var winnerColour = result[2] == "W" ? "white" : "black"; + turn.innerHTML = ""; + document.getElementById("board").innerHTML = "<h1 class='display-1 text-center pc-" + winnerColour + "'>" + winner + + " Wins</h1><p class='text-center'><a href='/home'>Try again?</a></p>"; } else { - document.getElementById("error").innerHTML = "Your move was invalid"; + if(result[0] == "success") { // if backend function returns true + if(result[1] == "success") { + findAndDestroy(document.getElementById(end).getElementsByClassName("piece")[0].id); + } + makeMove(start, end); + } else { + document.getElementById("error").innerHTML = "Your move was invalid"; + } } }); convertToStart(); diff --git a/src/cmd/__pycache__/bishop.cpython-36.pyc b/src/cmd/__pycache__/bishop.cpython-36.pyc Binary files differ. diff --git a/src/cmd/__pycache__/board.cpython-36.pyc b/src/cmd/__pycache__/board.cpython-36.pyc Binary files differ. diff --git a/src/cmd/__pycache__/functions.cpython-36.pyc b/src/cmd/__pycache__/functions.cpython-36.pyc Binary files differ. diff --git a/src/cmd/__pycache__/king.cpython-36.pyc b/src/cmd/__pycache__/king.cpython-36.pyc Binary files differ. diff --git a/src/cmd/__pycache__/knight.cpython-36.pyc b/src/cmd/__pycache__/knight.cpython-36.pyc Binary files differ. diff --git a/src/cmd/__pycache__/pawn.cpython-36.pyc b/src/cmd/__pycache__/pawn.cpython-36.pyc Binary files differ. diff --git a/src/cmd/__pycache__/piece.cpython-36.pyc b/src/cmd/__pycache__/piece.cpython-36.pyc Binary files differ. diff --git a/src/cmd/__pycache__/queen.cpython-36.pyc b/src/cmd/__pycache__/queen.cpython-36.pyc Binary files differ. diff --git a/src/cmd/__pycache__/rook.cpython-36.pyc b/src/cmd/__pycache__/rook.cpython-36.pyc Binary files differ. diff --git a/src/cmd/play.py b/src/cmd/play.py @@ -18,7 +18,7 @@ if __name__ == "__main__": print("Black wins!") break print(b.toString()) - i+=1 + i += 1 if(col == 'W'): col = 'B' print("Blacks turn")