online multiplayer chess game (note server currently down)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
extends Node

const WHITE = true
const BLACK = false

var __nosethalfmove := false
var pawns := []  # PoolPawnArray
var team := true
var grid: Grid = null
var piece_set := "california"
var fullmove := 1
var halfmove := 0
var in_check := false
var checking_piece: Piece = null
var board_color1: Color = Color(0.870588, 0.890196, 0.901961)
var board_color2: Color = Color(0.54902, 0.635294, 0.678431)
var white_king: King = null
var black_king: King = null
var spectating := false
var chat: Chat = null
var turn := true  # true for white, false for black
# true cuz white goes first


func reset_vars() -> void:
	__nosethalfmove = false
	pawns = []
	team = true
	spectating = false
	grid = null
	fullmove = 1
	halfmove = 0
	in_check = false
	checking_piece = null
	white_king = null
	black_king = null
	turn = true
	Utils.reset_vars()


func reset_halfmove() -> void:
	halfmove = 0
	__nosethalfmove = true


func add_turn() -> void:
	Events.emit_signal("just_before_turn_over")
	turn = not turn
	if turn:  #  white just moved
		fullmove += 1
	if __nosethalfmove:
		__nosethalfmove = false
	else:
		halfmove += 1
	Events.emit_signal("turn_over")


func str_bool(b: bool) -> String:
	return "white" if b else "black"


func get_turn() -> String:
	return str_bool(turn)


func get_team() -> String:
	return str_bool(team)


func _ready() -> void:
	Log.info("startup")
	VisualServer.set_default_clear_color(Color.black)
	Debug.monitor(self, "fullmove")
	Debug.monitor(self, "halfmove")
	Debug.monitor(self, "in_check")
	Debug.monitor(self, "turn", "get_turn()")
	Debug.monitor(self, "team", "get_team()")
	Debug.monitor(self, "static memory", "get_static_memory()")
	Debug.monitor(self, "dynamic memory", "get_dynamic_memory()")
	Debug.monitor(Engine, "fps", "get_frames_per_second()")


func get_static_memory() -> String:
	return String.humanize_size(OS.get_static_memory_usage())


func get_dynamic_memory() -> String:
	return String.humanize_size(OS.get_dynamic_memory_usage())