initial
This commit is contained in:
commit
3ea7bfd5dc
122 changed files with 568704 additions and 0 deletions
77
Scripts/Rules/bishop.gd
Executable file
77
Scripts/Rules/bishop.gd
Executable file
|
|
@ -0,0 +1,77 @@
|
|||
extends Rule
|
||||
|
||||
static func ready(piece: Piece):
|
||||
pass
|
||||
|
||||
static func select(piece: Piece, game: Game):
|
||||
|
||||
var pos = piece.to_coord()
|
||||
var board_size = game.get_node("Board").board_size
|
||||
print("Board Size: ", board_size)
|
||||
print("Bishop Pos:", pos)
|
||||
#piece.possible_movements = []
|
||||
|
||||
var tiles_to_left: int = board_size.x-1 - pos.x
|
||||
print("tiles to left: ", tiles_to_left)
|
||||
var tiles_to_right: int = (board_size.x-1) - ((board_size.x-1) - pos.x)
|
||||
print("tiles to right: ", tiles_to_right)
|
||||
var tiles_to_top: int = board_size.y-1 - pos.y
|
||||
print("tiles to top: ", tiles_to_top)
|
||||
var tiles_to_bottom: int = (board_size.y-1) - ((board_size.y-1) - pos.y)
|
||||
print("tiles to bottom: ", tiles_to_bottom)
|
||||
|
||||
#left down
|
||||
for x in range(pos.x+1, board_size.x, 1):
|
||||
var move = Vector2i(x - pos.x, -(x - pos.x) )
|
||||
var other_piece = game.get_piece_at(move+pos)
|
||||
if other_piece:
|
||||
if other_piece.is_in_group("Enemy"):
|
||||
piece.possible_movements.append(move)
|
||||
break
|
||||
piece.possible_movements.append(move)
|
||||
|
||||
#right down
|
||||
for x in range(pos.x-1, -1, -1):
|
||||
var move = Vector2i(x -pos.x, x-pos.x)
|
||||
var other_piece = game.get_piece_at(move+pos)
|
||||
if pos.x + move.x < 0:
|
||||
continue
|
||||
if pos.y + move.y < 0:
|
||||
continue
|
||||
if other_piece:
|
||||
if other_piece.is_in_group("Enemy"):
|
||||
piece.possible_movements.append(move)
|
||||
break
|
||||
piece.possible_movements.append(move)
|
||||
|
||||
#left up
|
||||
for x in range(pos.x+1, board_size.x, 1):
|
||||
var move = Vector2i(x - pos.x, (x - pos.x) )
|
||||
var other_piece = game.get_piece_at(move+pos)
|
||||
if other_piece:
|
||||
if other_piece.is_in_group("Enemy"):
|
||||
piece.possible_movements.append(move)
|
||||
break
|
||||
piece.possible_movements.append(move)
|
||||
|
||||
#right up
|
||||
for x in range(pos.x-1, -1, -1):
|
||||
var move = Vector2i(x -pos.x, -(x - pos.x))
|
||||
var other_piece = game.get_piece_at(move+pos)
|
||||
if pos.x + move.x < 0:
|
||||
continue
|
||||
if pos.y + move.y < 0:
|
||||
continue
|
||||
if other_piece:
|
||||
if other_piece.is_in_group("Enemy"):
|
||||
piece.possible_movements.append(move)
|
||||
break
|
||||
piece.possible_movements.append(move)
|
||||
|
||||
for move in piece.possible_movements:
|
||||
pass
|
||||
|
||||
pass
|
||||
|
||||
static func before_move(piece: Piece):
|
||||
pass
|
||||
1
Scripts/Rules/bishop.gd.uid
Executable file
1
Scripts/Rules/bishop.gd.uid
Executable file
|
|
@ -0,0 +1 @@
|
|||
uid://cfwpyvuiwr1ph
|
||||
20
Scripts/Rules/king.gd
Executable file
20
Scripts/Rules/king.gd
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
extends Rule
|
||||
|
||||
static func ready(piece: Piece):
|
||||
pass
|
||||
|
||||
static func select(piece: Piece, game: Game):
|
||||
piece.possible_movements = [
|
||||
Vector2i(-1,0),
|
||||
Vector2i(1,0),
|
||||
Vector2i(-1,-1),
|
||||
Vector2i(1,1),
|
||||
Vector2i(0,1),
|
||||
Vector2i(0,-1),
|
||||
Vector2i(-1,1),
|
||||
Vector2i(1,-1),
|
||||
]
|
||||
pass
|
||||
|
||||
static func before_move(piece: Piece):
|
||||
pass
|
||||
1
Scripts/Rules/king.gd.uid
Executable file
1
Scripts/Rules/king.gd.uid
Executable file
|
|
@ -0,0 +1 @@
|
|||
uid://c0ha05qj3xk65
|
||||
20
Scripts/Rules/knight.gd
Executable file
20
Scripts/Rules/knight.gd
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
extends Rule
|
||||
|
||||
static func ready(piece: Piece):
|
||||
pass
|
||||
|
||||
static func select(piece: Piece, game: Game):
|
||||
piece.possible_movements = [
|
||||
Vector2i(-1,2),
|
||||
Vector2i(1,2),
|
||||
Vector2i(-1,-2),
|
||||
Vector2i(1,-2),
|
||||
Vector2i(-2,1),
|
||||
Vector2i(2,1),
|
||||
Vector2i(-2,-1),
|
||||
Vector2i(2,-1),
|
||||
]
|
||||
pass
|
||||
|
||||
static func before_move(piece: Piece):
|
||||
pass
|
||||
1
Scripts/Rules/knight.gd.uid
Executable file
1
Scripts/Rules/knight.gd.uid
Executable file
|
|
@ -0,0 +1 @@
|
|||
uid://dsea2mlyank46
|
||||
39
Scripts/Rules/pawn.gd
Executable file
39
Scripts/Rules/pawn.gd
Executable file
|
|
@ -0,0 +1,39 @@
|
|||
extends Rule
|
||||
|
||||
static func ready(piece: Piece):
|
||||
piece.possible_movements = [
|
||||
Vector2i(0,1),
|
||||
Vector2i(0,2)
|
||||
]
|
||||
pass
|
||||
|
||||
static func select(piece: Piece, game: Game):
|
||||
var pos = piece.to_coord()
|
||||
piece.possible_movements = []
|
||||
|
||||
var max_steps = 1
|
||||
if piece.to_coord() == piece.start_coord:
|
||||
max_steps = 2
|
||||
for y in range(1, max_steps+1, 1):
|
||||
var move = Vector2i(0,y)
|
||||
var other_piece = game.get_piece_at(move+pos)
|
||||
if other_piece:
|
||||
break
|
||||
piece.possible_movements.append(move)
|
||||
|
||||
#Vector2i(piece.position.x / 2 + move.x, piece.position.z / 2 + move.y)
|
||||
var top_left_tile = Vector2i(piece.position.x / 2 + 1, piece.position.z / 2 +1)
|
||||
var top_right_tile = Vector2i(piece.position.x / 2 - 1, piece.position.z / 2 +1)
|
||||
for enemy in game.get_node("Pieces").get_children():
|
||||
if enemy.is_in_group("Enemy"):
|
||||
var enemy_coord = Vector2i(enemy.position.x / 2, enemy.position.z / 2)
|
||||
|
||||
if enemy_coord == top_left_tile:
|
||||
piece.possible_movements.append(Vector2i(1,1))
|
||||
if enemy_coord == top_right_tile:
|
||||
piece.possible_movements.append(Vector2i(-1,1))
|
||||
|
||||
pass
|
||||
|
||||
static func before_move(piece: Piece):
|
||||
pass
|
||||
1
Scripts/Rules/pawn.gd.uid
Executable file
1
Scripts/Rules/pawn.gd.uid
Executable file
|
|
@ -0,0 +1 @@
|
|||
uid://cnc4cqr4eu4yh
|
||||
55
Scripts/Rules/rook.gd
Executable file
55
Scripts/Rules/rook.gd
Executable file
|
|
@ -0,0 +1,55 @@
|
|||
extends Rule
|
||||
|
||||
static func ready(piece: Piece):
|
||||
pass
|
||||
|
||||
static func select(piece: Piece, game: Game):
|
||||
|
||||
var pos = piece.to_coord()
|
||||
var board_size = game.get_node("Board").board_size
|
||||
piece.possible_movements = []
|
||||
|
||||
# alle felder nach links:
|
||||
for x in range(pos.x+1, board_size.x, 1):
|
||||
var move = Vector2i(x - pos.x, 0)
|
||||
var other_piece = game.get_piece_at(move+pos)
|
||||
if other_piece:
|
||||
if other_piece.is_in_group("Enemy"):
|
||||
piece.possible_movements.append(move)
|
||||
break
|
||||
piece.possible_movements.append(move)
|
||||
|
||||
for x in range(pos.x - 1, -1, -1):
|
||||
var move = Vector2i(x - pos.x, 0)
|
||||
var other_piece = game.get_piece_at(move+pos)
|
||||
if other_piece:
|
||||
if other_piece.is_in_group("Enemy"):
|
||||
piece.possible_movements.append(move)
|
||||
break
|
||||
piece.possible_movements.append(move)
|
||||
|
||||
for y in range(pos.y+1, board_size.y, 1):
|
||||
var move = Vector2i(0,y - pos.y)
|
||||
var other_piece = game.get_piece_at(move+pos)
|
||||
if other_piece:
|
||||
if other_piece.is_in_group("Enemy"):
|
||||
piece.possible_movements.append(move)
|
||||
break
|
||||
piece.possible_movements.append(move)
|
||||
|
||||
for y in range(pos.y - 1, -1, -1):
|
||||
var move = Vector2i(0,y - pos.y)
|
||||
var other_piece = game.get_piece_at(move+pos)
|
||||
if other_piece:
|
||||
if other_piece.is_in_group("Enemy"):
|
||||
piece.possible_movements.append(move)
|
||||
break
|
||||
piece.possible_movements.append(move)
|
||||
|
||||
for move in piece.possible_movements:
|
||||
pass
|
||||
|
||||
pass
|
||||
|
||||
static func before_move(piece: Piece):
|
||||
pass
|
||||
1
Scripts/Rules/rook.gd.uid
Executable file
1
Scripts/Rules/rook.gd.uid
Executable file
|
|
@ -0,0 +1 @@
|
|||
uid://by68phh60fpjr
|
||||
13
Scripts/rule.gd
Executable file
13
Scripts/rule.gd
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
extends Node
|
||||
class_name Rule
|
||||
|
||||
|
||||
|
||||
static func ready(piece: Piece):
|
||||
pass
|
||||
|
||||
static func select(piece: Piece, game: Game):
|
||||
pass
|
||||
|
||||
static func before_move(piece: Piece):
|
||||
pass
|
||||
1
Scripts/rule.gd.uid
Executable file
1
Scripts/rule.gd.uid
Executable file
|
|
@ -0,0 +1 @@
|
|||
uid://bm7f2mxksxp82
|
||||
Loading…
Add table
Add a link
Reference in a new issue