#!/usr/bin/tclsh
# OpenVerse Server Program
# Modified by Andy Goth <unununium@openverse.org>
# Now it runs a GothChess room!
# 
#
# Module Name		- GothChess initialization procs
# Current Maintainter 	- Andy Goth <unununium@openverse.org>
# Sourced By		- gothchess.tcl
#
# Copyright (C) 1999 David Gale <cruise@openverse.org>
# For more information visit http://OpenVerse.org/
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
# USA.

global chess MVS

# Set up the tell registry
lappend MVS(tell_registry) "tell_startstop on_startstop"
lappend MVS(tell_registry) "tell_exit on_exit"
lappend MVS(tell_registry) "tell_rook on_rook"
lappend MVS(tell_registry) "tell_knight on_knight"
lappend MVS(tell_registry) "tell_bishop on_bishop"
lappend MVS(tell_registry) "tell_queen on_queen"

# Set up tell registry for squares
for {set y 0} {$y < 8} {incr y} {
    for {set x 0} {$x < 8} {incr x} {
	set tell_name "tell_square_$x"
	append tell_name "_$y"

	# Add this square to the registry
	lappend MVS(tell_registry) "$tell_name on_$tell_name"

	# Trickery: Generate a proc on the fly
	eval "proc on_$tell_name {who} {on_square \$who $x $y}"
    }
}
unset x y

# Set all variables to initial values
set chess(initial_time) 0
set chess(chess_timer_running) 0
set chess(chess_timer_id) 0
set chess(turn) 0
set chess(startstop_active) 0
set chess(piece_index) -1
set chess(anim_timer_count) 0
set chess(undo_stack) {}
set chess(promotion) -1
set chess(en_passant_index) -1
set chess(en_passant_x) -1
set chess(en_passant_y) -1

set chess(players.1.sock) 0
set chess(players.1.name) ""
set chess(players.1.time) 0
set chess(players.1.is_missing) 0
set chess(players.1.num_captured) 0

set chess(players.2.sock) 0
set chess(players.2.name) ""
set chess(players.2.time) 0
set chess(players.2.is_missing) 0
set chess(players.2.num_captured) 0
