listboxOchki->Width=236;
listboxOchki->Left=14;
}
}
}
}
//------------------------------Результаты--------------------------------------
void __fastcall
TMainForm::ViProigrali(void)
{
IsVisitApplicationBox=true;
HisWinPoPartiam++;
Application->MessageBoxA("Вы проиграли!\nИграем дальше!","Поражение",MB_OK+MB_ICONEXCLAMATION);
InterfaceIgraemDalshe();
IsVisitApplicationBox=false;
}
//---------------------------------
void __fastcall
TMainForm::ViViigrali(void)
{
IsVisitApplicationBox=true;
MyWinPoPartiam++;
Application->MessageBoxA("Вы выиграли!\nИграем дальше!","Победа!!",MB_OK+MB_ICONEXCLAMATION);
InterfaceIgraemDalshe();
IsVisitApplicationBox=false;
}
//----------------------------------
void __fastcall TMainForm::Nichia(void)
{
IsVisitApplicationBox=true;
MyWinPoPartiam++;
HisWinPoPartiam++;
Application->MessageBoxA("Вы сыграли вничью!\nИграем дальше!","Ничья",MB_OK+MB_ICONEXCLAMATION);
InterfaceIgraemDalshe();
IsVisitApplicationBox=false;
}
//----------------------------------------------------------------------------
void __fastcall
TMainForm::menuOProgrClick(TObject *Sender)
{
FormAbout->ShowModal();
}
//----------------------------Интерфейсы---------------------------------------
void __fastcall
TMainForm::InterfaceBezIgri(void)
{
MyWholeOch=0;
HisWholeOch=0;
MyCurOch=0;
NomHoda=0;
IsYaFixed=false;
IsHeFixed=false;
NomPartia=0;
MyWinPoPartiam=0;
HisWinPoPartiam=0;
ServerHostName="";
ServerHostIP="";
IsIgrayut=false;
menuStop->Enabled=false;
panParam->Visible=false;
lbNomPartia->Visible=false;
panSchetPoPartiam->Visible=false;
gbPole1->Top=15;
gbPole2->Top=15;
gbTabl->Top=15;
this->Height=400;
this->Caption="Игровое поле";
btBrosit->Enabled=false;
btFix->Enabled=false;
btBrosit->Color=clCream;
btFix->Color=clCream;
shapeBrosil->Brush->Color=clSilver;
shapeFixed->Brush->Color=clSilver;
shapeBrosil->Caption->Font->Color=clWhite;
shapeFixed->Caption->Font->Color=clWhite;
lbMyWholeOch->Caption="0";
lbHisWholeOch->Caption="0";
lbMaxOch2->Caption="";
listboxOchki->Clear();
listboxOchki->Width=218;
listboxOchki->Left=23;
AnsiString
tmp=AnsiQuotedStr("Игра->Начать новую игру",'"');
lbStat->Caption="Для начала
новой игры выберете пункт меню "+tmp;
}
//--------------------------------------------------------------
void __fastcall
TMainForm::InterfaceBeginNewGame(void)
{
menuStop->Enabled=true;
if(IsServer)
{
Caption=Caption+" Сервер";
imStolServer->Parent=panPole1;
imStolClient->Parent=panPole2;
}
else
{
Caption=Caption+" Клиент";
imStolClient->Parent=panPole1;
imStolServer->Parent=panPole2;
}
for (int i=0;i<KolKub;i++)
{
Kubiki1[i] = new TImage(this);
Kubiki1[i]->Parent=panPole1;
Kubiki1[i]->Transparent=true;
Kubiki2[i] = new TImage(this);
Kubiki2[i]->Parent=panPole2;
Kubiki2[i]->Transparent=true;
}
panParam->Visible=true;
lbNomPartia->Visible=true;
panSchetPoPartiam->Visible=true;
gbPole1->Top=80;
gbTabl->Top=80;
gbPole2->Top=80;
this->Height=470;
lbKolKub->Caption=IntToStr(KolKub);
lbMaxOch->Caption=IntToStr(MaxOch);
lbMaxOch2->Caption=IntToStr(MaxOch);
lbNomPartia->Caption="Партия № 1";
lbSchetPoPartiam->Caption="0 : 0";
NomPartia=1;
IsIgrayut=true;
}
//---------------------------------------------------------
void __fastcall
TMainForm::ChangeInterfacePerehodHoda(bool HozhuYa)
{
if(HozhuYa)
{
btBrosit->Enabled=true;
btFix->Enabled=true;
btBrosit->Color=clCream;
btFix->Color=clCream;
shapeBrosil->Caption->Font->Color=clWhite;
shapeFixed->Caption->Font->Color=clWhite;
lbStat->Caption="Твой ход...";
if (MyWholeOch>MaxOch-KolKub)
{
IsVisitApplicationBox=true;
Application->MessageBoxA("Единственно верный вариант для Вас сейчас - зафиксировать очки!","Предупреждение",MB_OK+MB_ICONEXCLAMATION);
IsVisitApplicationBox=false;
}
}
else
{
btBrosit->Enabled=false;
btFix->Enabled=false;
shapeBrosil->Brush->Color=clSilver;
shapeFixed->Brush->Color=clSilver;
shapeBrosil->Caption->Font->Color=clBlack;
shapeFixed->Caption->Font->Color=clBlack;
lbStat->Caption="Ход соперника...";
}
}
//--------------------------------------------------------------------------
void __fastcall
TMainForm::InterfaceIgraemDalshe(void)
{
NomPartia++;
MyWholeOch=0;
HisWholeOch=0;
MyCurOch=0;
NomHoda=0;
IsYaFixed=false;
IsHeFixed=false;
IsIgrayut=true;
lbNomPartia->Caption="Партия № "+IntToStr(NomPartia);
lbSchetPoPartiam->Caption=IntToStr(MyWinPoPartiam)+" :
"+IntToStr(HisWinPoPartiam);
listboxOchki->Clear();
listboxOchki->Width=218;
listboxOchki->Left=23;
lbMyWholeOch->Caption="0";
lbHisWholeOch->Caption="0";
lbMyWholeOch->Font->Color=clGreen;
lbHisWholeOch->Font->Color=clGreen;
btBrosit->Color=clCream;
btFix->Color=clCream;
shapeBrosil->Brush->Color=clSilver;
shapeFixed->Brush->Color=clSilver;
for (int i=0;i<KolKub;i++)
{
Kubiki1[i]->Visible=false;
Kubiki2[i]->Visible=false;
}
if(IsServer)
{
ChangeInterfacePerehodHoda(1);
}
else
{
ChangeInterfacePerehodHoda(0);
}
}
//-----------------------Завершение игры---------------------------------------
void __fastcall
TMainForm::menuStopClick(TObject *Sender)
{
IsVisitApplicationBox=true;
if(Application->MessageBoxA("Вы действительно хотите завершить игру?","Завершение игры",MB_YESNO)==IDYES)
{
for (int i=0;i<KolKub;i++)
{
delete Kubiki1[i];
delete Kubiki2[i];
}
switch(choosenProt)
{
case 0:
IPXSend("3;");
IPXCloseConnection();
break;
case 1:
TCPIPSend("3;");
TCPIPCloseConnection();
break;
case 2:
NetBiosSend("3;");
NetBiosCloseConnection();
break;
case 3:
MailSlotSend("3;");
MailSlotCloseConnection();
break;
case 4:
PipeSend("3;");
PipeCloseConnection();
break;
}
IsIgrayut=false;
InterfaceBezIgri();
}
IsVisitApplicationBox=false;
}
//---------------------------------------------------------------------------
void __fastcall
TMainForm::menuQuitClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::FormCloseQuery(TObject
*Sender, bool &CanClose)
{
if (IsIgrayut)
{
menuStopClick(this);
if(IsIgrayut) CanClose=false;
}
}
//-------------------служебные функции преобразования типов---------------------
char* __fastcall
TMainForm::DannieToChar(int Type, int MyCurOch, int MyWholeOch,
int
ZnachKub1,int XKub1,int YKub1,
int
ZnachKub2,int XKub2,int YKub2,
int
ZnachKub3,int XKub3,int YKub3,
int
ZnachKub4,int XKub4,int YKub4
)
{
AnsiString
strTmp=IntToStr(Type)+";"+IntToStr(MyCurOch)+";"+IntToStr(MyWholeOch)+";"+
IntToStr(ZnachKub1)+";"+IntToStr(XKub1)+";"+IntToStr(YKub1)+";"+
IntToStr(ZnachKub2)+";"+IntToStr(XKub2)+";"+IntToStr(YKub2)+";"+
IntToStr(ZnachKub3)+";"+IntToStr(XKub3)+";"+IntToStr(YKub3)+";"+
IntToStr(ZnachKub4)+";"+IntToStr(XKub4)+";"+IntToStr(YKub4)+";";
return strTmp.c_str();
}
//---------------------------------------------------------------------------
int* __fastcall
TMainForm::CharToMas(char* charPriem)
{
AnsiString strPriem=charPriem;
MasPriem=new int[15];
int y=0;
int PrevDelim=0;
int CurDelim;
for(int
i=1;i<=strPriem.Length();i++)
{
if(IsDelimiter(";",strPriem,i))
{
MasPriem[y++]=StrToInt(MidStr(strPriem,PrevDelim+1,i-PrevDelim-1));
PrevDelim=i;
}
}
return MasPriem;
}
//Бросить---------------------------------------------------------------------------
//Закогнчить--------------------------------------------------------------------------
void __fastcall TMainForm::btBrosit2Click(TObject
*Sender)
{
Graphics::TBitmap *Bitmap1 = new
Graphics::TBitmap();
char strSend[70];
AnsiString strCat;
if(IsServer)
{
NomHoda++;
strCat="";
}
else
{
strCat="_2";
}
if(KolKub==1)
{
int ZnachKub, XKub, YKub ;
randomize();
ZnachKub = random(6)+1;
XKub=random(126)+14;
YKub=random(126)+14;
Bitmap1->LoadFromResourceName((unsigned
int)HInstance,"KUB"+IntToStr(ZnachKub)+strCat);
Kubiki1[0]->Picture->Bitmap=Bitmap1;
Kubiki1[0]->Left=XKub;
Kubiki1[0]->Top=YKub;
Kubiki1[0]->Visible=true;
MyCurOch=ZnachKub;
MyWholeOch=MyWholeOch+MyCurOch;
strcpy(strSend,DannieToChar(1,
MyCurOch, MyWholeOch, ZnachKub, XKub, YKub));
}
else if (KolKub==2)
{
int ZnachKub1, XKub1, YKub1,
ZnachKub2, XKub2, YKub2;
randomize();
ZnachKub1 = random(6)+1;
XKub1=random(126)+14;
YKub1=random(52)+14;
Bitmap1->LoadFromResourceName((unsigned
int)HInstance,"KUB"+IntToStr(ZnachKub1)+strCat);
Kubiki1[0]->Picture->Bitmap=Bitmap1;
Kubiki1[0]->Left=XKub1;
Kubiki1[0]->Top=YKub1;
Kubiki1[0]->Visible=true;
ZnachKub2 = random(6)+1;
XKub2=random(126)+14;
YKub2=random(52)+88;
Bitmap1->LoadFromResourceName((unsigned
int)HInstance,"KUB"+IntToStr(ZnachKub2)+strCat);
Kubiki1[1]->Picture->Bitmap=Bitmap1;
Kubiki1[1]->Left=XKub2;
Kubiki1[1]->Top=YKub2;
Kubiki1[1]->Visible=true;
MyCurOch=ZnachKub1+ZnachKub2;
MyWholeOch=MyWholeOch+MyCurOch;
strcpy(strSend,DannieToChar(1,
MyCurOch, MyWholeOch, ZnachKub1, XKub1, YKub1, ZnachKub2, XKub2, YKub2));
}
else if (KolKub==3)
{
int ZnachKub1, XKub1, YKub1,
ZnachKub2, XKub2, YKub2, ZnachKub3, XKub3, YKub3;
randomize();
ZnachKub1 = random(6)+1;
XKub1=random(126)+14;
YKub1=random(27)+14;
Bitmap1->LoadFromResourceName((unsigned int)HInstance,"KUB"+IntToStr(ZnachKub1)+strCat);
Kubiki1[0]->Picture->Bitmap=Bitmap1;
Kubiki1[0]->Left=XKub1;
Kubiki1[0]->Top=YKub1;
Kubiki1[0]->Visible=true;
ZnachKub2 = random(6)+1;
XKub2=random(126)+14;
YKub2=random(27)+63;
Bitmap1->LoadFromResourceName((unsigned
int)HInstance,"KUB"+IntToStr(ZnachKub2)+strCat);
Kubiki1[1]->Picture->Bitmap=Bitmap1;
Kubiki1[1]->Left=XKub2;
Kubiki1[1]->Top=YKub2;
Kubiki1[1]->Visible=true;
ZnachKub3 = random(6)+1;
XKub3=random(126)+14;
YKub3=random(28)+112;
Bitmap1->LoadFromResourceName((unsigned
int)HInstance,"KUB"+IntToStr(ZnachKub3)+strCat);
Kubiki1[2]->Picture->Bitmap=Bitmap1;
Kubiki1[2]->Left=XKub3;
Kubiki1[2]->Top=YKub3;
Kubiki1[2]->Visible=true;
MyCurOch=ZnachKub1+ZnachKub2+ZnachKub3;
MyWholeOch=MyWholeOch+MyCurOch;
strcpy(strSend,DannieToChar(1,
MyCurOch, MyWholeOch, ZnachKub1, XKub1, YKub1, ZnachKub2, XKub2, YKub2,
ZnachKub3, XKub3, YKub3));
}
else
{
int ZnachKub1, XKub1, YKub1,
ZnachKub2, XKub2, YKub2, ZnachKub3, XKub3, YKub3, ZnachKub4, XKub4, YKub4;
randomize();
ZnachKub1 = random(6)+1;
XKub1=random(52)+14;
YKub1=random(52)+14;
Bitmap1->LoadFromResourceName((unsigned int)HInstance,"KUB"+IntToStr(ZnachKub1)+strCat);
Kubiki1[0]->Picture->Bitmap=Bitmap1;
Kubiki1[0]->Left=XKub1;
Kubiki1[0]->Top=YKub1;
Kubiki1[0]->Visible=true;
ZnachKub2 = random(6)+1;
XKub2=random(52)+88;
YKub2=random(52)+14;
Bitmap1->LoadFromResourceName((unsigned
int)HInstance,"KUB"+IntToStr(ZnachKub2)+strCat);
Kubiki1[1]->Picture->Bitmap=Bitmap1;
Kubiki1[1]->Left=XKub2;
Kubiki1[1]->Top=YKub2;
Kubiki1[1]->Visible=true;
ZnachKub3 = random(6)+1;
XKub3=random(52)+14;
YKub3=random(52)+88;
Bitmap1->LoadFromResourceName((unsigned
int)HInstance,"KUB"+IntToStr(ZnachKub3)+strCat);
Kubiki1[2]->Picture->Bitmap=Bitmap1;
Kubiki1[2]->Left=XKub3;
Kubiki1[2]->Top=YKub3;
Kubiki1[2]->Visible=true;
ZnachKub4 = random(6)+1;
XKub4=random(52)+88;
YKub4=random(52)+88;
Bitmap1->LoadFromResourceName((unsigned
int)HInstance,"KUB"+IntToStr(ZnachKub4)+strCat);
Kubiki1[3]->Picture->Bitmap=Bitmap1;
Kubiki1[3]->Left=XKub4;
Kubiki1[3]->Top=YKub4;
Kubiki1[3]->Visible=true;
MyCurOch=ZnachKub1+ZnachKub2+ZnachKub3+ZnachKub4;
MyWholeOch=MyWholeOch+MyCurOch;
strcpy(strSend,DannieToChar(1,
MyCurOch, MyWholeOch, ZnachKub1, XKub1, YKub1, ZnachKub2, XKub2,
YKub2,ZnachKub3, XKub3, YKub3, ZnachKub4, XKub4, YKub4));
}
switch(choosenProt)
{
case 0:
IPXSend(strSend);
break;
case 1:
TCPIPSend(AnsiString(strSend));
break;
case 2:
NetBiosSend(strSend);
break;
case 3:
MailSlotSend(strSend);
break;
case 4:
PipeSend(strSend);
break;
}
enum TypeDannihForTabl
DannieForTabl;
DannieForTabl=yabrosil;
ZapolnTabl(DannieForTabl);
Страницы: 1, 2, 3, 4
|