⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.cpp

📁 一个麻将程序。我的。
💻 CPP
📖 第 1 页 / 共 4 页
字号:
        {
            gamestat=LeftWaitForPG;
            flag_pg=2;
            break;
        }
        if(upcom.wanttopeng())
        {
             gamestat=UpWaitForPG;
             flag_pg=1;
             break;
        }
        if(upcom.wanttogang())
        {
            gamestat=UpWaitForPG;
            flag_pg=2;
            break;
        }

        gamestat=UpWaitForMo;

        break;

    case UpWaitForHu:
        // 访问两家电脑 及downplayerwanttogang=true表示玩家也杠
        //判断抢杠和
         //判断painewget是否为零,判断自摸
            timer->Enabled=false;

            if(!flag_zimo)
            {
                upcom.painewget=mjots.getnewest();
            /*rightcom.painewget=11; //另3人补一张其实只是为了不让红旗飘飘函数检测
            leftcom.painewget=11;//painewget时出错,此牌对输的人来说已经无用
            downplayer.painewget=11; */

            //flag_qghu1=false;
                if(downplayerwanttogang||rightcom.wanttogang()||leftcom.wanttogang())
                    flag_qghu1=true;

                //if(!flag_zimo)
                assert(loser!=2);
            }
            soundhu();
            hupaiform=new Thupai(this,downplayer,leftcom,upcom,rightcom,gang,
                flag_qghu1,flag_zimo,2,loser,zhuangjia,name,paishu,imagetype);
            assert(hupaiform);
            hupaiform->calculate(sc);
            hupaiform->ShowModal();
            begin=false;
            delete hupaiform;
                downsc+=sc[0];
                leftsc+=sc[1];
                upsc+=sc[2];
                rightsc+=sc[3];

                zhuangjia=2;
                clearanddrawname();

                N3->Enabled=true;
                N4->Enabled=true;
                N11->Enabled=true;
                start->Visible=true;

            break;
    case LeftWaitForHu:
        // 访问两家电脑 及downplayerwanttogang=true表示玩家也杠
        //判断抢杠和
         //判断painewget是否为零,判断自摸
            timer->Enabled=false;

            if(!flag_zimo)
            {
                leftcom.painewget=mjots.getnewest();
            /*upcom.painewget=11; //另3人补一张其实只是为了不让红旗飘飘函数检测
            rightcom.painewget=11;//painewget时出错,此牌对输的人来说已经无用
            downplayer.painewget=11;  */

            //flag_qghu1=false;
                if(downplayerwanttogang||rightcom.wanttogang()||upcom.wanttogang())
                    flag_qghu1=true;


                //if(!flag_zimo)
                assert(loser!=1);
            }
            soundhu();
            hupaiform=new Thupai(this,downplayer,leftcom,upcom,rightcom,gang,
                flag_qghu1,flag_zimo,1,loser,zhuangjia,name,paishu,imagetype);
            assert(hupaiform);
            hupaiform->calculate(sc);
            hupaiform->ShowModal();
            begin=false;
            delete hupaiform;
                downsc+=sc[0];
                leftsc+=sc[1];
                upsc+=sc[2];
                rightsc+=sc[3];


                zhuangjia=1;
                clearanddrawname();

                N3->Enabled=true;
                N4->Enabled=true;
                N11->Enabled=true;
                start->Visible=true;


            break;
    case RightWaitForHu:
        // 访问两家电脑 及downplayerwanttogang=true表示玩家也杠
        //判断抢杠和
         //判断painewget是否为零,判断自摸
            timer->Enabled=false;

            if(!flag_zimo)
            {
                rightcom.painewget=mjots.getnewest();
            /*upcom.painewget=11; //另3人补一张其实只是为了不让红旗飘飘函数检测
            leftcom.painewget=11;//painewget时出错,此牌对输的人来说已经无用
            downplayer.painewget=11; */

                //flag_qghu1=false;
                if(downplayerwanttogang||upcom.wanttogang()||leftcom.wanttogang())
                    flag_qghu1=true;


                //if(!flag_zimo)
                assert(loser!=3);
            }
            soundhu();
            hupaiform=new Thupai(this,downplayer,leftcom,upcom,rightcom,gang,
                flag_qghu1,flag_zimo,3,loser,zhuangjia,name,paishu,imagetype);
            assert(hupaiform);
            hupaiform->calculate(sc);
            hupaiform->ShowModal();
            begin=false;
            delete hupaiform;
                downsc+=sc[0];
                leftsc+=sc[1];
                upsc+=sc[2];
                rightsc+=sc[3];

                zhuangjia=3;
                clearanddrawname();

                N3->Enabled=true;
                N4->Enabled=true;
                N11->Enabled=true;
                start->Visible=true;

            break;
     case WaitForHuangZhuang:
            timer->Enabled=false;
            Application->MessageBox("流局","流局",MB_OK);

            //clearform();
            begin=false;
            clearanddrawname();

            N3->Enabled=true;
            N4->Enabled=true;
            N11->Enabled=true;
            start->Visible=true;
            break;

    }

}
void __fastcall TForm1::timerTimer(TObject *Sender)
{   timerfun();
}
//---------------------------------------------------------------------------



void __fastcall TForm1::PaintBox1DblClick(TObject *Sender)
{
    if(!begin) return;
    bool a=  timer->Enabled;
    timer->Enabled=false;

    Form2=new TForm2(this);
    assert(Form2);
    Form2->ShowModal();

    delete Form2;
    timer->Enabled=a;    
}
//---------------------------------------------------------------------------


void __fastcall TForm1::startClick(TObject *Sender)
{
    mjot.setfirst(random(4),random(15)*2);

    mjot.reset();
    mjot.wash();

    mjots.clear();
    
    leftcom.clear();
    upcom.clear();
    rightcom.clear();
    downplayer.clear();

    fapai_dir=zhuangjia;
    fapai_num=0;
    gamestat=fapai;
    begin=true;
    numofgames++;

    gang=false;
    flag_bugang=false;
    downplayerwanttogang=false;
    flag_zimo=false;
    playerPGflag=btNo;

    N3->Enabled=false;
    N4->Enabled=false;
    N11->Enabled=false;
    start->Visible=false;

    timer->Interval=gamespeed/5;
    timer->Enabled=true;
    this->Refresh();
}
//---------------------------------------------------------------------------


void __fastcall TForm1::N3Click(TObject *Sender)
{
    if(start->Visible==true)start->Click();    
}
//---------------------------------------------------------------------------

void __fastcall TForm1::N4Click(TObject *Sender)
{
    setpaishu=new Tsetpaishu(this,paishu,avepaishu,moneyperpai);
    assert(setpaishu);
    setpaishu->ShowModal();
    delete setpaishu;
    //this->Refresh();

    clearanddrawname();

    if(begin) PaintBox1Paint(Sender); 

}
//---------------------------------------------------------------------------

void __fastcall TForm1::N2Click(TObject *Sender)
{
    saveForm=new TsaveForm(this,paishu,moneyperpai,name,downsc,leftsc,upsc,rightsc,
        zhuangjia,numofgames,gamespeed,difficult,imagetype);
    assert(saveForm);
    saveForm->ShowModal();
    delete saveForm;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::N5Click(TObject *Sender)
{
    speedset=new Tspeedset(this,gamespeed);
    assert(speedset);
    speedset->ShowModal();
    delete  speedset;

    timer->Interval=gamespeed;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::N10Click(TObject *Sender)
{
    colorset=new Tcolorset(this,imagetype);
    assert(colorset);
    colorset->ShowModal();
    delete colorset;
  /*
if(bigsize) {
    if (imdownming1==NULL)
    {
         imdownming1=new Graphics::TBitmap;
         imdownming1->LoadFromFile("upming1_big.bmp");
    }
    if (imdownming2==NULL)
    {
         imdownming2=new Graphics::TBitmap;
         imdownming2->LoadFromFile("upming2_big.bmp");
    }
    if (imdownan1==NULL)
    {
         imdownan1=new Graphics::TBitmap;
         imdownan1->LoadFromFile("upan1_big.bmp");
    }
    if (imdownan2==NULL)
    {
         imdownan2=new Graphics::TBitmap;
         imdownan2->LoadFromFile("upan2_big.bmp");
    }
}         */

    clearform();
    Refresh();
    setbkcolor();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::N11Click(TObject *Sender)
{
    nameset=new Tnameset(this,name,downsc,leftsc,upsc,rightsc,moneyperpai);
    assert(nameset);
    nameset->ShowModal();
    delete nameset;

    clearanddrawname(); 
    if(begin) PaintBox1Paint(Sender); 
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
    #ifndef NLABEL
    Label5->Visible=true;
    Label6->Visible=true;
    Label7->Visible=true;
    #endif
    /*mjpai a[]={2,3,4,5,6};
    mjpaizu zu(a,5);

    int d=zu.find(6);*/
}
//---------------------------------------------------------------------------

void __fastcall TForm1::N9Click(TObject *Sender)
{
    ShellAbout(Handle, "九江麻将","九江麻将1.01(2003.2-4) 张浩 版权所有!",
        Application->Icon->Handle);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::N12Click(TObject *Sender)
{
    timer->Enabled=false;

    TRegistry *reg = new TRegistry;
    assert(reg);
    reg->OpenKeyReadOnly("\\Software\\zhanghao's jjmj");
    bool cb1=false,cb2=false,cb3=false;


    if(reg->ValueExists("cb1"))
        cb1=reg->ReadBool("cb1");
    if(reg->ValueExists("cb2"))
        cb2=reg->ReadBool("cb2");
    if(reg->ValueExists("cb3"))
        cb3=reg->ReadBool("cb3");

    if(!cb1&&!cb2&&!cb3){
        Application->MessageBox("进度为空","无进度",MB_OK);
        reg->CloseKey();
        return;
    }

    if(cb1)
    {

        for(int i=0;i<25;i++)
            paishu[i]=reg->ReadInteger(AnsiString("paishu")+i);
            
        avepaishu=0;
        for(int i=0;i<25;i++)
            avepaishu+=paishu[i];
        avepaishu/=25;

        moneyperpai=reg->ReadFloat("moneyperpai");
    }

    if(cb2)
    {
        for(int i=0;i<4;i++)
            name[i]=reg->ReadString(AnsiString("name")+i);

        downsc=reg->ReadInteger("downsc");
        leftsc=reg->ReadInteger("leftsc");
        upsc=reg->ReadInteger("upsc");
        rightsc=reg->ReadInteger("rightsc");
        zhuangjia=reg->ReadInteger("zhuangjia");
        numofgames=reg->ReadInteger("numofgames");
    }

    if(cb3)
    {
        gamespeed=(unsigned int)reg->ReadInteger("gamespeed");
        difficult=reg->ReadInteger("difficult");
        imagetype=reg->ReadInteger("imagetype");
        //N16->Checked=reg->ReadBool("music");
        //bigsize=reg->ReadBool("bigimage");
    }

    reg->CloseKey();
           /*
if(bigsize) {
    if (imdownming1==NULL)
    {
         imdownming1=new Graphics::TBitmap;
         imdownming1->LoadFromFile("upming1_big.bmp");
    }
    if (imdownming2==NULL)
    {
         imdownming2=new Graphics::TBitmap;
         imdownming2->LoadFromFile("upming2_big.bmp");
    }
    if (imdownan1==NULL)
    {
         imdownan1=new Graphics::TBitmap;
         imdownan1->LoadFromFile("upan1_big.bmp");
    }
    if (imdownan2==NULL)
    {
         imdownan2=new Graphics::TBitmap;
         imdownan2->LoadFromFile("upan2_big.bmp");
    }
}
     */
    begin=false;
    clearanddrawname();
    //N16->Checked?MediaPlayer1->Play():MediaPlayer1->Stop();
    setbkcolor();

    N3->Enabled=true;
    N4->Enabled=true;
    N11->Enabled=true;
    start->Visible=true;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::N6Click(TObject *Sender)
{
    difficultf=new Tdifficult(this,difficult);
    assert(difficultf);
    difficultf->ShowModal();
    delete difficultf;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::N8Click(TObject *Sender)
{
    Form3=new TForm3(this);
    assert(Form3);
    Form3->ShowModal();
    delete Form3;
}
//---------------------------------------------------------------------------


void __fastcall TForm1::N16Click(TObject *Sender)
{
    N16->Checked=!N16->Checked;

    if(N16->Checked)
        m_sound=true;
    else
        m_sound=false;

}
//---------------------------------------------------------------------------



void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
    if(imdownming1!=NULL) delete imdownming1;    
    if(imdownming2!=NULL) delete imdownming2;
    if(imdownan1!=NULL) delete imdownan1;
    if(imdownan2!=NULL) delete imdownan2;
}
//---------------------------------------------------------------------------

void soundpeng()
{
    if(!Form1->m_sound)return;
     Form1->sound->FileName="wav\\wfn42.wav";
     Form1->sound->Open();
     Form1->sound->Play();
}
void soundgang()
{
     if(!Form1->m_sound)return;

     Form1->sound->FileName="wav\\wfn43.wav";
     Form1->sound->Open();
     Form1->sound->Play();

}
void soundhu()
{
    if(!Form1->m_sound)return;
     Form1->sound->FileName="wav\\wfn44.wav";
     Form1->sound->Open();
     Form1->sound->Play();

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -