quantum-chess

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

commit 13b5128fe83295099c7a5de7e3414fd44e84f482
parent 1250fb50f598e0c42a66fd64ab42bb6c4f5d2759
Author: Cody Lewis <luxdotsugi@gmail.com>
Date:   Wed,  8 Aug 2018 11:08:55 +1000

fixed enums

Diffstat:
Msrc/WebApp/Board.py | 20++++++++++----------
Msrc/WebApp/Main.py | 3++-
Msrc/WebApp/Piece.py | 36++++++++++++++++++------------------
Msrc/WebApp/__pycache__/Board.cpython-36.pyc | 0
Msrc/WebApp/__pycache__/Main.cpython-36.pyc | 0
Msrc/WebApp/__pycache__/Piece.cpython-36.pyc | 0
Msrc/WebApp/static/scripts/chess.js | 117+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
Msrc/WebApp/templates/index.html | 13++++---------
Msrc/cmd/__pycache__/bishop.cpython-36.pyc | 0
Msrc/cmd/__pycache__/board.cpython-36.pyc | 0
Msrc/cmd/__pycache__/functions.cpython-36.pyc | 0
Msrc/cmd/__pycache__/king.cpython-36.pyc | 0
Msrc/cmd/__pycache__/knight.cpython-36.pyc | 0
Msrc/cmd/__pycache__/pawn.cpython-36.pyc | 0
Msrc/cmd/__pycache__/piece.cpython-36.pyc | 0
Msrc/cmd/__pycache__/queen.cpython-36.pyc | 0
Msrc/cmd/__pycache__/rook.cpython-36.pyc | 0
Msrc/cmd/bishop.py | 2+-
Msrc/cmd/board.py | 20++++++++++----------
Msrc/cmd/king.py | 2+-
Msrc/cmd/knight.py | 16++++++++--------
Msrc/cmd/pawn.py | 13+++++++------
Msrc/cmd/play.py | 5++---
Msrc/cmd/queen.py | 2+-
Msrc/cmd/rook.py | 2+-
25 files changed, 176 insertions(+), 75 deletions(-)

diff --git a/src/WebApp/Board.py b/src/WebApp/Board.py @@ -30,19 +30,19 @@ class Board: self.playBoard[index] = '0' def addMovement(self, i, move): # add an atomic movement unit to the index - if(move == Functions.Direction.UP): + if(move == Functions.Direction.UP.value): i = chr(ord(i[0:1])-1) + str(int(i[1:])) - elif(move == Functions.Direction.DOWN): + elif(move == Functions.Direction.DOWN.value): i = chr(ord(i[0:1])+1) + str(int(i[1:])) - elif(move == Functions.Direction.RIGHT): + elif(move == Functions.Direction.RIGHT.value): i = i[0:1] + str(int(i[1:])-1) - elif(move == Functions.Direction.LEFT): + elif(move == Functions.Direction.LEFT.value): i = i[0:1] + str(int(i[1:])+1) - elif(move == Functions.Direction.UPRIGHT): + elif(move == Functions.Direction.UPRIGHT.value): i = chr(ord(i[0:1])-1) + str(int(i[1:])-1) - elif(move == Functions.Direction.DOWNRIGHT): + elif(move == Functions.Direction.DOWNRIGHT.value): i = chr(ord(i[0:1])+1) + str(int(i[1:])-1) - elif(move == Functions.Direction.DOWNLEFT): + elif(move == Functions.Direction.DOWNLEFT.value): i = chr(ord(i[0:1])+1) + str(int(i[1:])+1) else: i = chr(ord(i[0:1])-1) + str(int(i[1:])+1) @@ -59,9 +59,9 @@ class Board: dx = int(start[1:]) - int(end[1:]) # +ve: right, -ve: left movement = self.pathToString(dx, dy) i = start - i = self.addMovement(i,movement[0:1]) - if((self.playBoard[start].getId()[1:3] != "Kn" and (movement[0:1] in ['u', 'd', 'l', 'r'])) and i != end and self.playBoard[i] != '0'): # make sure nothing is in the way - return False + i = self.addMovement(i, movement[0:1]) + # if((self.playBoard[start].getId()[1:3] != "Kn" and (movement[0:1] in ['u', 'd', 'l', 'r'])) and i != end and self.playBoard[i] != '0'): # make sure nothing is in the way + # return False if(len(movement) > 1): for j in range(1, len(movement)): i = self.addMovement(i, movement[j : j + 1]) diff --git a/src/WebApp/Main.py b/src/WebApp/Main.py @@ -16,5 +16,6 @@ def home(): colour = clean(request.form["colour"]) start = clean(request.form["start"]) end = clean(request.form["end"]) - Board.play(start, end, colour, sp) + return "success" if Board.play(start, end, colour, sp) else "fail" + # return "sp: {}, colour: {}, start: {}, end: {}".format(sp, colour, start, end) return render_template("index.html") diff --git a/src/WebApp/Piece.py b/src/WebApp/Piece.py @@ -51,9 +51,9 @@ class Pawn(Piece): moveNum = 1 if(len(moveArr) <= moveNum): if(self.colour == 'W'): - direction = Functions.Direction.UP + direction = Functions.Direction.UP.value else: - direction = Functions.Direction.DOWN + direction = Functions.Direction.DOWN.value for i in range(len(moveArr)): if(not moveArr[i] == direction): return False @@ -63,11 +63,11 @@ class Pawn(Piece): def canAttack(self, movement): moveArr = Functions.splitMovement(movement) if(self.colour == 'W'): - dir1 = Functions.Direction.UPLEFT - dir2 = Functions.Direction.UPRIGHT + dir1 = Functions.Direction.UPLEFT.value + dir2 = Functions.Direction.UPRIGHT.value else: - dir1 = Functions.Direction.DOWNLEFT - dir2 = Functions.Direction.DOWNRIGHT + dir1 = Functions.Direction.DOWNLEFT.value + dir2 = Functions.Direction.DOWNRIGHT.value if(len(moveArr) == 1 and (moveArr[0] == dir1 or moveArr[0] == dir2)): return True else: @@ -81,7 +81,7 @@ class Bishop(Piece): def canMove(self,movement): moveArr = Functions.splitMovement(movement) direction = moveArr[0] - if direction in [Functions.Direction.UPLEFT, Functions.Direction.UPRIGHT, Functions.Direction.DOWNLEFT, Functions.Direction.DOWNRIGHT]: + if direction in [Functions.Direction.UPLEFT.value, Functions.Direction.UPRIGHT.value, Functions.Direction.DOWNLEFT.value, Functions.Direction.DOWNRIGHT.value]: for i in range(1, len(moveArr)): if(direction != moveArr[i]): return False @@ -97,7 +97,7 @@ class King(Piece): moveArr = Functions.splitMovement(movement) direction = moveArr[0] if(len(moveArr) == 1): - if direction in [Functions.Direction.DOWN, Functions.Direction.UP, Functions.Direction.RIGHT, Functions.Direction.LEFT, Functions.Direction.DOWNRIGHT, Functions.Direction.DOWNLEFT, Functions.Direction.UPRIGHT, Functions.Direction.UPLEFT]: + if direction in [Functions.Direction.DOWN.value, Functions.Direction.UP.value, Functions.Direction.RIGHT.value, Functions.Direction.LEFT.value, Functions.Direction.DOWNRIGHT.value, Functions.Direction.DOWNLEFT.value, Functions.Direction.UPRIGHT.value, Functions.Direction.UPLEFT.value]: return True return False @@ -114,17 +114,17 @@ class Knight(Piece): return False def __isL(self, moveArr): - if(moveArr[0] == Functions.Direction.UP): - if(moveArr[1] == Functions.Direction.UPLEFT or moveArr[1] == Functions.Direction.UPRIGHT): + if(moveArr[0] == Functions.Direction.UP.value): + if(moveArr[1] == Functions.Direction.UPLEFT.value or moveArr[1] == Functions.Direction.UPRIGHT.value): return True - elif(moveArr[0] == Functions.Direction.DOWN): - if(moveArr[1] == Functions.Direction.DOWNLEFT or moveArr[1] == Functions.Direction.DOWNRIGHT): + elif(moveArr[0] == Functions.Direction.DOWN.value): + if(moveArr[1] == Functions.Direction.DOWNLEFT.value or moveArr[1] == Functions.Direction.DOWNRIGHT.value): return True - elif(moveArr[0] == Functions.Direction.LEFT): - if(moveArr[1] == Functions.Direction.UPLEFT or moveArr[1] == Functions.Direction.DOWNLEFT): + elif(moveArr[0] == Functions.Direction.LEFT.value): + if(moveArr[1] == Functions.Direction.UPLEFT.value or moveArr[1] == Functions.Direction.DOWNLEFT.value): return True - elif(moveArr[0] == Functions.Direction.RIGHT): - if(moveArr[1] == Functions.Direction.UPRIGHT or moveArr[1] == Functions.Direction.DOWNRIGHT): + elif(moveArr[0] == Functions.Direction.RIGHT.value): + if(moveArr[1] == Functions.Direction.UPRIGHT.value or moveArr[1] == Functions.Direction.DOWNRIGHT.value): return True else: return False @@ -137,7 +137,7 @@ class Queen(Piece): def canMove(self, movement): moveArr = Functions.splitMovement(movement) direction = moveArr[0] - if direction in [Functions.Direction.DOWN, Functions.Direction.UP, Functions.Direction.RIGHT, Functions.Direction.LEFT, Functions.Direction.DOWNRIGHT, Functions.Direction.DOWNLEFT, Functions.Direction.UPRIGHT, Functions.Direction.UPLEFT]: + if direction in [Functions.Direction.DOWN.value, Functions.Direction.UP.value, Functions.Direction.RIGHT.value, Functions.Direction.LEFT.value, Functions.Direction.DOWNRIGHT.value, Functions.Direction.DOWNLEFT.value, Functions.Direction.UPRIGHT.value, Functions.Direction.UPLEFT.value]: for i in range(1, len(moveArr)): if(direction != moveArr[i]): return False @@ -152,7 +152,7 @@ class Rook(Piece): def canMove(self, movement): moveArr = Functions.splitMovement(movement) direction = moveArr[0] - if direction in [Functions.Direction.UP, Functions.Direction.DOWN, Functions.Direction.LEFT, Functions.Direction.RIGHT]: + if direction in [Functions.Direction.UP.value, Functions.Direction.DOWN.value, Functions.Direction.LEFT.value, Functions.Direction.RIGHT.value]: for i in range(1, len(moveArr)): if direction != moveArr[i]: return False 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__/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/static/scripts/chess.js b/src/WebApp/static/scripts/chess.js @@ -1,15 +1,120 @@ +var start = "A1"; +var end = "A1"; $(document).ready(function() { - var squares = $(".square"); + var squares = document.getElementsByClassName("square"); for(var i = 0; i < squares.length; i++) { - if(squares[i].id == "") { + var count = i; + squares[count].addEventListener("click", initStart); + /*if(squares[i].innerHTML == "") { continue; - } + }*/ // add click event for each piece + // alert("#" + squares[i].id + " span"); + /*var innerSpans = squares[count].getElementsByTagName("SPAN"); + if(innerSpans[0] != undefined) { + var innerClasses = innerSpans[0].className; + squares[count].addEventListener("click", function() { + movement(squares[count].id, innerClasses); + }); + }*/ + // alert("#" + squares[i].id + " span"); } }); -function movement(classes) { +function convertToStart() { + var squares = document.getElementsByClassName("square"); + for(var i = 0; i < squares.length; i++) { + var count = i; + squares[count].removeEventListener("click", initEnd); + squares[count].addEventListener("click", initStart); + } +} + +function initStart() { + start = this.id; + convertToEnd(); +} + +function convertToEnd() { + var squares = document.getElementsByClassName("square"); + for(var i = 0; i < squares.length; i++) { + var count = i; + squares[count].removeEventListener("click", initStart); + squares[count].addEventListener("click", initEnd); + } +} + +function initEnd() { + end = this.id; + postMovement(start, end); +} + +function movement(id, classes) { // determine movement spaces based on piece classes + var yAxis = "ABCDEFGH"; + var direction = 1; + var xCoOrd = id[1]; + var xMax = 0; + var yCoOrd = yAxis.indexOf(id[0]); + var yMax = 0; + var movementSpace; + var i; + var left; + var right; + var up; + var down; + var curSpace; + if(classes.indexOf("pawn") > -1) { + direction = classes.indexOf("white") > -1 ? -1 : 1; + yMax = yCoOrd == 1 || yCoOrd == 6 ? 2 : 1; + for(i = 0; i < yMax; i++) { + curSpace = yAxis[yCoOrd + (i * direction)] + xCoOrd; + movementSpace = document.getElementById(curSpace); + if(movementSpace.innerHTML == "") { + movementSpace.className += "move-space"; + movementSpace.addEventListener("click", function() { + postMovement(id, movementSpace.id); + }); + } + } + } else if(classes.indexOf("rook") > -1) { + for(left = xCoOrd; left > 0; left--) { + curSpace = yAxis[yCoOrd] + left; + movementSpace = $("#" + curSpace); + if(movementSpace.innerHTML == "") { + break; + } + movementSpace.className += "move-space"; + movementSpace.addEventListener("click", function() { postMovement(id, movementSpace.id); }); + movementSpace.removeEventListener("click", function() { postMovement(id, movementSpace.id); }); + } + } } -// post plays to backend, then change board based on response- \ No newline at end of file +// post plays to backend, then change board based on response +function postMovement(start, end) { + var turn = document.getElementById("turn"); + var colour = turn.innerHTML == "Blue's Turn" ? "W" : "B"; + var validMove; + superpos = sp.value == "checked" ? "True" : "False"; + $.post("/home", { "sp" : superpos, "colour" : colour, "start" : start, "end" : end }, function(data) { + // validMove = data; + alert("start: " + start + " end: " + end + " sp: " + superpos + " colour: " + colour); + alert(data); + }); + if(validMove) { + // if backend function returns true + var startSquare = document.getElementById(start); + var endSquare = document.getElementById(end); + endSquare.innerHTML = startSquare.innerHTML; + startSquare.innerHTML = ""; + if(turn.innerHTML == "Blue's Turn") { + turn.innerHTML = "Red's Turn"; + turn.className = "pc-black text-center"; + } else { + turn.innerHTML = "Blue's Turn"; + turn.className = "pc-white text-center"; + } + } + convertToStart(); +}+ \ No newline at end of file diff --git a/src/WebApp/templates/index.html b/src/WebApp/templates/index.html @@ -10,21 +10,16 @@ {% block contents %} <div class="container-fluid bg-light"> - <h1 class="display-1 text-center">Quantum Chess</h1> + <!-- <h1 class="display-1 text-center">Quantum Chess</h1> --> <br /> + <p class="pc-white text-center" id="turn">Blue's Turn</p> <div class="container"> <div class="container" id="board"> {% for i in range(0, 8) %} <div class="row"> <div class="col-sm-2 text-right"></div> {% for j in range(0, 8) %} - <div class="col-1 - {% if ((j % 2) == (i % 2)) %} - bg-dark - {% else %} - bg-light - {% endif %} - square" id="{{ "ABCDEFGH"[i] }}{{ j + 1 }}"> + <div class="col-1 {% if ((j % 2) == (i % 2)) %}bg-dark{% else %}bg-light{% endif %} square" id="{{ "abcgefgh"[i] }}{{ j + 1 }}"> {% if i in [0, 1, 6, 7] %} <span class="piece text-center fa {% if i in [0, 7] %} @@ -40,7 +35,7 @@ fa-chess-king {% endif %} {% else %} - fa-chess-pawn first-move + fa-chess-pawn {% endif %} {% if i in [0, 1] %} pc-black 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/bishop.py b/src/cmd/bishop.py @@ -12,7 +12,7 @@ class Bishop(piece.Piece): def canMove(self,movement): moveArr = functions.splitMovement(movement) direction = moveArr[0] - if direction in [Direction.UPLEFT, Direction.UPRIGHT, Direction.DOWNLEFT, Direction.DOWNRIGHT]: + if direction in [Direction.UPLEFT.value, Direction.UPRIGHT.value, Direction.DOWNLEFT.value, Direction.DOWNRIGHT.value]: for i in range(1, len(moveArr)): if(direction != moveArr[i]): return False diff --git a/src/cmd/board.py b/src/cmd/board.py @@ -41,19 +41,19 @@ class Board: self.playBoard[index] = '0' def addMovement(self, i, move): # add an atomic movement unit to the index - if(move == Direction.UP): + if(move == Direction.UP.value): i = chr(ord(i[0:1])-1) + str(int(i[1:])) - elif(move == Direction.DOWN): + elif(move == Direction.DOWN.value): i = chr(ord(i[0:1])+1) + str(int(i[1:])) - elif(move == Direction.RIGHT): + elif(move == Direction.RIGHT.value): i = i[0:1] + str(int(i[1:])-1) - elif(move == Direction.LEFT): + elif(move == Direction.LEFT.value): i = i[0:1] + str(int(i[1:])+1) - elif(move == Direction.UPRIGHT): + elif(move == Direction.UPRIGHT.value): i = chr(ord(i[0:1])-1) + str(int(i[1:])-1) - elif(move == Direction.DOWNRIGHT): + elif(move == Direction.DOWNRIGHT.value): i = chr(ord(i[0:1])+1) + str(int(i[1:])-1) - elif(move == Direction.DOWNLEFT): + elif(move == Direction.DOWNLEFT.value): i = chr(ord(i[0:1])+1) + str(int(i[1:])+1) else: i = chr(ord(i[0:1])-1) + str(int(i[1:])+1) @@ -70,9 +70,9 @@ class Board: dx = int(start[1:]) - int(end[1:]) # +ve: right, -ve: left movement = self.pathToString(dx, dy) i = start - i = self.addMovement(i,movement[0:1]) - if((self.playBoard[start].getId()[1:3] != "Kn" and (movement[0:1] in ['u', 'd', 'l', 'r'])) and i != end and self.playBoard[i] != '0'): # make sure nothing is in the way - return False + i = self.addMovement(i, movement[0:1]) + # if((self.playBoard[start].getId()[1:3] != "Kn" and (movement[0:1] in ['u', 'd', 'l', 'r'])) and i != end and self.playBoard[i] != '0'): # make sure nothing is in the way + # return False if(len(movement) > 1): for j in range(1, len(movement)): i = self.addMovement(i, movement[j : j + 1]) diff --git a/src/cmd/king.py b/src/cmd/king.py @@ -14,6 +14,6 @@ class King(piece.Piece): moveArr = functions.splitMovement(movement) direction = moveArr[0] if(len(moveArr) == 1): - if direction in [Direction.DOWN, Direction.UP, Direction.RIGHT, Direction.LEFT, Direction.DOWNRIGHT, Direction.DOWNLEFT, Direction.UPRIGHT, Direction.UPLEFT]: + if direction in [Direction.DOWN.value, Direction.UP.value, Direction.RIGHT.value, Direction.LEFT.value, Direction.DOWNRIGHT.value, Direction.DOWNLEFT.value, Direction.UPRIGHT.value, Direction.UPLEFT.value]: return True return False diff --git a/src/cmd/knight.py b/src/cmd/knight.py @@ -18,17 +18,17 @@ class Knight(piece.Piece): return False def __isL(self, moveArr): - if(moveArr[0] == Direction.UP): - if(moveArr[1] == Direction.UPLEFT or moveArr[1] == Direction.UPRIGHT): + if moveArr[0] == Direction.UP.value: + if moveArr[1] == Direction.UPLEFT.value or moveArr[1] == Direction.UPRIGHT.value: return True - elif(moveArr[0] == Direction.DOWN): - if(moveArr[1] == Direction.DOWNLEFT or moveArr[1] == Direction.DOWNRIGHT): + elif moveArr[0] == Direction.DOWN.value: + if moveArr[1] == Direction.DOWNLEFT.value or moveArr[1] == Direction.DOWNRIGHT.value: return True - elif(moveArr[0] == Direction.LEFT): - if(moveArr[1] == Direction.UPLEFT or moveArr[1] == Direction.DOWNLEFT): + elif moveArr[0] == Direction.LEFT.value: + if moveArr[1] == Direction.UPLEFT.value or moveArr[1] == Direction.DOWNLEFT.value: return True - elif(moveArr[0] == Direction.RIGHT): - if(moveArr[1] == Direction.UPRIGHT or moveArr[1] == Direction.DOWNRIGHT): + elif moveArr[0] == Direction.RIGHT.value: + if moveArr[1] == Direction.UPRIGHT.value or moveArr[1] == Direction.DOWNRIGHT.value: return True else: return False diff --git a/src/cmd/pawn.py b/src/cmd/pawn.py @@ -20,9 +20,10 @@ class Pawn(piece.Piece): moveNum = 1 if(len(moveArr) <= moveNum): if(self.colour == 'W'): - direction = Direction.UP + direction = Direction.UP.value else: - direction = Direction.DOWN + direction = Direction.DOWN.value + print(direction) for i in range(len(moveArr)): if(not moveArr[i] == direction): return False @@ -32,11 +33,11 @@ class Pawn(piece.Piece): def canAttack(self, movement): moveArr = functions.splitMovement(movement) if(self.colour == 'W'): - dir1 = Direction.UPLEFT - dir2 = Direction.UPRIGHT + dir1 = Direction.UPLEFT.value + dir2 = Direction.UPRIGHT.value else: - dir1 = Direction.DOWNLEFT - dir2 = Direction.DOWNRIGHT + dir1 = Direction.DOWNLEFT.value + dir2 = Direction.DOWNRIGHT.value if(len(moveArr) == 1 and (moveArr[0] == dir1 or moveArr[0] == dir2)): return True else: diff --git a/src/cmd/play.py b/src/cmd/play.py @@ -17,7 +17,6 @@ if __name__ == "__main__": elif(winVal == 'B'): print("Black wins!") break - print(b.toString()) i+=1 if(col == 'W'): @@ -28,12 +27,12 @@ if __name__ == "__main__": print("Whites turn") while(True): superPos = str(input("Do you want to super-position (y/n)? ")) - if(re.match(pattern,superPos)): + if(re.match(pattern, superPos)): print('Super-position mode on') sp = True start = str(input("Choose your starting piece: ")) end = str(input("Choose your end place: ")) - if(b.play(start,end,col,sp)): + if(b.play(start, end, col, sp)): sp = False break else: diff --git a/src/cmd/queen.py b/src/cmd/queen.py @@ -12,7 +12,7 @@ class Queen(piece.Piece): def canMove(self, movement): moveArr = functions.splitMovement(movement) direction = moveArr[0] - if direction in [Direction.DOWN, Direction.UP, Direction.RIGHT, Direction.LEFT, Direction.DOWNRIGHT, Direction.DOWNLEFT, Direction.UPRIGHT, Direction.UPLEFT]: + if direction in [Direction.DOWN.value, Direction.UP.value, Direction.RIGHT.value, Direction.LEFT.value, Direction.DOWNRIGHT.value, Direction.DOWNLEFT.value, Direction.UPRIGHT.value, Direction.UPLEFT.value]: for i in range(1, len(moveArr)): if(direction != moveArr[i]): return False diff --git a/src/cmd/rook.py b/src/cmd/rook.py @@ -12,7 +12,7 @@ class Rook(piece.Piece): def canMove(self, movement): moveArr = functions.splitMovement(movement) direction = moveArr[0] - if direction in [Direction.UP, Direction.DOWN, Direction.LEFT, Direction.RIGHT]: + if direction in [Direction.UP.value, Direction.DOWN.value, Direction.LEFT.value, Direction.RIGHT.value]: for i in range(1, len(moveArr)): if direction != moveArr[i]: return False