Обеспечение всемирной трансляции спортивных шахматных соревнований с применением разработанного в ходе проекта законченного программного продукта

Дипломная работа - Компьютеры, программирование

Другие дипломы по предмету Компьютеры, программирование

{

return move.substring(20, 26);

}

function getFrom(color, move) {

}

function getTo(color, move) {

}

function isShortCastling(color, move) {

}

function isLongCastling(color, move) {

}

moves_split = all_moves.split(|);

moves_strip = new Array();

for(i = 0; i < moves_split.length; i++) {

if(moves_split[i] != "") {

moves_strip.push(moves_split[i]);

trace(split: + moves_split[i]);

}

}

var number = moves_strip.length;

trace(number = + number);

var current_move = this.moves.get_current_move();

trace(current_move = + current_move);

var current_number = current_move != null ? current_move.number : 0;

trace(current_number = + current_number);

if(number == current_number) {

if((current_move.color == white) && existsBlack(moves_strip[number - 1])) {

var move_annotation = getBlackMove(moves_strip[number - 1]);

var move_time = getBlackTime(moves_strip[number - 1]);

var fieldFrom = getFrom(black, move_annotation);

var fieldTo = getTo(black, move_annotation);

var move = new move(number, black, fieldFrom, fieldTo, fieldFrom.figure, fieldTo.figure, isShortCastling(black, move_annotation), isLongCastling(black, move_annotation), current_move, null, this, move_time);

this.moves.add_move(move);

}

}

if(number > current_number){

for(iMove = current_move; iMove < number; iMove++) {

var move_annotation = getWhiteMove(moves_strip[number - 1]);

if(existsWhite(move_annotation)) {

var move_time = getWhiteTime(moves_strip[number - 1]);

var fieldFrom = getFrom(white, move_annotation);

var fieldTo = getTo(white, move_annotation);

var move = new move(iMove + 1, white, fieldFrom, fieldTo, fieldFrom.figure, fieldTo.figure, isShortCastling(white, move_annotation), isLongCastling(white, move_annotation), current_move, null, this, move_time);

this.moves.add_move(move);

}

move_annotation = getBlackMove(moves_strip[number - 1]);

if(existsBlack(move_annotation)) {

var move_time = getBlackTime(moves_strip[number - 1]);

var fieldFrom = getFrom(black, move_annotation);

var fieldTo = getTo(black, move_annotation);

var move = new move(iMove + 1, black, fieldFrom, fieldTo, fieldFrom.figure, fieldTo.figure, isShortCastling(black, move_annotation), isLongCastling(black, move_annotation), current_move, null, this, move_time);

this.moves.add_move(move);

}

}

}

}

this.refresh_figures = refresh_figures;

this.go_begin = go_begin;

this.go_end = go_end;

this.go_next = go_next;

this.go_preview = go_preview;

this.go_custom = go_custom;

this.repaint = function() {

}

// Парсит данные пришедшие от сервера

this.parse_moves = function() {

var moves = this.all_moves;

trace(call => parse_moves( + moves + ))

function existsWhite(move) {

return getWhiteMove(move) != "******";

}

function existsBlack(move) {

return getBlackMove(move) != "******";

}

function getWhiteMove(move) {

return move.substring(0,6);

}

function getWhiteTime(move) {

return move.substring(13, 19);

}

function getBlackMove(move) {

return move.substring(6,12);

}

function getBlackTime(move) {

return move.substring(20, 26);

}

function getFrom(color, move) {

}

function getTo(color, move) {

}

function isShortCastling(color, move) {

}

function isLongCastling(color, move) {

}

moves_split = moves.split(|);

moves_strip = new Array();

for(i = 0; i < moves_split.length; i++) {

if(moves_split[i] != null) {

moves_strip.push(moves_split[i]);

}

}

var number = moves_strip.length;

var current_move = this.moves.get_current_move;

var current_number = current_move != null ? current_move.number : 0;

if(number == current_number) {

if((current_move.color == white) && existsBlack(moves_strip[number - 1])) {

var move_annotation = getBlackMove(moves_strip[number - 1]);

var move_time = getBlackTime(moves_strip[number - 1]);

var fieldFrom = getFrom(black, move_annotation);

var fieldTo = getTo(black, move_annotation);

var move = new move(number, black, fieldFrom, fieldTo, fieldFrom.figure, fieldTo.figure, isShortCastling(black, move_annotation), isLongCastling(black, move_annotation), current_move, null, this, move_time);

this.moves.add_move(move);

}

}

if(number > current_number){

for(iMove = current_move; iMove < number; iMove++) {

var move_annotation = getWhiteMove(moves_strip[number - 1]);

if(existsWhite(move_annotation)) {

var move_time = getWhiteTime(moves_strip[number - 1]);

var fieldFrom = getFrom(white, move_annotation);

var fieldTo = getTo(white, move_annotation);

var move = new move(iMove + 1, white, fieldFrom, fieldTo, fieldFrom.figure, fieldTo.figure, isShortCastling(white, move_annotation), isLongCastling(white, move_annotation), current_move, null, this, move_time);

this.moves.add_move(move);

}

move_annotation = getBlackMove(moves_strip[number - 1]);

if(existsBlack(move_annotation)) {

var move_time = getBlackTime(moves_strip[number - 1]);

var fieldFrom = getFrom(black, move_annotation);

var fieldTo = getTo(black, move_annotation);

var move = new move(iMove + 1, black, fieldFrom, fieldTo, fieldFrom.figure, fieldTo.figure, isShortCastling(black, move_annotation), isLongCastling(black, move_annotation), current_move, null, this, move_time);

this.moves.add_move(move);

}

}

}

}

// Настройки

this.all_moves = "";

this.moves_delay = 3;

this.moves_url = /main/game_moves/1;

this.figures_delay = 2;

}

 

// Инициализация доски

function init() {

trace(call => init());

// Расставляем шахматы в начальную позицию

// белые пешки

this.figures.wpA.set_field(this.fields.A2);

this.figures.wpB.set_field(this.fields.B2);

this.figures.wpC.set_field(this.fields.C2);

this.figures.wpD.set_field(this.fields.D2);

this.figures.wpE.set_field(this.fields.E2);

this.figures.wpF.set_field(this.fields.F2);

this.figures.wpG.set_field(this.fields.G2);

this.figures.wpH.set_field(this.fields.H2);

// белые фигуры

this.figures.wrA.set_field(this.fields.A1);

this.figures.wrH.set_field(this.fields.H1);

this.figures.whB.set_field(this.fields.B1);

this.figures.whG.set_field(this.fields.G1);

this.figures.wbC.set_field(this.fields.C1);

this.figures.wbF.set_field(this.fields.F1);

this.figures.wq.set_field(this.fields.D1);

this.figures.wk.set_field(this.fields.E1);

// черные пешки

this.figures.bpA.set_field(this.fields.A7);

this.figures.bpB.set_field(this.fields.B7);

this.figures.bpC.set_field(this.fields.C7);

this.figures.bpD.set_field(this.fields.D7);

this.figures.bpE.set_field(this.fields.E7);

this.figures.bpF.set_field(this.fields.F7);

this.figures.bpG.set_field(this.fields.G7);

this.figures.bpH.set_field(this.fields.H7);

// черные фигуры

this.figures.brA.set_field(this.fields.A8);

this.figures.brH.set_field(this.fields.H8);

this.figures.bhB.set_field(this.fields.B8);

this.figures.bhG.set_field(this.fields.G8);

this.figures.bbC.set_field(this.fields.C8);

this.figures.bbF.set_field(this.fields.F8);

this.figures.bq.set_field(this.fields.D8);

this.figures.bk.set_field(this.fields.E8);

// Создаем Ajax опрашиватель сервера

new PeriodicalExecuter(this.refresh_moves, this.moves_delay);

new PeriodicalExecuter(this.refresh_figures, this.figures_delay);

}

 

// Перерисовка позиции (делает один ход)

function refresh_figures() {

//trace(call => refresh_figures);

if(this.exists_move) {

this.current_move = this.moves.get_current_move();