Skip to content

Instantly share code, notes, and snippets.

@1ou
Created December 23, 2019 09:12
Show Gist options
  • Save 1ou/cbca4fb45c179916396609b64eeffb5e to your computer and use it in GitHub Desktop.
Save 1ou/cbca4fb45c179916396609b64eeffb5e to your computer and use it in GitHub Desktop.
#include <vcl.h>
#pragma hdrstop
#include "chess.h"
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
GAME = new Chess();
Xod = -1;
Num_Chess = 0;
Double_Rub = -1;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N6Click(TObject *Sender)
{
//2
if(GAME->figure[2]->get_Empty() == false)
SpeedButton2->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[2]->get_King())
if(GAME->figure[2]->get_Party() == 0)
SpeedButton2->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton2->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[2]->get_Party() == 0)
SpeedButton2->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton2->Glyph->LoadFromFile("King_White.bmp");
//4
if(GAME->figure[4]->get_Empty() == false)
SpeedButton4->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[4]->get_King())
if(GAME->figure[4]->get_Party() == 0)
SpeedButton4->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton4->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[4]->get_Party() == 0)
SpeedButton4->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton4->Glyph->LoadFromFile("King_White.bmp");
//6
if(GAME->figure[6]->get_Empty() == false)
SpeedButton6->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[6]->get_King())
if(GAME->figure[6]->get_Party() == 0)
SpeedButton6->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton6->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[6]->get_Party() == 0)
SpeedButton6->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton6->Glyph->LoadFromFile("King_White.bmp");
//8
if(GAME->figure[8]->get_Empty() == false)
SpeedButton8->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[8]->get_King())
if(GAME->figure[8]->get_Party() == 0)
SpeedButton8->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton8->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[8]->get_Party() == 0)
SpeedButton8->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton8->Glyph->LoadFromFile("King_White.bmp");
//9
if(GAME->figure[9]->get_Empty() == false)
SpeedButton9->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[9]->get_King())
if(GAME->figure[9]->get_Party() == 0)
SpeedButton9->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton9->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[9]->get_Party() == 0)
SpeedButton9->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton9->Glyph->LoadFromFile("King_White.bmp");
//11
if(GAME->figure[11]->get_Empty() == false)
SpeedButton11->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[11]->get_King())
if(GAME->figure[11]->get_Party() == 0)
SpeedButton11->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton11->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[11]->get_Party() == 0)
SpeedButton11->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton11->Glyph->LoadFromFile("King_White.bmp");
//13
if(GAME->figure[13]->get_Empty() == false)
SpeedButton13->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[13]->get_King())
if(GAME->figure[13]->get_Party() == 0)
SpeedButton13->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton13->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[13]->get_Party() == 0)
SpeedButton4->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton4->Glyph->LoadFromFile("King_White.bmp");
//15
if(GAME->figure[15]->get_Empty() == false)
SpeedButton15->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[15]->get_King())
if(GAME->figure[15]->get_Party() == 0)
SpeedButton15->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton15->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[15]->get_Party() == 0)
SpeedButton15->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton15->Glyph->LoadFromFile("King_White.bmp");
//18
if(GAME->figure[18]->get_Empty() == false)
SpeedButton18->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[18]->get_King())
if(GAME->figure[18]->get_Party() == 0)
SpeedButton18->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton18->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[18]->get_Party() == 0)
SpeedButton18->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton18->Glyph->LoadFromFile("King_White.bmp");
//20
if(GAME->figure[20]->get_Empty() == false)
SpeedButton20->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[20]->get_King())
if(GAME->figure[20]->get_Party() == 0)
SpeedButton20->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton20->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[20]->get_Party() == 0)
SpeedButton20->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton20->Glyph->LoadFromFile("King_White.bmp");
//22
if(GAME->figure[22]->get_Empty() == false)
SpeedButton22->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[22]->get_King())
if(GAME->figure[22]->get_Party() == 0)
SpeedButton22->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton22->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[22]->get_Party() == 0)
SpeedButton22->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton22->Glyph->LoadFromFile("King_White.bmp");
//24
if(GAME->figure[24]->get_Empty() == false)
SpeedButton24->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[24]->get_King())
if(GAME->figure[24]->get_Party() == 0)
SpeedButton24->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton24->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[24]->get_Party() == 0)
SpeedButton24->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton24->Glyph->LoadFromFile("King_White.bmp");
//25
if(GAME->figure[25]->get_Empty() == false)
SpeedButton25->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[25]->get_King())
if(GAME->figure[25]->get_Party() == 0)
SpeedButton25->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton25->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[25]->get_Party() == 0)
SpeedButton25->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton25->Glyph->LoadFromFile("King_White.bmp");
//27
if(GAME->figure[27]->get_Empty() == false)
SpeedButton27->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[27]->get_King())
if(GAME->figure[27]->get_Party() == 0)
SpeedButton27->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton27->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[27]->get_Party() == 0)
SpeedButton27->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton27->Glyph->LoadFromFile("King_White.bmp");
//29
if(GAME->figure[29]->get_Empty() == false)
SpeedButton29->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[29]->get_King())
if(GAME->figure[29]->get_Party() == 0)
SpeedButton29->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton29->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[29]->get_Party() == 0)
SpeedButton29->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton29->Glyph->LoadFromFile("King_White.bmp");
//31
if(GAME->figure[31]->get_Empty() == false)
SpeedButton31->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[31]->get_King())
if(GAME->figure[31]->get_Party() == 0)
SpeedButton31->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton31->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[31]->get_Party() == 0)
SpeedButton31->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton31->Glyph->LoadFromFile("King_White.bmp");
//34
if(GAME->figure[34]->get_Empty() == false)
SpeedButton34->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[34]->get_King())
if(GAME->figure[34]->get_Party() == 0)
SpeedButton34->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton34->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[34]->get_Party() == 0)
SpeedButton34->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton34->Glyph->LoadFromFile("King_White.bmp");
//36
if(GAME->figure[36]->get_Empty() == false)
SpeedButton36->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[36]->get_King())
if(GAME->figure[36]->get_Party() == 0)
SpeedButton36->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton36->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[36]->get_Party() == 0)
SpeedButton36->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton36->Glyph->LoadFromFile("King_White.bmp");
//38
if(GAME->figure[38]->get_Empty() == false)
SpeedButton38->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[38]->get_King())
if(GAME->figure[38]->get_Party() == 0)
SpeedButton38->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton38->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[38]->get_Party() == 0)
SpeedButton38->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton38->Glyph->LoadFromFile("King_White.bmp");
if(GAME->figure[41]->get_Empty() == false)
SpeedButton41->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[41]->get_King())
if(GAME->figure[41]->get_Party() == 0)
SpeedButton41->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton41->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[41]->get_Party() == 0)
SpeedButton41->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton41->Glyph->LoadFromFile("King_White.bmp");
//40
if(GAME->figure[40]->get_Empty() == false)
SpeedButton40->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[40]->get_King())
if(GAME->figure[40]->get_Party() == 0)
SpeedButton40->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton40->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[40]->get_Party() == 0)
SpeedButton40->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton40->Glyph->LoadFromFile("King_White.bmp");
//43
if(GAME->figure[43]->get_Empty() == false)
SpeedButton43->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[43]->get_King())
if(GAME->figure[43]->get_Party() == 0)
SpeedButton43->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton43->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[43]->get_Party() == 0)
SpeedButton43->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton43->Glyph->LoadFromFile("King_White.bmp");
//45
if(GAME->figure[45]->get_Empty() == false)
SpeedButton45->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[45]->get_King())
if(GAME->figure[45]->get_Party() == 0)
SpeedButton45->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton45->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[45]->get_Party() == 0)
SpeedButton45->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton45->Glyph->LoadFromFile("King_White.bmp");
//47
if(GAME->figure[47]->get_Empty() == false)
SpeedButton47->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[47]->get_King())
if(GAME->figure[47]->get_Party() == 0)
SpeedButton47->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton47->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[47]->get_Party() == 0)
SpeedButton47->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton47->Glyph->LoadFromFile("King_White.bmp");
//50
if(GAME->figure[50]->get_Empty() == false)
SpeedButton50->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[50]->get_King())
if(GAME->figure[50]->get_Party() == 0)
SpeedButton50->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton50->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[50]->get_Party() == 0)
SpeedButton50->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton50->Glyph->LoadFromFile("King_White.bmp");
//52
if(GAME->figure[52]->get_Empty() == false)
SpeedButton52->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[52]->get_King())
if(GAME->figure[52]->get_Party() == 0)
SpeedButton52->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton52->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[52]->get_Party() == 0)
SpeedButton52->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton52->Glyph->LoadFromFile("King_White.bmp");
//54
if(GAME->figure[54]->get_Empty() == false)
SpeedButton54->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[54]->get_King())
if(GAME->figure[54]->get_Party() == 0)
SpeedButton54->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton54->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[54]->get_Party() == 0)
SpeedButton54->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton54->Glyph->LoadFromFile("King_White.bmp");
//56
if(GAME->figure[56]->get_Empty() == false)
SpeedButton56->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[56]->get_King())
if(GAME->figure[56]->get_Party() == 0)
SpeedButton56->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton56->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[56]->get_Party() == 0)
SpeedButton56->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton56->Glyph->LoadFromFile("King_White.bmp");
//57
if(GAME->figure[57]->get_Empty() == false)
SpeedButton57->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[57]->get_King())
if(GAME->figure[57]->get_Party() == 0)
SpeedButton57->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton57->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[57]->get_Party() == 0)
SpeedButton57->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton57->Glyph->LoadFromFile("King_White.bmp");
//59
if(GAME->figure[59]->get_Empty() == false)
SpeedButton59->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[59]->get_King())
if(GAME->figure[59]->get_Party() == 0)
SpeedButton59->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton59->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[59]->get_Party() == 0)
SpeedButton59->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton59->Glyph->LoadFromFile("King_White.bmp");
//61
if(GAME->figure[61]->get_Empty() == false)
SpeedButton61->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[61]->get_King())
if(GAME->figure[61]->get_Party() == 0)
SpeedButton61->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton61->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[61]->get_Party() == 0)
SpeedButton61->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton61->Glyph->LoadFromFile("King_White.bmp");
//63
if(GAME->figure[63]->get_Empty() == false)
SpeedButton63->Glyph->LoadFromFile("Pool_2.bmp");
else
if(!GAME->figure[63]->get_King())
if(GAME->figure[63]->get_Party() == 0)
SpeedButton63->Glyph->LoadFromFile("Black.bmp");
else
SpeedButton63->Glyph->LoadFromFile("White.bmp");
else
if(GAME->figure[63]->get_Party() == 0)
SpeedButton63->Glyph->LoadFromFile("King_Black.bmp");
else
SpeedButton63->Glyph->LoadFromFile("King_White.bmp");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton41Click(TObject *Sender)
{
int Num = 41;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton34Click(TObject *Sender)
{
int Num = 34;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton43Click(TObject *Sender)
{
int Num = 43;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton25Click(TObject *Sender)
{
int Num = 25;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton57Click(TObject *Sender)
{
int Num = 57;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton45Click(TObject *Sender)
{
int Num = 45;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton47Click(TObject *Sender)
{
int Num = 47;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton56Click(TObject *Sender)
{
int Num = 56;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton54Click(TObject *Sender)
{
int Num = 54;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton52Click(TObject *Sender)
{
int Num = 52;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton59Click(TObject *Sender)
{
int Num = 59;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton63Click(TObject *Sender)
{
int Num = 63;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton61Click(TObject *Sender)
{
int Num = 61;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton50Click(TObject *Sender)
{
int Num = 50;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton36Click(TObject *Sender)
{
int Num = 36;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton38Click(TObject *Sender)
{
int Num = 38;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton40Click(TObject *Sender)
{
int Num = 40;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton31Click(TObject *Sender)
{
int Num = 31;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton29Click(TObject *Sender)
{
int Num = 29;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton27Click(TObject *Sender)
{
int Num = 27;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton24Click(TObject *Sender)
{
int Num = 24;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton22Click(TObject *Sender)
{
int Num = 22;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton18Click(TObject *Sender)
{
int Num = 18;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton20Click(TObject *Sender)
{
int Num = 20;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton15Click(TObject *Sender)
{
int Num = 15;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton13Click(TObject *Sender)
{
int Num = 13;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton11Click(TObject *Sender)
{
int Num = 11;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton9Click(TObject *Sender)
{
int Num = 9;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton8Click(TObject *Sender)
{
int Num = 8;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton6Click(TObject *Sender)
{
int Num = 6;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton2Click(TObject *Sender)
{
int Num = 2;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton4Click(TObject *Sender)
{
int Num = 36;
change_Chess(Num);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton37Click(TObject *Sender)
{
Xod = -1;
}
//---------------------------------------------------------------------------
///////////////////////////////////
////Ïðåîáðàçîâàíèå øàøêè â Äàìêó///
///////////////////////////////////
void __fastcall TForm1::Damka()
{
int A[4] = {57,59,61,63};
for(int i = 0; i < 4; i++)
if((GAME->figure[A[i]]->get_Party() == 0) && (!GAME->figure[A[i]]->get_King()))
GAME->figure[A[i]]->set_King(true);
}
//////////////////////////////////////////
////Ïðîâåðêà ìîæíî ëè åùå ðóáèòü ÈÃÐÎÊÓ///
//////////////////////////////////////////
bool __fastcall TForm1:: Test_On_Rub(int i)
{
if((i+14 < 64) && (GAME->figure[i+7]->get_Empty()) && (GAME->figure[i+7]->get_Party() == 0) && (GAME->figure[i]->get_Party() == 1) && (!GAME->figure[i+14]->get_Empty()))
{
if((i != 57) && (i != 50) && (i != 41) && (i != 34) &&
(i != 25) && (i != 18) && (i != 9) && (i != 2) &&
(i != 11) && (i != 4) && (i != 13) && (i != 6) && (i != 15))
{
Xod = -1;
return true;
}
}
if((i-14 >= 0) && (GAME->figure[i-7]->get_Empty()) && (GAME->figure[i-7]->get_Party() == 0) && (GAME->figure[i]->get_Party() == 1) && (!GAME->figure[i-14]->get_Empty()))
{
if((i != 63) && (i != 56) && (i != 47) && (i != 40) &&
(i != 31) && (i != 24) && (i != 15) && (i != 9) &&
(i != 6) && (i != 4) && (i != 13) && (i != 11) && (i != 2) && (i != 8))
{
Xod = -1;
return true;
}
}
if((i + 18 < 64) && (GAME->figure[i+9]->get_Empty()) && (GAME->figure[i+9]->get_Party() == 0) && (GAME->figure[i]->get_Party() == 1) && (!GAME->figure[i+18]->get_Empty()))
{
if((i != 57) && (i != 50) && (i != 59) && (i != 52) &&
(i != 61) && (i != 54) && (i != 63) && (i != 47) &&
(i != 56) && (i != 31) && (i != 40) && (i != 24) && (i != 15) && (i != 8))
{
Xod = -1;
return true;
}
}
if((i - 18 >= 0) && (GAME->figure[i-9]->get_Empty()) && (GAME->figure[i-9]->get_Party() == 0) && (GAME->figure[i]->get_Party() == 1) && (!GAME->figure[i-18]->get_Empty()))
{
if((i != 57) && (i != 50) && (i != 41) && (i != 34) &&
(i != 25) && (i != 18) && (i != 9) && (i != 2) &&
(i != 11) && (i != 4) && (i != 13) && (i != 6) && (i != 15) && (i != 8))
{
Xod = -1;
return true;
}
}
return false;
}
////////////////////////////////////////
////////////Ñìåíà øàøåê ìåñòàìè////////
/////////////////////////////////////
void __fastcall TForm1:: change_Chess(int Num)
{
if(Xod == Num) return;
if(Xod == -1) {
Xod = Num;
GAME->UPCountPlay();
}
else {
//Åñëè ïîçèöèÿ ñâîáîäíà
if(GAME->figure[Num]->get_Empty() == false)
{
//Åñëè õîäèò äàìêîé
if(GAME->figure[Num]->get_King())
{
GAME->figure[Num]->set(GAME->figure[Xod]->get_Empty(),
GAME->figure[Xod]->get_King(),
GAME->figure[Xod]->get_Party());
GAME->figure[Xod]->set_Empty(false);
N6->Click();
Xod = -1;
Computer_Intellect();
Damka();
StatusBar1->Panels->Items[1]->Text = GAME->get_CountPlay();
}
else //Åñëè òàê õîäèòü ìîæíî
{
//Åñëè ÐÓÁÈÌ
if(((abs(Xod - Num) == 14) || (abs(Xod - Num) == 18)) && (GAME->figure[(Xod+Num)/2]->get_Empty()) && (GAME->figure[(Xod+Num)/2]->get_Party() == 0))
{
GAME->figure[Num]->set(GAME->figure[Xod]->get_Empty(),
GAME->figure[Xod]->get_King(),
GAME->figure[Xod]->get_Party());
GAME->figure[Xod]->set_Empty(false);
GAME->figure[(Xod+Num)/2]->set_Empty(false);
if(Test_On_Rub(Num)) {
Damka();
N6->Click();
Double_Rub = Num;
StatusBar1->Panels->Items[1]->Text = GAME->get_CountPlay();
return;
}
else
{
N6->Click();
Xod = -1;
Computer_Intellect();
Damka();
StatusBar1->Panels->Items[1]->Text = GAME->get_CountPlay();
return;
}
}
//Åñëè ÕÎÄÈÌ
if((Num < Xod) && ((Xod - Num == 9) || (Xod - Num == 7)))
{
GAME->figure[Num]->set(GAME->figure[Xod]->get_Empty(),
GAME->figure[Xod]->get_King(),
GAME->figure[Xod]->get_Party());
GAME->figure[Xod]->set_Empty(false);
if((Double_Rub != Num) && (Double_Rub != -1)) {
GAME->figure[Double_Rub]->set_Empty(false);
}
for(int i = 0; i < 64; i++)
{
if(Test_On_Rub(i)) {
GAME->figure[i]->set_Empty(false);
break;
}
}
N6->Click();
Xod = -1;
Computer_Intellect();
Damka();
StatusBar1->Panels->Items[1]->Text = GAME->get_CountPlay();
Double_Rub = -1;
return;
}
else Xod = -1;
}
}
else Xod = -1;
}
}
////////////////////////////////////////////////////
////Ðóáëåíèå êîìïüþòåðîì 2, 3.., n øàøêè çà 1 õîä///
////////////////////////////////////////////////////
int __fastcall TForm1::RUB_2(int i)
{
if(GAME->figure[i]->get_Empty())
{
if((i+14 < 64) && (GAME->figure[i+7]->get_Empty()) && (GAME->figure[i+7]->get_Party() == 1) && (GAME->figure[i]->get_Party() == 0) && (!GAME->figure[i+14]->get_Empty()))
{
if((i != 57) && (i != 50) && (i != 41) && (i != 34) &&
(i != 25) && (i != 18) && (i != 9) && (i != 2) &&
(i != 11) && (i != 4) && (i != 13) && (i != 6) && (i != 15)){
GAME->figure[i+14]->set(GAME->figure[i]->get_Empty(),
GAME->figure[i]->get_King(),
GAME->figure[i]->get_Party());
GAME->figure[i]->set_Empty(false);
GAME->figure[i + 7]->set_Empty(false);
N6->Click();
return (i + 14);
}
}
if((i-14 >= 0) && (GAME->figure[i-7]->get_Empty()) && (GAME->figure[i-7]->get_Party() == 1) && (GAME->figure[i]->get_Party() == 0) && (!GAME->figure[i-14]->get_Empty()))
{
if((i != 63) && (i != 56) && (i != 47) && (i != 40) &&
(i != 31) && (i != 24) && (i != 15) && (i != 9) &&
(i != 6) && (i != 4) && (i != 13) && (i != 11) && (i != 2) && (i != 8)){
GAME->figure[i-14]->set(GAME->figure[i]->get_Empty(),
GAME->figure[i]->get_King(),
GAME->figure[i]->get_Party());
GAME->figure[i]->set_Empty(false);
GAME->figure[i - 7]->set_Empty(false);
N6->Click();
return (i - 14);
}
}
//9
if((i + 18 < 64) && (GAME->figure[i+9]->get_Empty()) && (GAME->figure[i+9]->get_Party() == 1) && (GAME->figure[i]->get_Party() == 0) && (!GAME->figure[i+18]->get_Empty()))
{
if((i != 57) && (i != 50) && (i != 59) && (i != 52) &&
(i != 61) && (i != 54) && (i != 63) && (i != 47) &&
(i != 56) && (i != 31) && (i != 40) && (i != 24) &&
(i != 15) && (i != 8)){
GAME->figure[i+18]->set(GAME->figure[i]->get_Empty(),
GAME->figure[i]->get_King(),
GAME->figure[i]->get_Party());
GAME->figure[i]->set_Empty(false);
GAME->figure[i + 9]->set_Empty(false);
N6->Click();
return (i + 18);
}
}
if((i - 18 >= 0) && (GAME->figure[i-9]->get_Empty()) && (GAME->figure[i-9]->get_Party() == 1) && (GAME->figure[i]->get_Party() == 0) && (!GAME->figure[i-18]->get_Empty()))
{
if((i != 57) && (i != 50) && (i != 41) && (i != 34) &&
(i != 25) && (i != 18) && (i != 9) && (i != 2) &&
(i != 11) && (i != 4) && (i != 13) && (i != 6) &&
(i != 15) && (i != 8)){
GAME->figure[i-18]->set(GAME->figure[i]->get_Empty(),
GAME->figure[i]->get_King(),
GAME->figure[i]->get_Party());
GAME->figure[i]->set_Empty(false);
GAME->figure[i - 9]->set_Empty(false);
N6->Click();
return (i - 18);
}
}
}
return -1;//Âîçâðàùàåì 1, åñëè íè÷åãî íå áûëî ñðóáëåíî
}
///////////////////////////////////
////Ïðîâåðêà íà ðóáêó øàøêè////////
///////////////////////////////////
int __fastcall TForm1::RUBILOVO()
{
for(int i = 0; i < 64; i++)
{
if(GAME->figure[i]->get_Empty())
{
if((i+14 < 64) && (GAME->figure[i+7]->get_Empty()) && (GAME->figure[i+7]->get_Party() == 1) && (GAME->figure[i]->get_Party() == 0) && (!GAME->figure[i+14]->get_Empty()))
{
if((i != 57) && (i != 50) && (i != 41) && (i != 34) &&
(i != 25) && (i != 18) && (i != 9) && (i != 2) &&
(i != 11) && (i != 4) && (i != 13) && (i != 6) && (i != 15)){
GAME->figure[i+14]->set(GAME->figure[i]->get_Empty(),
GAME->figure[i]->get_King(),
GAME->figure[i]->get_Party());
GAME->figure[i]->set_Empty(false);
GAME->figure[i + 7]->set_Empty(false);
Damka();
N6->Click();
return (i + 14);
}
}
if((i-14 >= 0) && (GAME->figure[i-7]->get_Empty()) && (GAME->figure[i-7]->get_Party() == 1) && (GAME->figure[i]->get_Party() == 0) && (!GAME->figure[i-14]->get_Empty()))
{
if((i != 63) && (i != 56) && (i != 47) && (i != 40) &&
(i != 31) && (i != 24) && (i != 15) && (i != 9) &&
(i != 6) && (i != 4) && (i != 13) && (i != 11) && (i != 2) && (i != 8)){
GAME->figure[i-14]->set(GAME->figure[i]->get_Empty(),
GAME->figure[i]->get_King(),
GAME->figure[i]->get_Party());
GAME->figure[i]->set_Empty(false);
GAME->figure[i - 7]->set_Empty(false);
Damka();
N6->Click();
return(i - 14);
}
}
//9
if((i + 18 < 64) && (GAME->figure[i+9]->get_Empty()) && (GAME->figure[i+9]->get_Party() == 1) && (GAME->figure[i]->get_Party() == 0) && (!GAME->figure[i+18]->get_Empty()))
{
if((i != 57) && (i != 50) && (i != 59) && (i != 52) &&
(i != 61) && (i != 54) && (i != 63) && (i != 47) &&
(i != 56) && (i != 31) && (i != 40) && (i != 24) &&
(i != 15) && (i != 8)){
GAME->figure[i+18]->set(GAME->figure[i]->get_Empty(),
GAME->figure[i]->get_King(),
GAME->figure[i]->get_Party());
GAME->figure[i]->set_Empty(false);
GAME->figure[i + 9]->set_Empty(false);
Damka();
N6->Click();
return(i + 18);
}
}
if((i - 18 >= 0) && (GAME->figure[i-9]->get_Empty()) && (GAME->figure[i-9]->get_Party() == 1) && (GAME->figure[i]->get_Party() == 0) && (!GAME->figure[i-18]->get_Empty()))
{
if((i != 57) && (i != 50) && (i != 41) && (i != 34) &&
(i != 25) && (i != 18) && (i != 9) && (i != 2) &&
(i != 11) && (i != 4) && (i != 13) && (i != 6) &&
(i != 15) && (i != 8)){
GAME->figure[i-18]->set(GAME->figure[i]->get_Empty(),
GAME->figure[i]->get_King(),
GAME->figure[i]->get_Party());
GAME->figure[i]->set_Empty(false);
GAME->figure[i - 9]->set_Empty(false);
Damka();
N6->Click();
return(i - 18);
}
}
}
}
return -1;
}
///////////////////////////////////
////Êîìïüþòåðíûå õîäû//////////////
///////////////////////////////////
void __fastcall TForm1::Computer_Intellect()
{
int i = RUBILOVO();
if (i != -1)
{
while(RUB_2(i) != -1) {}
Damka();
return;
}
int A[4] = {18,20,22,24};
int Num = rand() % 4;
if(GAME->get_CountPlay() == 1)
if(!GAME->figure[A[Num]+7]->get_Empty())
{
GAME->figure[A[Num]+7]->set(GAME->figure[A[Num]]->get_Empty(),
GAME->figure[A[Num]]->get_King(),
GAME->figure[A[Num]]->get_Party());
GAME->figure[A[Num]]->set_Empty(false);
N6->Click();
Xod = -1;
}
if(GAME->get_CountPlay() == 2)
if(!GAME->figure[A[Num]]->get_Empty())
{
GAME->figure[A[Num]]->set(GAME->figure[A[Num]-9]->get_Empty(),
GAME->figure[A[Num]-9]->get_King(),
GAME->figure[A[Num]-9]->get_Party());
GAME->figure[A[Num]-9]->set_Empty(false);
N6->Click();
Xod = -1;
}
if(GAME->get_CountPlay() > 2)
{
for(int i = 18; i <= 54; i++)
if((GAME->figure[i]->get_Empty()) && (GAME->figure[i]->get_Party() == 0))
{
if((!GAME->figure[i - 7]->get_Empty()) &&
(GAME->figure[i - 14]->get_Empty()) && (GAME->figure[i - 14]->get_Party() == 0) && (i >= 18) && (i <= 54))
{
GAME->figure[i-7]->set(GAME->figure[i-14]->get_Empty(),
GAME->figure[i-14]->get_King(),
GAME->figure[i-14]->get_Party());
GAME->figure[i-14]->set_Empty(false);
N6->Click();
return;
}
if((!GAME->figure[i - 9]->get_Empty()) &&
(GAME->figure[i - 18]->get_Empty()) && (GAME->figure[i - 18]->get_Party() == 0) && (i >= 20) && (i <= 54))
{
GAME->figure[i-9]->set(GAME->figure[i-18]->get_Empty(),
GAME->figure[i-18]->get_King(),
GAME->figure[i-18]->get_Party());
GAME->figure[i-18]->set_Empty(false);
N6->Click();
return;
}
}
}
if(GAME->get_CountPlay() > 2)
{
int A[] = {4,6,11,13,20,22,27,29,36,38,43,45};
for(int i = 0; i < 12; i++)
if((GAME->figure[A[i]]->get_Empty()) && (GAME->figure[A[i]]->get_Party() == 0))
{
if((GAME->figure[A[i]-2]->get_Empty()) && (GAME->figure[A[i]-2]->get_Party() == 0)
&& !(GAME->figure[A[i]+14]->get_Empty()) && !(GAME->figure[A[i]+7]->get_Empty()))
{
GAME->figure[A[i]+7]->set(GAME->figure[A[i]]->get_Empty(),
GAME->figure[A[i]]->get_King(),
GAME->figure[A[i]]->get_Party());
GAME->figure[A[i]]->set_Empty(false);
Damka();
N6->Click();
return;
}
if((GAME->figure[A[i]+2]->get_Empty()) && (GAME->figure[A[i]+2]->get_Party() == 0)
&& !(GAME->figure[A[i]+18]->get_Empty()) && !(GAME->figure[A[i]+9]->get_Empty()))
{
GAME->figure[A[i]+9]->set(GAME->figure[A[i]]->get_Empty(),
GAME->figure[A[i]]->get_King(),
GAME->figure[A[i]]->get_Party());
GAME->figure[A[i]]->set_Empty(false);
Damka();
N6->Click();
return;
}
}
}
}
void __fastcall TForm1::N2Click(TObject *Sender)
{
delete GAME;
GAME = new Chess();
Xod = -1;
Num_Chess = 0;
N6->Click();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N4Click(TObject *Sender)
{
Form1->Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
GAME->time.Up_Time();
int Sec = GAME->time.get_Seconds(),White = 0,Black = 0;
StatusBar1->Panels->Items[4]->Text = Sec / 60;
StatusBar1->Panels->Items[6]->Text = Sec - (Sec / 60 * 60);
for(int i = 0; i < 64; i++) {
if((GAME->figure[i]->get_Party() == 0) && (GAME->figure[i]->get_Empty())) Black++;
if((GAME->figure[i]->get_Party() == 1) && (GAME->figure[i]->get_Empty())) White++;
}
StatusBar1->Panels->Items[10]->Text = Black;
StatusBar1->Panels->Items[13]->Text = White;
if(Black == 0) {
ShowMessage("Âû âûèãàðëè!");
Timer1->Enabled = false;
N2->Click();
Timer1->Enabled = true;
}
if(White == 0) {
ShowMessage("Âû ïðîèãðàëè!");
Timer1->Enabled = false;
N2->Click();
Timer1->Enabled = true;
}
}
//---------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment