online multiplayer chess game (note server currently down)
fixed: works, mostly
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | Grid.gd | 2 | ||||
| -rw-r--r-- | pieces/Piece.gd | 19 | ||||
| -rw-r--r-- | pieces/Queen.gd | 28 |
4 files changed, 11 insertions, 39 deletions
@@ -1,2 +1,3 @@ .import/ logs/ +*.sh @@ -41,8 +41,6 @@ func check_in_check(): # check if in_check for j in range(0, 8): # for each column var spot = matrix[i][j] # get the square if spot and spot.white != Globals.turn: # enemie - if spot.shortname == "qW": - print("going through white queen") if matrix[i][j].can_check_king(Globals.white_king if Globals.turn else Globals.black_king): # if it can take the king Globals.in_check = true # set in_check Globals.checking_piece = matrix[i][j] # set checking_piece diff --git a/pieces/Piece.gd b/pieces/Piece.gd index 676c37f..5c10d2b 100644 --- a/pieces/Piece.gd +++ b/pieces/Piece.gd @@ -87,12 +87,12 @@ func traverse(arr = [Vector2.UP, Vector2.DOWN, Vector2.LEFT, Vector2.RIGHT]): break if at_pos(pos) != null: # only one black - if check_spots_check: - if checkcheck(pos): - circle_array.append(pos) - break - break + # if check_spots_check: + # if checkcheck(pos): + circle_array.append(pos) break + # break + # break if check_spots_check: if !checkcheck(pos): continue @@ -112,15 +112,16 @@ func get_attacks(): # @Override var moves = get_moves() # assumes the attacks are same as moves var final = [] for i in moves: - if at_pos(i) != null and at_pos(i).white != white: - final.append(i) + if at_pos(i) != null: + if at_pos(i).white != white: # attack ze enemie + final.append(i) return final func can_check_king(king): check_spots_check = false - for attackable in get_attacks(): - if at_pos(attackable) == king: + for attack in get_attacks(): + if at_pos(attack) == king: check_spots_check = true return true check_spots_check = true diff --git a/pieces/Queen.gd b/pieces/Queen.gd index d500356..2ce7689 100644 --- a/pieces/Queen.gd +++ b/pieces/Queen.gd @@ -6,34 +6,6 @@ func get_moves(): return traverse(all_dirs()) -func get_attacks(): # @Override - var moves = get_moves() # assumes the attacks are same as moves - var final = [] - print("getting attacks from moves, moves: " + str(moves)) - for i in moves: - if at_pos(i) != null and at_pos(i).white != white: - final.append(i) - print("final: " + str(final)) - return final - - -func can_check_king(king): - print("queen looking for king") - check_spots_check = false - print("starting the loop") - var attacks = get_attacks() - print("get attacks is: " + str(attacks)) - # assert(get_attacks()) - for attack in attacks: - if at_pos(attack) == king: - print("queen found king") - check_spots_check = true - return true - print(str(attack) + " was not king") - check_spots_check = true - return false - - func _ready(): ._ready() shortname = "q" + team |