重做斗地主View.cpp
上传用户:xyf7799
上传日期:2022-08-01
资源大小:2008k
文件大小:47k
源码类别:

棋牌游戏

开发平台:

Visual C++

  1. // 重做斗地主View.cpp : implementation of the CMyView class
  2. //
  3. #include "stdafx.h"
  4. #include "重做斗地主.h"
  5. #include "重做斗地主Doc.h"
  6. #include "重做斗地主View.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CMyView
  14. IMPLEMENT_DYNCREATE(CMyView, CView)
  15. BEGIN_MESSAGE_MAP(CMyView, CView)
  16. //{{AFX_MSG_MAP(CMyView)
  17. ON_WM_LBUTTONDOWN()
  18. ON_WM_RBUTTONDOWN()
  19. ON_COMMAND(IDM_BAN_START, OnBanStart)
  20. ON_WM_KEYDOWN()
  21. //}}AFX_MSG_MAP
  22. END_MESSAGE_MAP()
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CMyView construction/destruction
  25. CMyView::CMyView()
  26. {
  27. // TODO: add construction code here
  28. //位图的引入
  29. for(int i=0;i<54;i++)
  30. {
  31. bmpPai[i].LoadBitmap(IDB_BITMAP1+i);
  32. }
  33. bmpTable.LoadBitmap(IDB_BITMAP55);
  34. bmpCusor.LoadBitmap(IDB_BITMAP56);
  35. bmpNull.LoadBitmap(IDB_BITMAP57);
  36. bmpZheDang.LoadBitmap(IDB_BITMAP61);
  37. for(i=0;i<3;i++)
  38. {
  39. bmpTurn[i].LoadBitmap(IDB_BITMAP58+i);
  40. }
  41. //初始化所有的牌组
  42. for(i=0;i<20;i++)
  43. {
  44. P[i].z=0;
  45. C1[i].z=0;
  46. C2[i].z=0;
  47. L[i].z=0;
  48. nCusor[i]=0;
  49. F[i].z=0;
  50. }
  51. //定义地主是谁
  52. srand(GetTickCount());
  53. nIsDiZhu=rand()%3;
  54. nIsWho=nIsDiZhu;
  55. nLastFormWho=2;
  56. for(i=0;i<3;i++)
  57. {
  58. nZongZiJin[i]=1000;
  59. }
  60. //发牌
  61. srand(GetTickCount());
  62. i=0;
  63. int j=0;
  64. int DiZhuPai[3];
  65. int temp;
  66. BOOL isChongFu=FALSE;
  67. for(i=0;i<3;i++)
  68. {
  69. DiZhuPai[i]=0;
  70. }
  71. //先定义三张地主牌
  72. i=0;
  73. while(i<3)
  74. {
  75. temp=rand()%54+1;
  76. for(j=0;j<3;j++)
  77. {
  78. if(DiZhuPai[j]==temp)
  79. isChongFu=TRUE;
  80. break;
  81. }
  82. if(isChongFu==FALSE)
  83. {
  84. DiZhuPai[i]=temp;
  85. i++;
  86. }
  87. isChongFu=FALSE;
  88. }
  89. switch(nIsDiZhu)
  90. {
  91. case 0:
  92. C1[19].z=DiZhuPai[2];
  93. C1[18].z=DiZhuPai[1];
  94. C1[17].z=DiZhuPai[0];
  95. break;
  96. case 1:
  97. C2[19].z=DiZhuPai[2];
  98. C2[18].z=DiZhuPai[1];
  99. C2[17].z=DiZhuPai[0];
  100. break;
  101. case 2:
  102. P[19].z=DiZhuPai[2];
  103. P[18].z=DiZhuPai[1];
  104. P[17].z=DiZhuPai[0];
  105. break;
  106. default:
  107. break;
  108. }
  109. //下面是定义剩下的牌
  110. i=1;
  111. int a=0;
  112. int b=0;
  113. int c=0;
  114. while(i<=54)
  115. {
  116. if(i==DiZhuPai[0]||i==DiZhuPai[1]||i==DiZhuPai[2])
  117. {
  118. i++;
  119. }
  120. else
  121. {
  122. j=rand()%3;
  123. switch(j)
  124. {
  125. case 0:
  126. if(a<17)
  127. {
  128. C1[a].z=i;
  129. a++;
  130. i++;
  131. }
  132. break;
  133. case 1:
  134. if(b<17)
  135. {
  136. C2[b].z=i;
  137. b++;
  138. i++;
  139. }
  140. break;
  141. case 2:
  142. if(c<17)
  143. {
  144. P[c].z=i;
  145. c++;
  146. i++;
  147. }
  148. break;
  149. default:
  150. break;
  151. }
  152. }
  153. }
  154. PaiXu(0);
  155. PaiXu(1);
  156. PaiXu(2);
  157. }
  158. CMyView::~CMyView()
  159. {
  160. }
  161. BOOL CMyView::PreCreateWindow(CREATESTRUCT& cs)
  162. {
  163. // TODO: Modify the Window class or styles here by modifying
  164. //  the CREATESTRUCT cs
  165. return CView::PreCreateWindow(cs);
  166. }
  167. /////////////////////////////////////////////////////////////////////////////
  168. // CMyView drawing
  169. void CMyView::OnDraw(CDC* pDC)
  170. {
  171. CMyDoc* pDoc = GetDocument();
  172. ASSERT_VALID(pDoc);
  173. // TODO: add draw code for native data here
  174. //牌桌和牌的显示
  175. CDC dc;
  176. dc.CreateCompatibleDC(pDC);
  177. dc.SelectObject(bmpTable);
  178. pDC->StretchBlt(0,0,640,410,&dc,0,0,640,410,SRCCOPY);
  179. for(int i=0;i<20;i++)
  180. {
  181. if(C1[i].z!=0)
  182. {
  183. TransparentBitmap(pDC->GetSafeHdc(),bmpPai[C1[i].z-1],i*32,150,0,0,RGB(0,0,255));
  184. }
  185. else
  186. {
  187. TransparentBitmap(pDC->GetSafeHdc(),bmpNull,i*32,150,0,0,RGB(255,255,255));
  188. }
  189. }
  190. for(i=0;i<20;i++)
  191. {
  192. if(C2[i].z!=0)
  193. {
  194. TransparentBitmap(pDC->GetSafeHdc(),bmpPai[C2[i].z-1],i*32,214,0,0,RGB(0,0,255));
  195. }
  196. else
  197. {
  198. TransparentBitmap(pDC->GetSafeHdc(),bmpNull,i*32,214,0,0,RGB(255,255,255));
  199. }
  200. }
  201. for(i=0;i<20;i++)
  202. {
  203. if(P[i].z!=0)
  204. {
  205. TransparentBitmap(pDC->GetSafeHdc(),bmpPai[P[i].z-1],i*32,278,0,0,RGB(0,0,255));
  206. }
  207. else
  208. {
  209. TransparentBitmap(pDC->GetSafeHdc(),bmpNull,i*32,278,0,0,RGB(255,255,255));
  210. }
  211. }
  212. for(i=0;i<20;i++)
  213. {
  214. if(L[i].z!=0)
  215. {
  216. TransparentBitmap(pDC->GetSafeHdc(),bmpPai[L[i].z-1],i*32,342,0,0,RGB(0,0,255));
  217. }
  218. else
  219. {
  220. TransparentBitmap(pDC->GetSafeHdc(),bmpNull,i*32,342,0,0,RGB(255,255,255));
  221. }
  222. }
  223. //光标和轮到谁的显示
  224. switch(nIsWho)
  225. {
  226. case 0:
  227. TransparentBitmap(pDC->GetSafeHdc(),bmpTurn[0],0,0,0,0,RGB(0,0,255));
  228. for(i=0;i<20;i++)
  229. {
  230. if(nCusor[i]==1)
  231. TransparentBitmap(pDC->GetSafeHdc(),bmpCusor,i*32,150,0,0,RGB(255,255,255));
  232. }
  233. break;
  234. case 1:
  235. TransparentBitmap(pDC->GetSafeHdc(),bmpTurn[1],0,0,0,0,RGB(0,0,255));
  236. for(i=0;i<20;i++)
  237. {
  238. if(nCusor[i]==1)
  239. TransparentBitmap(pDC->GetSafeHdc(),bmpCusor,i*32,214,0,0,RGB(255,255,255));
  240. }
  241. break;
  242. case 2:
  243. TransparentBitmap(pDC->GetSafeHdc(),bmpTurn[2],0,0,0,0,RGB(0,0,255));
  244. for(i=0;i<20;i++)
  245. {
  246. if(nCusor[i]==1)
  247. TransparentBitmap(pDC->GetSafeHdc(),bmpCusor,i*32,278,0,0,RGB(255,255,255));
  248. }
  249. break;
  250. default:
  251. break;
  252. }
  253. //积分的显示
  254. CString str;
  255. pDC->SetBkColor(RGB(0,128,0));
  256. str.Format("%d",nZongZiJin[0]);
  257. pDC->TextOut(108,134,str);
  258. str.Format("%d",nZongZiJin[1]);
  259. pDC->TextOut(108,198,str);
  260. str.Format("%d",nZongZiJin[2]);
  261. pDC->TextOut(108,262,str);
  262. }
  263. /////////////////////////////////////////////////////////////////////////////
  264. // CMyView diagnostics
  265. #ifdef _DEBUG
  266. void CMyView::AssertValid() const
  267. {
  268. CView::AssertValid();
  269. }
  270. void CMyView::Dump(CDumpContext& dc) const
  271. {
  272. CView::Dump(dc);
  273. }
  274. CMyDoc* CMyView::GetDocument() // non-debug version is inline
  275. {
  276. ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyDoc)));
  277. return (CMyDoc*)m_pDocument;
  278. }
  279. #endif //_DEBUG
  280. /////////////////////////////////////////////////////////////////////////////
  281. // CMyView message handlers
  282. void CMyView::TransparentBitmap(HDC hdc, HBITMAP hBitmap,short xStart, short yStart,
  283. short xadd,short yadd, COLORREF cTransparentColor)
  284. {
  285.    BITMAP     m_bm;
  286.    COLORREF   cColor;  
  287.    // 创建临时DC
  288.    HDC     hMem, hBack, hObject, hTemp, hSave;
  289.    hBack   = CreateCompatibleDC(hdc);
  290.    hObject = CreateCompatibleDC(hdc);
  291.    hMem    = CreateCompatibleDC(hdc);
  292.    hSave   = CreateCompatibleDC(hdc);   
  293.    hTemp   = CreateCompatibleDC(hdc);
  294.    // 选入位图
  295.    SelectObject(hTemp, hBitmap);   
  296.    GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&m_bm);
  297.    //显示位图宽高
  298.    POINT      ptSize;
  299.    // 取得位图的宽度
  300.    ptSize.x = m_bm.bmWidth;     
  301.     // 取得位图的该度
  302.    ptSize.y = m_bm.bmHeight;           
  303.    // 转换为逻辑点值
  304.    DPtoLP(hTemp, &ptSize, 1);   
  305.    // 创建临时位图
  306.    HBITMAP    bmBack, bmObject, bmMem, bmSave;
  307.    // 单色位图
  308.    bmBack   = CreateBitmap(ptSize.x, ptSize.y, 1, 1, NULL);    
  309.    bmObject = CreateBitmap(ptSize.x, ptSize.y, 1, 1, NULL);
  310.    // 与设备兼容位图
  311.    bmMem    = CreateCompatibleBitmap(hdc, ptSize.x, ptSize.y);
  312.    bmSave      = CreateCompatibleBitmap(hdc, ptSize.x, ptSize.y);
  313.    // 将创建的临时位图选入临时DC中
  314.    HBITMAP    OldbmBack, OldbmObject, OldbmMem, OldbmSave;
  315.    OldbmBack   = (HBITMAP)SelectObject(hBack, bmBack);
  316.    OldbmObject = (HBITMAP)SelectObject(hObject, bmObject);
  317.    OldbmMem    = (HBITMAP)SelectObject(hMem, bmMem);
  318.    OldbmSave   = (HBITMAP)SelectObject(hSave, bmSave);
  319.    // 设置映射模式
  320.    SetMapMode(hTemp, GetMapMode(hdc));
  321.    // 先保留原始位图
  322.    BitBlt(hSave, 0, 0, ptSize.x, ptSize.y, hTemp, 0, 0, SRCCOPY);
  323.    // 将背景颜色设置为需透明的颜色
  324.    cColor = SetBkColor(hTemp, cTransparentColor);
  325.    // 创建目标屏蔽码
  326.    BitBlt(hObject, 0, 0, ptSize.x, ptSize.y, hTemp, 0, 0, SRCCOPY);
  327.    // 恢复源DC的原始背景色
  328.    SetBkColor(hTemp, cColor);
  329.    // 创建反转的目标屏蔽码
  330.    BitBlt(hBack, 0, 0, ptSize.x, ptSize.y, hObject, 0, 0, NOTSRCCOPY);
  331.    // 拷贝主DC的背景到目标DC
  332.    BitBlt(hMem, 0, 0, ptSize.x, ptSize.y, hdc, xStart, yStart, SRCCOPY);
  333.    // 屏蔽位图的显示区
  334.    BitBlt(hMem, 0, 0, ptSize.x, ptSize.y, hObject, 0, 0, SRCAND);
  335.    // 屏蔽位图中的透明色
  336.    BitBlt(hTemp, 0, 0, ptSize.x, ptSize.y, hBack, 0, 0, SRCAND);
  337.    // 将位图与目标DC的背景左异或操作
  338.    BitBlt(hMem, 0, 0, ptSize.x, ptSize.y, hTemp, 0, 0, SRCPAINT);
  339.    // 拷贝目标到屏幕上 
  340.    StretchBlt(hdc, xStart, yStart, ptSize.x+xadd, ptSize.y+yadd, hMem, 0, 0, ptSize.x, ptSize.y,SRCCOPY);
  341.    // 恢复原始位图
  342.    BitBlt(hTemp, 0, 0, ptSize.x, ptSize.y, hSave, 0, 0, SRCCOPY);
  343.    // 删除临时内存位图
  344.    DeleteObject(SelectObject(hBack, OldbmBack));
  345.    DeleteObject(SelectObject(hObject, OldbmObject));
  346.    DeleteObject(SelectObject(hMem, OldbmMem));
  347.    DeleteObject(SelectObject(hSave, OldbmSave));
  348.    // 删除临时内存DC
  349.    DeleteDC(hMem);
  350.    DeleteDC(hBack);
  351.    DeleteDC(hObject);
  352.    DeleteDC(hSave);
  353.    DeleteDC(hTemp);
  354. }
  355. void CMyView::OnLButtonDown(UINT nFlags, CPoint point) 
  356. {
  357. // TODO: Add your message handler code here and/or call default
  358. int i=point.x/32;
  359. switch(nIsWho)
  360. {
  361. case 0:
  362. if(point.y<150||point.y>182)
  363. return;
  364. if(nCusor[i]==0)
  365. {
  366. if(C1[i].z!=0)
  367. nCusor[i]=1;
  368. }
  369. else
  370. {
  371. if(C1[i].z!=0)
  372. nCusor[i]=0;
  373. }
  374. InvalidateRect(CRect(i*32,150,i*32+32,182));
  375. break;
  376. case 1:
  377. if(point.y<214||point.y>246)
  378. return;
  379. if(nCusor[i]==0)
  380. {
  381. if(C2[i].z!=0)
  382. nCusor[i]=1;
  383. }
  384. else
  385. {
  386. if(C2[i].z!=0)
  387. nCusor[i]=0;
  388. }
  389. InvalidateRect(CRect(i*32,214,i*32+32,246));
  390. break;
  391. case 2:
  392. if(point.y<278||point.y>310)
  393. return;
  394. if(nCusor[i]==1)
  395. {
  396. if(P[i].z!=0)
  397. nCusor[i]=0;
  398. }
  399. else
  400. {
  401. if(P[i].z!=0)
  402. nCusor[i]=1;
  403. }
  404. InvalidateRect(CRect(i*32,278,i*32+32,310));
  405. break;
  406. }
  407. CView::OnLButtonDown(nFlags, point);
  408. }
  409. void CMyView::OnRButtonDown(UINT nFlags, CPoint point) 
  410. {
  411. // TODO: Add your message handler code here and/or call default
  412. int i=0;
  413. int cusorNum=0;
  414. for(i=0;i<20;i++)
  415. {
  416. if(nCusor[i]==1)
  417. cusorNum++;
  418. }
  419. switch(nIsWho)
  420. {
  421. case 0:
  422. if(cusorNum==0)
  423. return;
  424. for(i=0;i<20;i++)
  425. {
  426. F[i].z=0;
  427. if(nCusor[i]==1)
  428. F[i].z=C1[i].z;
  429. }
  430. PaiXu(4);
  431. if(ChuPaiRule()==FALSE)
  432. {
  433. MessageBox("不符合出牌规则!");
  434. return;
  435. }
  436. //////////////////////////////////////////////
  437. for(i=0;i<20;i++)
  438. {
  439. L[i].z=0;
  440. }
  441. for(i=0;i<20;i++)
  442. {
  443. if(nCusor[i]==1)
  444. {
  445. L[i].z=C1[i].z;
  446. C1[i].z=0;
  447. }
  448. }
  449. for(i=0;i<20;i++)
  450. {
  451. nCusor[i]=0;
  452. }
  453. //////////////////////////////////////////////
  454. PaiXu(0);
  455. PaiXu(3);
  456. InvalidateRect(CRect(0,150,640,182));
  457. InvalidateRect(CRect(0,342,640,374));
  458. nIsWho=++nIsWho%3;
  459. nLastFormWho=2;
  460. break;
  461. case 1:
  462. if(cusorNum==0)
  463. return;
  464. for(i=0;i<20;i++)
  465. {
  466. F[i].z=0;
  467. if(nCusor[i]==1)
  468. F[i].z=C2[i].z;
  469. }
  470. PaiXu(4);
  471. if(ChuPaiRule()==FALSE)
  472. {
  473. MessageBox("不符合出牌规则!");
  474. return;
  475. }
  476. //////////////////////////////////////////////
  477. for(i=0;i<20;i++)
  478. {
  479. L[i].z=0;
  480. }
  481. for(i=0;i<20;i++)
  482. {
  483. if(nCusor[i]==1)
  484. {
  485. L[i].z=C2[i].z;
  486. C2[i].z=0;
  487. }
  488. }
  489. for(i=0;i<20;i++)
  490. {
  491. nCusor[i]=0;
  492. }
  493. //////////////////////////////////////////////
  494. PaiXu(1);
  495. PaiXu(3);
  496. InvalidateRect(CRect(0,214,640,246));
  497. InvalidateRect(CRect(0,342,640,374));
  498. nIsWho=++nIsWho%3;
  499. nLastFormWho=2;
  500. break;
  501. case 2:
  502. if(cusorNum==0)
  503. return;
  504. for(i=0;i<20;i++)
  505. {
  506. F[i].z=0;
  507. if(nCusor[i]==1)
  508. F[i].z=P[i].z;
  509. }
  510. PaiXu(4);
  511. if(ChuPaiRule()==FALSE)
  512. {
  513. MessageBox("不符合出牌规则!");
  514. return;
  515. }
  516. //////////////////////////////////////////////
  517. for(i=0;i<20;i++)
  518. {
  519. L[i].z=0;
  520. }
  521. for(i=0;i<20;i++)
  522. {
  523. if(nCusor[i]==1)
  524. {
  525. L[i].z=P[i].z;
  526. P[i].z=0;
  527. }
  528. }
  529. for(i=0;i<20;i++)
  530. {
  531. nCusor[i]=0;
  532. }
  533. //////////////////////////////////////////////
  534. PaiXu(2);
  535. PaiXu(3);
  536. InvalidateRect(CRect(0,278,640,310));
  537. InvalidateRect(CRect(0,342,640,374));
  538. nIsWho=++nIsWho%3;
  539. nLastFormWho=2;
  540. break;
  541. }
  542. InvalidateRect(CRect(0,0,72,16));
  543. //关于胜利的判断
  544. int jiShu=0;
  545. for(i=0;i<20;i++)
  546. {
  547. if(C1[i].z!=0)
  548. jiShu++;
  549. else
  550. break;
  551. }
  552. if(jiShu==0)
  553. {
  554. MessageBox("电脑1胜!");
  555. MessageBox("进入下轮");
  556. if(nIsDiZhu==0)
  557. {
  558. nZongZiJin[0]+=200;
  559. nZongZiJin[1]-=100;
  560. nZongZiJin[2]-=100;
  561. }
  562. else if(nIsDiZhu==1)
  563. {
  564. nZongZiJin[0]+=100;
  565. nZongZiJin[1]-=200;
  566. nZongZiJin[2]+=100;
  567. }
  568. else if(nIsDiZhu==2)
  569. {
  570. nZongZiJin[0]+=100;
  571. nZongZiJin[1]+=100;
  572. nZongZiJin[2]-=200;
  573. }
  574. nIsDiZhu=0;
  575. nIsWho=0;
  576. AllQingKong();
  577. OnBanStart();
  578. }
  579. else
  580. {
  581. jiShu=0;
  582. for(i=0;i<20;i++)
  583. {
  584. if(C2[i].z!=0)
  585. jiShu++;
  586. else
  587. break;
  588. }
  589. if(jiShu==0)
  590. {
  591. MessageBox("电脑2胜!");
  592. MessageBox("进入下轮");
  593. if(nIsDiZhu==0)
  594. {
  595. nZongZiJin[0]-=200;
  596. nZongZiJin[1]+=100;
  597. nZongZiJin[2]+=100;
  598. }
  599. else if(nIsDiZhu==1)
  600. {
  601. nZongZiJin[0]-=100;
  602. nZongZiJin[1]+=200;
  603. nZongZiJin[2]-=100;
  604. }
  605. else if(nIsDiZhu==2)
  606. {
  607. nZongZiJin[0]+=100;
  608. nZongZiJin[1]+=100;
  609. nZongZiJin[2]-=200;
  610. }
  611. nIsDiZhu=1;
  612. nIsWho=1;
  613. AllQingKong();
  614. OnBanStart();
  615. }
  616. else
  617. {
  618. jiShu=0;
  619. for(i=0;i<20;i++)
  620. {
  621. if(P[i].z!=0)
  622. jiShu++;
  623. else
  624. break;
  625. }
  626. if(jiShu==0)
  627. {
  628. MessageBox("玩家胜!");
  629. MessageBox("进入下轮");
  630. if(nIsDiZhu==0)
  631. {
  632. nZongZiJin[0]-=200;
  633. nZongZiJin[1]+=100;
  634. nZongZiJin[2]+=100;
  635. }
  636. else if(nIsDiZhu==1)
  637. {
  638. nZongZiJin[0]+=100;
  639. nZongZiJin[1]-=200;
  640. nZongZiJin[2]+=100;
  641. }
  642. else if(nIsDiZhu==2)
  643. {
  644. nZongZiJin[0]-=100;
  645. nZongZiJin[1]-=100;
  646. nZongZiJin[2]+=200;
  647. }
  648. nIsDiZhu=2;
  649. nIsWho=2;
  650. AllQingKong();
  651. OnBanStart();
  652. }
  653. }
  654. }
  655. CView::OnRButtonDown(nFlags, point);
  656. }
  657. void CMyView::PaiXu(int nTurn)
  658. {
  659. int i=0;
  660. int nTemp[20];
  661. for(i=0;i<20;i++)
  662. {
  663. nTemp[i]=0;
  664. }
  665. int j=0;
  666. int z=0;
  667. int zz=0;
  668. int zzz=0;
  669. switch(nTurn)
  670. {
  671. case 0:
  672. for(z=3;z<=13;z++)
  673. {
  674. zz=z;
  675. for(zzz=0;zzz<4;zzz++)
  676. {
  677. for(i=0;i<20;i++)
  678. {
  679. if(C1[i].z==zz)
  680. {
  681. nTemp[j]=zz;
  682. j++;
  683. }
  684. }
  685. zz+=13;
  686. }
  687. }
  688. for(z=1;z<=2;z++)
  689. {
  690. zz=z;
  691. for(zzz=0;zzz<4;zzz++)
  692. {
  693. for(i=0;i<20;i++)
  694. {
  695. if(C1[i].z==zz)
  696. {
  697. nTemp[j]=zz;
  698. j++;
  699. }
  700. }
  701. zz+=13;
  702. }
  703. }
  704. for(i=0;i<20;i++)
  705. {
  706. if(C1[i].z==53)
  707. {
  708. nTemp[j]=53;
  709. j++;
  710. }
  711. }
  712. for(i=0;i<20;i++)
  713. {
  714. if(C1[i].z==54)
  715. {
  716. nTemp[j]=54;
  717. j++;
  718. }
  719. }
  720. for(i=0;i<20;i++)
  721. {
  722. if(C1[i].z==0)
  723. {
  724. nTemp[j]=0;
  725. j++;
  726. }
  727. }
  728. for(i=0;i<20;i++)
  729. {
  730. C1[i].z=nTemp[i];
  731. }
  732. break;
  733. case 1:
  734. for(z=3;z<=13;z++)
  735. {
  736. zz=z;
  737. for(zzz=0;zzz<4;zzz++)
  738. {
  739. for(i=0;i<20;i++)
  740. {
  741. if(C2[i].z==zz)
  742. {
  743. nTemp[j]=zz;
  744. j++;
  745. }
  746. }
  747. zz+=13;
  748. }
  749. }
  750. for(z=1;z<=2;z++)
  751. {
  752. zz=z;
  753. for(zzz=0;zzz<4;zzz++)
  754. {
  755. for(i=0;i<20;i++)
  756. {
  757. if(C2[i].z==zz)
  758. {
  759. nTemp[j]=zz;
  760. j++;
  761. }
  762. }
  763. zz+=13;
  764. }
  765. }
  766. for(i=0;i<20;i++)
  767. {
  768. if(C2[i].z==53)
  769. {
  770. nTemp[j]=53;
  771. j++;
  772. }
  773. }
  774. for(i=0;i<20;i++)
  775. {
  776. if(C2[i].z==54)
  777. {
  778. nTemp[j]=54;
  779. j++;
  780. }
  781. }
  782. for(i=0;i<20;i++)
  783. {
  784. if(C2[i].z==0)
  785. {
  786. nTemp[j]=0;
  787. j++;
  788. }
  789. }
  790. for(i=0;i<20;i++)
  791. {
  792. C2[i].z=nTemp[i];
  793. }
  794. break;
  795. case 2:
  796. for(z=3;z<=13;z++)
  797. {
  798. zz=z;
  799. for(zzz=0;zzz<4;zzz++)
  800. {
  801. for(i=0;i<20;i++)
  802. {
  803. if(P[i].z==zz)
  804. {
  805. nTemp[j]=zz;
  806. j++;
  807. }
  808. }
  809. zz+=13;
  810. }
  811. }
  812. for(z=1;z<=2;z++)
  813. {
  814. zz=z;
  815. for(zzz=0;zzz<4;zzz++)
  816. {
  817. for(i=0;i<20;i++)
  818. {
  819. if(P[i].z==zz)
  820. {
  821. nTemp[j]=zz;
  822. j++;
  823. }
  824. }
  825. zz+=13;
  826. }
  827. }
  828. for(i=0;i<20;i++)
  829. {
  830. if(P[i].z==53)
  831. {
  832. nTemp[j]=53;
  833. j++;
  834. }
  835. }
  836. for(i=0;i<20;i++)
  837. {
  838. if(P[i].z==54)
  839. {
  840. nTemp[j]=54;
  841. j++;
  842. }
  843. }
  844. for(i=0;i<20;i++)
  845. {
  846. if(P[i].z==0)
  847. {
  848. nTemp[j]=0;
  849. j++;
  850. }
  851. }
  852. for(i=0;i<20;i++)
  853. {
  854. P[i].z=nTemp[i];
  855. }
  856. break;
  857. case 3:
  858. for(z=3;z<=13;z++)
  859. {
  860. zz=z;
  861. for(zzz=0;zzz<4;zzz++)
  862. {
  863. for(i=0;i<20;i++)
  864. {
  865. if(L[i].z==zz)
  866. {
  867. nTemp[j]=zz;
  868. j++;
  869. }
  870. }
  871. zz+=13;
  872. }
  873. }
  874. for(z=1;z<=2;z++)
  875. {
  876. zz=z;
  877. for(zzz=0;zzz<4;zzz++)
  878. {
  879. for(i=0;i<20;i++)
  880. {
  881. if(L[i].z==zz)
  882. {
  883. nTemp[j]=zz;
  884. j++;
  885. }
  886. }
  887. zz+=13;
  888. }
  889. }
  890. for(i=0;i<20;i++)
  891. {
  892. if(L[i].z==53)
  893. {
  894. nTemp[j]=53;
  895. j++;
  896. }
  897. }
  898. for(i=0;i<20;i++)
  899. {
  900. if(L[i].z==54)
  901. {
  902. nTemp[j]=54;
  903. j++;
  904. }
  905. }
  906. for(i=0;i<20;i++)
  907. {
  908. if(L[i].z==0)
  909. {
  910. nTemp[j]=0;
  911. j++;
  912. }
  913. }
  914. for(i=0;i<20;i++)
  915. {
  916. L[i].z=nTemp[i];
  917. }
  918. break;
  919. case 4:
  920. for(z=3;z<=13;z++)
  921. {
  922. zz=z;
  923. for(zzz=0;zzz<4;zzz++)
  924. {
  925. for(i=0;i<20;i++)
  926. {
  927. if(F[i].z==zz)
  928. {
  929. nTemp[j]=zz;
  930. j++;
  931. }
  932. }
  933. zz+=13;
  934. }
  935. }
  936. for(z=1;z<=2;z++)
  937. {
  938. zz=z;
  939. for(zzz=0;zzz<4;zzz++)
  940. {
  941. for(i=0;i<20;i++)
  942. {
  943. if(F[i].z==zz)
  944. {
  945. nTemp[j]=zz;
  946. j++;
  947. }
  948. }
  949. zz+=13;
  950. }
  951. }
  952. for(i=0;i<20;i++)
  953. {
  954. if(F[i].z==53)
  955. {
  956. nTemp[j]=53;
  957. j++;
  958. }
  959. }
  960. for(i=0;i<20;i++)
  961. {
  962. if(F[i].z==54)
  963. {
  964. nTemp[j]=54;
  965. j++;
  966. }
  967. }
  968. for(i=0;i<20;i++)
  969. {
  970. if(F[i].z==0)
  971. {
  972. nTemp[j]=0;
  973. j++;
  974. }
  975. }
  976. for(i=0;i<20;i++)
  977. {
  978. F[i].z=nTemp[i];
  979. }
  980. break;
  981. default:
  982. break;
  983. }
  984. }
  985. void CMyView::OnBanStart() 
  986. {
  987. // TODO: Add your command handler code here
  988. srand(GetTickCount());
  989. int i=0;
  990. int j=0;
  991. int DiZhuPai[3];
  992. int temp;
  993. BOOL isChongFu=FALSE;
  994. for(i=0;i<3;i++)
  995. {
  996. DiZhuPai[i]=0;
  997. }
  998. //先定义三张地主牌
  999. i=0;
  1000. while(i<3)
  1001. {
  1002. temp=rand()%54+1;
  1003. for(j=0;j<3;j++)
  1004. {
  1005. if(DiZhuPai[j]==temp)
  1006. isChongFu=TRUE;
  1007. break;
  1008. }
  1009. if(isChongFu==FALSE)
  1010. {
  1011. DiZhuPai[i]=temp;
  1012. i++;
  1013. }
  1014. isChongFu=FALSE;
  1015. }
  1016. switch(nIsDiZhu)
  1017. {
  1018. case 0:
  1019. C1[19].z=DiZhuPai[2];
  1020. C1[18].z=DiZhuPai[1];
  1021. C1[17].z=DiZhuPai[0];
  1022. break;
  1023. case 1:
  1024. C2[19].z=DiZhuPai[2];
  1025. C2[18].z=DiZhuPai[1];
  1026. C2[17].z=DiZhuPai[0];
  1027. break;
  1028. case 2:
  1029. P[19].z=DiZhuPai[2];
  1030. P[18].z=DiZhuPai[1];
  1031. P[17].z=DiZhuPai[0];
  1032. break;
  1033. default:
  1034. break;
  1035. }
  1036. //下面是定义剩下的牌
  1037. i=1;
  1038. int a=0;
  1039. int b=0;
  1040. int c=0;
  1041. while(i<=54)
  1042. {
  1043. if(i==DiZhuPai[0]||i==DiZhuPai[1]||i==DiZhuPai[2])
  1044. {
  1045. i++;
  1046. }
  1047. else
  1048. {
  1049. j=rand()%3;
  1050. switch(j)
  1051. {
  1052. case 0:
  1053. if(a<17)
  1054. {
  1055. C1[a].z=i;
  1056. a++;
  1057. i++;
  1058. }
  1059. break;
  1060. case 1:
  1061. if(b<17)
  1062. {
  1063. C2[b].z=i;
  1064. b++;
  1065. i++;
  1066. }
  1067. break;
  1068. case 2:
  1069. if(c<17)
  1070. {
  1071. P[c].z=i;
  1072. c++;
  1073. i++;
  1074. }
  1075. break;
  1076. default:
  1077. break;
  1078. }
  1079. }
  1080. }
  1081. PaiXu(0);
  1082. PaiXu(1);
  1083. PaiXu(2);
  1084. Invalidate();
  1085. }
  1086. int CMyView::FoundationCompile(int x)
  1087. {
  1088. switch(x)
  1089. {
  1090. case 54:
  1091. x=17;
  1092. break;
  1093. case 53:
  1094. x=16;
  1095. break;
  1096. case 2:
  1097. case 15:
  1098. case 28:
  1099. case 41:
  1100. x=15;
  1101. break;
  1102. case 1:
  1103. case 14:
  1104. case 27:
  1105. case 40:
  1106. x=14;
  1107. break;
  1108. case 13:
  1109. case 26:
  1110. case 39:
  1111. case 52:
  1112. x=13;
  1113. break;
  1114. default:
  1115. x=x%13;
  1116. break;
  1117. }
  1118. return x;
  1119. }
  1120. BOOL CMyView::ChuPaiRule()
  1121. {
  1122. int i=0;
  1123. int LNum=0;
  1124. int FNum=0;
  1125. for(i=0;i<20;i++)
  1126. {
  1127. if(L[i].z!=0)
  1128. {
  1129. LNum+=1;
  1130. }
  1131. }
  1132. for(i=0;i<20;i++)
  1133. {
  1134. if(F[i].z!=0)
  1135. {
  1136. FNum+=1;
  1137. }
  1138. }
  1139. switch(LNum)
  1140. {
  1141. case 0:
  1142. switch(FNum)
  1143. {
  1144. case 1:
  1145. return TRUE;
  1146. case 2:
  1147. if(F[0].z%13==F[1].z%13)
  1148. return TRUE;
  1149. if(F[0].z==53&&F[1].z==54)
  1150. return TRUE;
  1151. return FALSE;
  1152. case 3:
  1153. if(F[0].z%13==F[1].z%13&&F[1].z%13==F[2].z%13)
  1154. return TRUE;
  1155. return FALSE;
  1156. case 4:
  1157. if(F[0].z%13==F[1].z%13&&F[0].z%13==F[2].z%13&&F[0].z%13==F[3].z%13)
  1158. return TRUE;
  1159. if(MagicF(4)==6)
  1160. return TRUE;
  1161. return FALSE;
  1162. case 5:
  1163. //三带二
  1164. if(MagicF(5)==12)
  1165. return TRUE;
  1166. //五连
  1167. if(MagicF(5)==20)
  1168. if( (FoundationCompile(F[0].z)+1==FoundationCompile(F[1].z))&&
  1169. (FoundationCompile(F[0].z)+2==FoundationCompile(F[2].z))&&
  1170. (FoundationCompile(F[0].z)+3==FoundationCompile(F[3].z))&&
  1171. (FoundationCompile(F[0].z)+4==FoundationCompile(F[4].z))  )
  1172. return TRUE;
  1173. return FALSE;
  1174. case 6:
  1175. //123456
  1176. if(MagicF(6)==30)
  1177. if( (FoundationCompile(F[0].z)+1==FoundationCompile(F[1].z))&&
  1178. (FoundationCompile(F[0].z)+2==FoundationCompile(F[2].z))&&
  1179. (FoundationCompile(F[0].z)+3==FoundationCompile(F[3].z))&&
  1180. (FoundationCompile(F[0].z)+4==FoundationCompile(F[4].z))&&
  1181. (FoundationCompile(F[0].z)+5==FoundationCompile(F[5].z)) )
  1182. return TRUE;
  1183. //112233
  1184. if(MagicF(6)==24)
  1185. if( (FoundationCompile(F[0].z)+1==FoundationCompile(F[2].z))&&
  1186. (FoundationCompile(F[0].z)+2==FoundationCompile(F[4].z)) )
  1187. return TRUE;
  1188. //111222
  1189. if(MagicF(6)==18)
  1190. if( (FoundationCompile(F[0].z)+1==FoundationCompile(F[3].z)) )
  1191. return TRUE;
  1192. return TRUE;
  1193. case 7:
  1194. //1234567
  1195. if(MagicF(7)==42)
  1196. if( (FoundationCompile(F[0].z)+1==FoundationCompile(F[1].z))&&
  1197. (FoundationCompile(F[0].z)+2==FoundationCompile(F[2].z))&&
  1198. (FoundationCompile(F[0].z)+3==FoundationCompile(F[3].z))&&
  1199. (FoundationCompile(F[0].z)+4==FoundationCompile(F[4].z))&&
  1200. (FoundationCompile(F[0].z)+5==FoundationCompile(F[5].z))&&
  1201. (FoundationCompile(F[0].z)+6==FoundationCompile(F[6].z)) )
  1202. return TRUE;
  1203. case 8:
  1204. //12345678
  1205. if(MagicF(8)==56)
  1206. if( (FoundationCompile(F[0].z)+1==FoundationCompile(F[1].z))&&
  1207. (FoundationCompile(F[0].z)+2==FoundationCompile(F[2].z))&&
  1208. (FoundationCompile(F[0].z)+3==FoundationCompile(F[3].z))&&
  1209. (FoundationCompile(F[0].z)+4==FoundationCompile(F[4].z))&&
  1210. (FoundationCompile(F[0].z)+5==FoundationCompile(F[5].z))&&
  1211. (FoundationCompile(F[0].z)+6==FoundationCompile(F[6].z))&&
  1212. (FoundationCompile(F[0].z)+7==FoundationCompile(F[7].z)) )
  1213. return TRUE;
  1214. //11223344
  1215. if(MagicF(8)==48)
  1216. return TRUE;
  1217. case 9:
  1218. //12345678
  1219. if(MagicF(9)==72)
  1220. if( (FoundationCompile(F[0].z)+1==FoundationCompile(F[1].z))&&
  1221. (FoundationCompile(F[0].z)+2==FoundationCompile(F[2].z))&&
  1222. (FoundationCompile(F[0].z)+3==FoundationCompile(F[3].z))&&
  1223. (FoundationCompile(F[0].z)+4==FoundationCompile(F[4].z))&&
  1224. (FoundationCompile(F[0].z)+5==FoundationCompile(F[5].z))&&
  1225. (FoundationCompile(F[0].z)+6==FoundationCompile(F[6].z))&&
  1226. (FoundationCompile(F[0].z)+7==FoundationCompile(F[7].z))&&
  1227. (FoundationCompile(F[0].z)+8==FoundationCompile(F[8].z)) )
  1228. return TRUE;
  1229. //111222333
  1230. if(MagicF(9)==54)
  1231. if( (FoundationCompile(F[0].z)+1==FoundationCompile(F[3].z))&&
  1232. (FoundationCompile(F[0].z)+2==FoundationCompile(F[6].z)) )
  1233. return TRUE;
  1234. case 10:
  1235. //1234567890
  1236. if(MagicF(10)==90)
  1237. if( (FoundationCompile(F[0].z)+1==FoundationCompile(F[1].z))&&
  1238. (FoundationCompile(F[0].z)+2==FoundationCompile(F[2].z))&&
  1239. (FoundationCompile(F[0].z)+3==FoundationCompile(F[3].z))&&
  1240. (FoundationCompile(F[0].z)+4==FoundationCompile(F[4].z))&&
  1241. (FoundationCompile(F[0].z)+5==FoundationCompile(F[5].z))&&
  1242. (FoundationCompile(F[0].z)+6==FoundationCompile(F[6].z))&&
  1243. (FoundationCompile(F[0].z)+7==FoundationCompile(F[7].z))&&
  1244. (FoundationCompile(F[0].z)+8==FoundationCompile(F[8].z))&&
  1245. (FoundationCompile(F[0].z)+9==FoundationCompile(F[9].z)) )
  1246. return TRUE;
  1247. //飞机
  1248. if(MagicF(10)==74)
  1249. {
  1250. int F_3_1=-1;
  1251. int F_3_2=-1;
  1252. int F_2_1=-1;
  1253. int F_2_2=-1;
  1254. int j=0;
  1255. int jiShu=0;
  1256. for(i=0;i<10;i++)
  1257. {
  1258. for(j=0;j<10;j++)
  1259. {
  1260. if(F[i].z%13!=F[j].z%13)
  1261. {
  1262. jiShu++;
  1263. }
  1264. }
  1265. if(jiShu==7)
  1266. {
  1267. if(F_3_1==-1)
  1268. F_3_1=F[i].z;
  1269. else
  1270. F_3_2=F[i].z;
  1271. else
  1272. jiShu=0;
  1273. }
  1274. jiShu=0;
  1275. for(i=0;i<10;i++)
  1276. {
  1277. for(j=0;j<10;j++)
  1278. {
  1279. if(F[i].z%13!=F[j].z%13)
  1280. {
  1281. jiShu++;
  1282. }
  1283. }
  1284. if(jiShu==8)
  1285. {
  1286. if(F_2_1==-1)
  1287. F_2_1=F[i].z;
  1288. else
  1289. F_2_2=F[i].z;
  1290. else
  1291. jiShu=0;
  1292. }
  1293. if((FoundationCompile(F_3_1)+1==FoundationCompile(F_3_2))&&
  1294. (FoundationCompile(F_2_1)+1==FoundationCompile(F_2_2)))
  1295. return TRUE;
  1296. }
  1297. //1122334455
  1298. if(MagicF(10)==80)
  1299. if( (FoundationCompile(F[0].z)+1==FoundationCompile(F[2].z))&&
  1300. (FoundationCompile(F[0].z)+2==FoundationCompile(F[4].z))&&
  1301. (FoundationCompile(F[0].z)+3==FoundationCompile(F[6].z))&&
  1302. (FoundationCompile(F[0].z)+4==FoundationCompile(F[8].z)) )
  1303. return TRUE;
  1304. return FALSE;
  1305. case 11:
  1306. //12345678901
  1307. if(MagicF(11)==110)
  1308. if( (FoundationCompile(F[0].z)+1==FoundationCompile(F[1].z))&&
  1309. (FoundationCompile(F[0].z)+2==FoundationCompile(F[2].z))&&
  1310. (FoundationCompile(F[0].z)+3==FoundationCompile(F[3].z))&&
  1311. (FoundationCompile(F[0].z)+4==FoundationCompile(F[4].z))&&
  1312. (FoundationCompile(F[0].z)+5==FoundationCompile(F[5].z))&&
  1313. (FoundationCompile(F[0].z)+6==FoundationCompile(F[6].z))&&
  1314. (FoundationCompile(F[0].z)+7==FoundationCompile(F[7].z))&&
  1315. (FoundationCompile(F[0].z)+8==FoundationCompile(F[8].z))&&
  1316. (FoundationCompile(F[0].z)+9==FoundationCompile(F[9].z))&&
  1317. (FoundationCompile(F[0].z)+10==FoundationCompile(F[10].z)) )
  1318. return TRUE;
  1319. case 12:
  1320. //123456789012
  1321. if(MagicF(12)==132)
  1322. if( (FoundationCompile(F[0].z)+1==FoundationCompile(F[1].z))&&
  1323. (FoundationCompile(F[0].z)+2==FoundationCompile(F[2].z))&&
  1324. (FoundationCompile(F[0].z)+3==FoundationCompile(F[3].z))&&
  1325. (FoundationCompile(F[0].z)+4==FoundationCompile(F[4].z))&&
  1326. (FoundationCompile(F[0].z)+5==FoundationCompile(F[5].z))&&
  1327. (FoundationCompile(F[0].z)+6==FoundationCompile(F[6].z))&&
  1328. (FoundationCompile(F[0].z)+7==FoundationCompile(F[7].z))&&
  1329. (FoundationCompile(F[0].z)+8==FoundationCompile(F[8].z))&&
  1330. (FoundationCompile(F[0].z)+9==FoundationCompile(F[9].z))&&
  1331. (FoundationCompile(F[0].z)+10==FoundationCompile(F[10].z))&&
  1332. (FoundationCompile(F[0].z)+11==FoundationCompile(F[11].z)) )
  1333. return TRUE;
  1334. default:
  1335. return FALSE;
  1336. }
  1337. case 1:
  1338. //以一打一
  1339. if(FNum==1)
  1340. if(FoundationCompile(F[0].z)>FoundationCompile(L[0].z))
  1341. return TRUE;
  1342. //以枪打一
  1343. if(FNum==4)
  1344. if(NoJokerF(4))
  1345. if(F[0].z%13==F[1].z%13&&F[0].z%13==F[2].z%13&&F[0].z%13==F[3].z%13)
  1346. return TRUE;
  1347. //以王打一
  1348. if(FNum==2)
  1349. if(F[0].z==53&&F[1].z==54)
  1350. return TRUE;
  1351. return FALSE;
  1352. case 2:
  1353. //以二打二
  1354. if(FNum==2)
  1355. if(F[0].z%13==F[1].z%13)
  1356. if(FoundationCompile(F[0].z)>FoundationCompile(L[0].z))
  1357. return TRUE;
  1358. //以王打二
  1359. if(FNum==2)
  1360. if(F[0].z==53&&F[1].z==54)
  1361. return TRUE;
  1362. //以枪打王
  1363. if(FNum==4)
  1364. if(NoJokerF(4))
  1365. if(F[0].z%13==F[1].z%13&&F[0].z%13==F[2].z%13&&F[0].z%13==F[3].z%13)
  1366. if(L[0].z!=53&&L[1].z!=54)
  1367. return FALSE;
  1368. return FALSE;
  1369. case 3:
  1370. //王打一切
  1371. if(FNum==2)
  1372. if(F[0].z==53&&F[1].z==54)
  1373. return TRUE;
  1374. //以三打三
  1375. if(FNum==3)
  1376. if(F[0].z%13==F[1].z%13&&F[0].z%13==F[2].z%13)
  1377. if(FoundationCompile(F[0].z)>FoundationCompile(L[0].z))
  1378. return TRUE;
  1379. //以枪打三
  1380. if(FNum==4)
  1381. if(NoJokerF(4))
  1382. if(F[0].z%13==F[1].z%13&&F[0].z%13==F[2].z%13&&F[0].z%13==F[3].z%13)
  1383. return TRUE;
  1384. //以王打三
  1385. if(FNum==2)
  1386. if(F[0].z==53&&F[1].z==54)
  1387. return TRUE;
  1388. return FALSE;
  1389. case 4:
  1390. //以枪打枪
  1391. if(FNum==4)
  1392. if(L[0].z%13==L[1].z%13&&L[0].z%13==L[2].z%13&&L[0].z%13==L[3].z%13)
  1393. if(NoJokerF(4))
  1394. if(F[0].z%13==F[1].z%13&&F[0].z%13==F[2].z%13&&F[0].z%13==F[3].z%13)
  1395. if(FoundationCompile(F[0].z)>FoundationCompile(L[0].z))
  1396. return TRUE;
  1397. //王打一切
  1398. if(FNum==2)
  1399. if(F[0].z==53&&F[1].z==54)
  1400. return TRUE;
  1401. //枪打三带一
  1402. if(FNum==4)
  1403. if(MagicL(4)==6)
  1404. if(F[0].z%13==F[1].z%13&&F[0].z%13==F[2].z%13&&F[0].z%13==F[3].z%13)
  1405. return TRUE;
  1406. //三带一打三带一
  1407. if(FNum==4)
  1408. if(MagicL(4)==6)
  1409. if(MagicF(4)==6)
  1410. if(FoundationCompile(YuanShuF(4))>FoundationCompile(YuanShuL(4)))
  1411. return TRUE;
  1412. return FALSE;
  1413. case 5:
  1414. //王打一切
  1415. if(FNum==2)
  1416. if(F[0].z==53&&F[1].z==54)
  1417. return TRUE;
  1418. //三带二打三带二
  1419. if(FNum==5)
  1420. if(MagicL(5)==12)
  1421. if(MagicF(5)==12)
  1422. if(FoundationCompile(YuanShuF(5))>FoundationCompile(YuanShuL(5)))
  1423. return TRUE;
  1424. //顺打顺
  1425. if(FNum==5)
  1426. if(MagicL(5)==20)
  1427. if( (FoundationCompile(L[0].z)+1==FoundationCompile(L[1].z))&&
  1428. (FoundationCompile(L[0].z)+2==FoundationCompile(L[2].z))&&
  1429. (FoundationCompile(L[0].z)+3==FoundationCompile(L[3].z))&&
  1430. (FoundationCompile(L[0].z)+4==FoundationCompile(L[4].z))  )
  1431. if(MagicF(5)==20)
  1432. if( (FoundationCompile(F[0].z)+1==FoundationCompile(F[1].z))&&
  1433. (FoundationCompile(F[0].z)+2==FoundationCompile(F[2].z))&&
  1434. (FoundationCompile(F[0].z)+3==FoundationCompile(F[3].z))&&
  1435. (FoundationCompile(F[0].z)+4==FoundationCompile(F[4].z))  )
  1436. if(FoundationCompile(F[0].z)>FoundationCompile(L[0].z))
  1437. return TRUE;
  1438. //枪打一切五
  1439. if(FNum==4)
  1440. if(NoJokerF(4))
  1441. if(F[0].z%13==F[1].z%13&&F[0].z%13==F[2].z%13&&F[0].z%13==F[3].z%13)
  1442. return TRUE;
  1443. return FALSE;
  1444. case 6:
  1445. //王打一切
  1446. if(FNum==2)
  1447. if(F[0].z==53&&F[1].z==54)
  1448. return TRUE;
  1449. //枪打六
  1450. if(FNum==4)
  1451. if(NoJokerF(4))
  1452. if(F[0].z%13==F[1].z%13&&F[0].z%13==F[2].z%13&&F[0].z%13==F[3].z%13)
  1453. return TRUE;
  1454. //六连打六连
  1455. if(FNum==6)
  1456. if(MagicL(6)==30)
  1457. if( (FoundationCompile(L[0].z)+1==FoundationCompile(L[1].z))&&
  1458. (FoundationCompile(L[0].z)+2==FoundationCompile(L[2].z))&&
  1459. (FoundationCompile(L[0].z)+3==FoundationCompile(L[3].z))&&
  1460. (FoundationCompile(L[0].z)+4==FoundationCompile(L[4].z))&&
  1461. (FoundationCompile(L[0].z)+5==FoundationCompile(L[5].z)) )
  1462. if(MagicF(6)==30)
  1463. if( (FoundationCompile(F[0].z)+1==FoundationCompile(F[1].z))&&
  1464. (FoundationCompile(F[0].z)+2==FoundationCompile(F[2].z))&&
  1465. (FoundationCompile(F[0].z)+3==FoundationCompile(F[3].z))&&
  1466. (FoundationCompile(F[0].z)+4==FoundationCompile(F[4].z))&&
  1467. (FoundationCompile(F[0].z)+5==FoundationCompile(F[5].z)) )
  1468. if(FoundationCompile(F[0].z)>FoundationCompile(L[0].z))
  1469. return TRUE;
  1470. //112233 vs 112233
  1471. if(FNum==6)
  1472. if(MagicF(6)==24)
  1473. if( (FoundationCompile(F[0].z)+1==FoundationCompile(F[2].z))&&
  1474. (FoundationCompile(F[0].z)+2==FoundationCompile(F[4].z)) )
  1475. if(MagicL(6)==24)
  1476. if( (FoundationCompile(L[0].z)+1==FoundationCompile(L[2].z))&&
  1477. (FoundationCompile(L[0].z)+2==FoundationCompile(L[4].z)) )
  1478. if(FoundationCompile(F[0].z)>FoundationCompile(L[0].z))
  1479. return TRUE;
  1480. //111222 VS 111222
  1481. if(FNum==6)
  1482. if(MagicL(6)==18)
  1483. if( (FoundationCompile(L[0].z)+1==FoundationCompile(L[3].z)) )
  1484. if(MagicF(6)==18)
  1485. if( (FoundationCompile(F[0].z)+1==FoundationCompile(F[3].z)) )
  1486. if(FoundationCompile(F[0].z)>FoundationCompile(L[0].z))
  1487. return TRUE;
  1488. case 7:
  1489. //1234567 vs 1234567
  1490. if(FNum==7)
  1491. if(MagicL(7)==42)
  1492. if( (FoundationCompile(L[0].z)+1==FoundationCompile(L[1].z))&&
  1493. (FoundationCompile(L[0].z)+2==FoundationCompile(L[2].z))&&
  1494. (FoundationCompile(L[0].z)+3==FoundationCompile(L[3].z))&&
  1495. (FoundationCompile(L[0].z)+4==FoundationCompile(L[4].z))&&
  1496. (FoundationCompile(L[0].z)+5==FoundationCompile(L[5].z))&&
  1497. (FoundationCompile(L[0].z)+6==FoundationCompile(L[6].z)) )
  1498. if(MagicF(7)==42)
  1499. if( (FoundationCompile(F[0].z)+1==FoundationCompile(F[1].z))&&
  1500. (FoundationCompile(F[0].z)+2==FoundationCompile(F[2].z))&&
  1501. (FoundationCompile(F[0].z)+3==FoundationCompile(F[3].z))&&
  1502. (FoundationCompile(F[0].z)+4==FoundationCompile(F[4].z))&&
  1503. (FoundationCompile(F[0].z)+5==FoundationCompile(F[5].z))&&
  1504. (FoundationCompile(F[0].z)+6==FoundationCompile(F[6].z)) )
  1505. if(FoundationCompile(F[0].z)>FoundationCompile(L[0].z))
  1506. return TRUE;
  1507. //王打一切
  1508. if(FNum==2)
  1509. if(F[0].z==53&&F[1].z==54)
  1510. return TRUE;
  1511. //枪打所有7
  1512. if(NoJokerF(4))
  1513. if(F[0].z%13==F[1].z%13&&F[0].z%13==F[2].z%13&&F[0].z%13==F[3].z%13)
  1514. return TRUE;
  1515. return FALSE;
  1516. case 8:
  1517. //王打一切
  1518. if(FNum==2)
  1519. if(F[0].z==53&&F[1].z==54)
  1520. return TRUE;
  1521. //枪打所有8
  1522. if(NoJokerF(4))
  1523. if(F[0].z%13==F[1].z%13&&F[0].z%13==F[2].z%13&&F[0].z%13==F[3].z%13)
  1524. return TRUE;
  1525. //12345678 vs 12345678
  1526. if(FNum==8)
  1527. if(MagicL(8)==56)
  1528. if( (FoundationCompile(L[0].z)+1==FoundationCompile(L[1].z))&&
  1529. (FoundationCompile(L[0].z)+2==FoundationCompile(L[2].z))&&
  1530. (FoundationCompile(L[0].z)+3==FoundationCompile(L[3].z))&&
  1531. (FoundationCompile(L[0].z)+4==FoundationCompile(L[4].z))&&
  1532. (FoundationCompile(L[0].z)+5==FoundationCompile(L[5].z))&&
  1533. (FoundationCompile(L[0].z)+6==FoundationCompile(L[6].z))&&
  1534. (FoundationCompile(L[0].z)+7==FoundationCompile(L[7].z)) )
  1535. if(MagicF(8)==56)
  1536. if( (FoundationCompile(F[0].z)+1==FoundationCompile(F[1].z))&&
  1537. (FoundationCompile(F[0].z)+2==FoundationCompile(F[2].z))&&
  1538. (FoundationCompile(F[0].z)+3==FoundationCompile(F[3].z))&&
  1539. (FoundationCompile(F[0].z)+4==FoundationCompile(F[4].z))&&
  1540. (FoundationCompile(F[0].z)+5==FoundationCompile(F[5].z))&&
  1541. (FoundationCompile(F[0].z)+6==FoundationCompile(F[6].z))&&
  1542. (FoundationCompile(F[0].z)+7==FoundationCompile(F[7].z)) )
  1543. if(FoundationCompile(F[0].z)>FoundationCompile(L[0].z))
  1544. return TRUE;
  1545. //11223344 vs 11223344
  1546. if(FNum==8)
  1547. if(MagicL(8)==48)
  1548. if(MagicF(8)==48)
  1549. if(FoundationCompile(F[0].z)>FoundationCompile(L[0].z))
  1550. return TRUE;
  1551. case 9:
  1552. //王打一切
  1553. if(FNum==2)
  1554. if(F[0].z==53&&F[1].z==54)
  1555. return TRUE;
  1556. //枪打所有9
  1557. if(NoJokerF(4))
  1558. if(F[0].z%13==F[1].z%13&&F[0].z%13==F[2].z%13&&F[0].z%13==F[3].z%13)
  1559. return TRUE;
  1560. //111222333 vs 111222333
  1561. if(MagicF(9)==54)
  1562. if( (FoundationCompile(F[0].z)+1==FoundationCompile(F[3].z))&&
  1563. (FoundationCompile(F[0].z)+2==FoundationCompile(F[6].z)) )
  1564. return TRUE;
  1565. //123456789 vs 123456789
  1566. if(FNum==9)
  1567. if(MagicL(9)==72)
  1568. if( (FoundationCompile(L[0].z)+1==FoundationCompile(L[1].z))&&
  1569. (FoundationCompile(L[0].z)+2==FoundationCompile(L[2].z))&&
  1570. (FoundationCompile(L[0].z)+3==FoundationCompile(L[3].z))&&
  1571. (FoundationCompile(L[0].z)+4==FoundationCompile(L[4].z))&&
  1572. (FoundationCompile(L[0].z)+5==FoundationCompile(L[5].z))&&
  1573. (FoundationCompile(L[0].z)+6==FoundationCompile(L[6].z))&&
  1574. (FoundationCompile(L[0].z)+7==FoundationCompile(L[7].z))&&
  1575. (FoundationCompile(L[0].z)+8==FoundationCompile(L[8].z)) )
  1576. if(MagicF(9)==72)
  1577. if( (FoundationCompile(F[0].z)+1==FoundationCompile(F[1].z))&&
  1578. (FoundationCompile(F[0].z)+2==FoundationCompile(F[2].z))&&
  1579. (FoundationCompile(F[0].z)+3==FoundationCompile(F[3].z))&&
  1580. (FoundationCompile(F[0].z)+4==FoundationCompile(F[4].z))&&
  1581. (FoundationCompile(F[0].z)+5==FoundationCompile(F[5].z))&&
  1582. (FoundationCompile(F[0].z)+6==FoundationCompile(F[6].z))&&
  1583. (FoundationCompile(F[0].z)+7==FoundationCompile(F[7].z))&&
  1584. (FoundationCompile(F[0].z)+8==FoundationCompile(F[8].z)) )
  1585. if(FoundationCompile(F[0].z)>FoundationCompile(L[0].z))
  1586. return TRUE;
  1587. case 10:
  1588. //王打一切
  1589. if(FNum==2)
  1590. if(F[0].z==53&&F[1].z==54)
  1591. return TRUE;
  1592. //枪打所有10
  1593. if(NoJokerF(4))
  1594. if(F[0].z%13==F[1].z%13&&F[0].z%13==F[2].z%13&&F[0].z%13==F[3].z%13)
  1595. return TRUE;
  1596. //1234567890 vs 1234567890
  1597. if(FNum==10)
  1598. if(MagicL(10)==90)
  1599. if( (FoundationCompile(L[0].z)+1==FoundationCompile(L[1].z))&&
  1600. (FoundationCompile(L[0].z)+2==FoundationCompile(L[2].z))&&
  1601. (FoundationCompile(L[0].z)+3==FoundationCompile(L[3].z))&&
  1602. (FoundationCompile(L[0].z)+4==FoundationCompile(L[4].z))&&
  1603. (FoundationCompile(L[0].z)+5==FoundationCompile(L[5].z))&&
  1604. (FoundationCompile(L[0].z)+6==FoundationCompile(L[6].z))&&
  1605. (FoundationCompile(L[0].z)+7==FoundationCompile(L[7].z))&&
  1606. (FoundationCompile(L[0].z)+8==FoundationCompile(L[8].z))&&
  1607. (FoundationCompile(L[0].z)+9==FoundationCompile(L[9].z)) )
  1608. if(MagicF(10)==90)
  1609. if( (FoundationCompile(F[0].z)+1==FoundationCompile(F[1].z))&&
  1610. (FoundationCompile(F[0].z)+2==FoundationCompile(F[2].z))&&
  1611. (FoundationCompile(F[0].z)+3==FoundationCompile(F[3].z))&&
  1612. (FoundationCompile(F[0].z)+4==FoundationCompile(F[4].z))&&
  1613. (FoundationCompile(F[0].z)+5==FoundationCompile(F[5].z))&&
  1614. (FoundationCompile(F[0].z)+6==FoundationCompile(F[6].z))&&
  1615. (FoundationCompile(F[0].z)+7==FoundationCompile(F[7].z))&&
  1616. (FoundationCompile(F[0].z)+8==FoundationCompile(F[8].z))&&
  1617. (FoundationCompile(F[0].z)+9==FoundationCompile(F[9].z)) )
  1618. if(FoundationCompile(F[0].z)>FoundationCompile(L[0].z))
  1619. return TRUE;
  1620. //飞机打飞机
  1621. if(FNum==10)
  1622. if(MagicF(10)==74)
  1623. {
  1624. int F_3_1=-1;
  1625. int F_3_2=-1;
  1626. int F_2_1=-1;
  1627. int F_2_2=-1;
  1628. int j=0;
  1629. int jiShu=0;
  1630. for(i=0;i<10;i++)
  1631. {
  1632. for(j=0;j<10;j++)
  1633. {
  1634. if(F[i].z%13!=F[j].z%13)
  1635. {
  1636. jiShu++;
  1637. }
  1638. }
  1639. if(jiShu==7)
  1640. {
  1641. if(F_3_1==-1)
  1642. F_3_1=F[i].z;
  1643. else
  1644. F_3_2=F[i].z;
  1645. else
  1646. jiShu=0;
  1647. }
  1648. jiShu=0;
  1649. for(i=0;i<10;i++)
  1650. {
  1651. for(j=0;j<10;j++)
  1652. {
  1653. if(F[i].z%13!=F[j].z%13)
  1654. {
  1655. jiShu++;
  1656. }
  1657. }
  1658. if(jiShu==8)
  1659. {
  1660. if(F_2_1==-1)
  1661. F_2_1=F[i].z;
  1662. else
  1663. F_2_2=F[i].z;
  1664. else
  1665. jiShu=0;
  1666. }
  1667. if((FoundationCompile(F_3_1)+1==FoundationCompile(F_3_2))&&
  1668. (FoundationCompile(F_2_1)+1==FoundationCompile(F_2_2)))
  1669. {
  1670. if(MagicL(10)==74)
  1671. {
  1672. int L_3_1=-1;
  1673. int L_3_2=-1;
  1674. int L_2_1=-1;
  1675. int L_2_2=-1;
  1676. j=0;
  1677. jiShu=0;
  1678. for(i=0;i<10;i++)
  1679. {
  1680. for(j=0;j<10;j++)
  1681. {
  1682. if(L[i].z%13!=L[j].z%13)
  1683. {
  1684. jiShu++;
  1685. }
  1686. }
  1687. if(jiShu==7)
  1688. {
  1689. if(L_3_1==-1)
  1690. L_3_1=L[i].z;
  1691. else
  1692. L_3_2=L[i].z;
  1693. else
  1694. jiShu=0;
  1695. }
  1696. jiShu=0;
  1697. for(i=0;i<10;i++)
  1698. {
  1699. for(j=0;j<10;j++)
  1700. {
  1701. if(L[i].z%13!=L[j].z%13)
  1702. {
  1703. jiShu++;
  1704. }
  1705. }
  1706. if(jiShu==8)
  1707. {
  1708. if(L_2_1==-1)
  1709. L_2_1=L[i].z;
  1710. else
  1711. L_2_2=L[i].z;
  1712. else
  1713. jiShu=0;
  1714. }
  1715. if((FoundationCompile(L_3_1)+1==FoundationCompile(L_3_2))&&
  1716. (FoundationCompile(L_2_1)+1==FoundationCompile(L_2_2)))
  1717. {
  1718. if(FoundationCompile(F_3_1)>FoundationCompile(L_3_1))
  1719. return TRUE;
  1720. }}}}
  1721. //1122334455 VS 1122334455
  1722. if(FNum==10)
  1723. if(MagicF(10)==80)
  1724. if( (FoundationCompile(F[0].z)+1==FoundationCompile(F[2].z))&&
  1725. (FoundationCompile(F[0].z)+2==FoundationCompile(F[4].z))&&
  1726. (FoundationCompile(F[0].z)+3==FoundationCompile(F[6].z))&&
  1727. (FoundationCompile(F[0].z)+4==FoundationCompile(F[8].z)) )
  1728. if(MagicL(10)==80)
  1729. if( (FoundationCompile(L[0].z)+1==FoundationCompile(L[2].z))&&
  1730. (FoundationCompile(L[0].z)+2==FoundationCompile(L[4].z))&&
  1731. (FoundationCompile(L[0].z)+3==FoundationCompile(L[6].z))&&
  1732. (FoundationCompile(L[0].z)+4==FoundationCompile(L[8].z)) )
  1733. if(FoundationCompile(F[0].z)>FoundationCompile(L[0].z))
  1734. return TRUE;
  1735. return FALSE;
  1736. case 11:
  1737. //王打一切
  1738. if(FNum==2)
  1739. if(F[0].z==53&&F[1].z==54)
  1740. return TRUE;
  1741. //枪打所有11
  1742. if(NoJokerF(4))
  1743. if(F[0].z%13==F[1].z%13&&F[0].z%13==F[2].z%13&&F[0].z%13==F[3].z%13)
  1744. return TRUE;
  1745. //12345678901 vs 12345678901
  1746. if(FNum==11)
  1747. if(MagicF(11)==110)
  1748. if( (FoundationCompile(F[0].z)+1==FoundationCompile(F[1].z))&&
  1749. (FoundationCompile(F[0].z)+2==FoundationCompile(F[2].z))&&
  1750. (FoundationCompile(F[0].z)+3==FoundationCompile(F[3].z))&&
  1751. (FoundationCompile(F[0].z)+4==FoundationCompile(F[4].z))&&
  1752. (FoundationCompile(F[0].z)+5==FoundationCompile(F[5].z))&&
  1753. (FoundationCompile(F[0].z)+6==FoundationCompile(F[6].z))&&
  1754. (FoundationCompile(F[0].z)+7==FoundationCompile(F[7].z))&&
  1755. (FoundationCompile(F[0].z)+8==FoundationCompile(F[8].z))&&
  1756. (FoundationCompile(F[0].z)+9==FoundationCompile(F[9].z))&&
  1757. (FoundationCompile(F[0].z)+10==FoundationCompile(F[10].z)) )
  1758. if(MagicL(11)==110)
  1759. if( (FoundationCompile(L[0].z)+1==FoundationCompile(L[1].z))&&
  1760. (FoundationCompile(L[0].z)+2==FoundationCompile(L[2].z))&&
  1761. (FoundationCompile(L[0].z)+3==FoundationCompile(L[3].z))&&
  1762. (FoundationCompile(L[0].z)+4==FoundationCompile(L[4].z))&&
  1763. (FoundationCompile(L[0].z)+5==FoundationCompile(L[5].z))&&
  1764. (FoundationCompile(L[0].z)+6==FoundationCompile(L[6].z))&&
  1765. (FoundationCompile(L[0].z)+7==FoundationCompile(L[7].z))&&
  1766. (FoundationCompile(L[0].z)+8==FoundationCompile(L[8].z))&&
  1767. (FoundationCompile(L[0].z)+9==FoundationCompile(L[9].z))&&
  1768. (FoundationCompile(L[0].z)+10==FoundationCompile(L[10].z)) )
  1769. if(FoundationCompile(F[0].z)>FoundationCompile(L[0].z))
  1770. return TRUE;
  1771. case 12:
  1772. //王打一切
  1773. if(FNum==2)
  1774. if(F[0].z==53&&F[1].z==54)
  1775. return TRUE;
  1776. //枪打所有12
  1777. if(NoJokerF(4))
  1778. if(F[0].z%13==F[1].z%13&&F[0].z%13==F[2].z%13&&F[0].z%13==F[3].z%13)
  1779. return TRUE;
  1780. default:
  1781. return FALSE;
  1782. }
  1783. }
  1784. void CMyView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
  1785. {
  1786. // TODO: Add your message handler code here and/or call default
  1787. int i=0;
  1788. int j=0;
  1789. int yShua=0;
  1790. switch(nChar)
  1791. {
  1792. case VK_SPACE:
  1793. BuYao();
  1794. break;
  1795. }
  1796. CView::OnKeyDown(nChar, nRepCnt, nFlags);
  1797. }
  1798. int CMyView::MagicF(int num)
  1799. {
  1800. int i=0;
  1801. int j=0;
  1802. int jiShu=0;
  1803. switch(num)
  1804. {
  1805. case 4:
  1806. //判断三带一 6
  1807. for(i=0;i<4;i++)
  1808. {
  1809. if(F[i].z==53||F[i].z==54)
  1810. return 1000;
  1811. for(j=0;j<4;j++)
  1812. {
  1813. if(F[i].z%13!=F[j].z%13)
  1814. jiShu++;
  1815. }
  1816. }
  1817. return jiShu;
  1818. case 5:
  1819. //判断三代二 12
  1820. for(i=0;i<5;i++)
  1821. {
  1822. if(F[i].z==53||F[i].z==54)
  1823. return 1000;
  1824. for(j=0;j<5;j++)
  1825. {
  1826. if(F[i].z%13!=F[j].z%13)
  1827. jiShu++;
  1828. }
  1829. }
  1830. return jiShu;
  1831. case 6:
  1832. //123456 30
  1833. //112233 24
  1834. //111222 18
  1835. for(i=0;i<6;i++)
  1836. {
  1837. if(F[i].z==53||F[i].z==54)
  1838. return 1000;
  1839. for(j=0;j<6;j++)
  1840. {
  1841. if(F[i].z%13!=F[j].z%13)
  1842. jiShu++;
  1843. }
  1844. }
  1845. return jiShu;
  1846. case 7:
  1847. for(i=0;i<7;i++)
  1848. {
  1849. if(F[i].z==53||F[i].z==54)
  1850. return 1000;
  1851. for(j=0;j<7;j++)
  1852. {
  1853. if(F[i].z%13!=F[j].z%13)
  1854. jiShu++;
  1855. }
  1856. }
  1857. return jiShu;
  1858. case 8:
  1859. for(i=0;i<8;i++)
  1860. {
  1861. if(F[i].z==53||F[i].z==54)
  1862. return 1000;
  1863. for(j=0;j<8;j++)
  1864. {
  1865. if(F[i].z%13!=F[j].z%13)
  1866. jiShu++;
  1867. }
  1868. }
  1869. return jiShu;
  1870. case 9:
  1871. for(i=0;i<9;i++)
  1872. {
  1873. if(F[i].z==53||F[i].z==54)
  1874. return 1000;
  1875. for(j=0;j<9;j++)
  1876. {
  1877. if(F[i].z%13!=F[j].z%13)
  1878. jiShu++;
  1879. }
  1880. }
  1881. return jiShu;
  1882. case 10:
  1883. for(i=0;i<10;i++)
  1884. {
  1885. if(F[i].z==53||F[i].z==54)
  1886. return 1000;
  1887. for(j=0;j<10;j++)
  1888. {
  1889. if(F[i].z%13!=F[j].z%13)
  1890. jiShu++;
  1891. }
  1892. }
  1893. return jiShu;
  1894. case 11:
  1895. for(i=0;i<11;i++)
  1896. {
  1897. if(F[i].z==53||F[i].z==54)
  1898. return 1000;
  1899. for(j=0;j<11;j++)
  1900. {
  1901. if(F[i].z%13!=F[j].z%13)
  1902. jiShu++;
  1903. }
  1904. }
  1905. return jiShu;
  1906. case 12:
  1907. for(i=0;i<12;i++)
  1908. {
  1909. if(F[i].z==53||F[i].z==54)
  1910. return 1000;
  1911. for(j=0;j<12;j++)
  1912. {
  1913. if(F[i].z%13!=F[j].z%13)
  1914. jiShu++;
  1915. }
  1916. }
  1917. return jiShu;
  1918. default:
  1919. break;
  1920. }
  1921. }
  1922. int CMyView::YuanShuF(int num)
  1923. {
  1924. int i=0;
  1925. int j=0;
  1926. int jiShu=0;
  1927. switch(num)
  1928. {
  1929. case 4:
  1930. //完成三带一
  1931. for(i=0;i<4;i++)
  1932. {
  1933. for(j=0;j<4;j++)
  1934. {
  1935. if(F[i].z%13!=F[j].z%13)
  1936. {
  1937. jiShu++;
  1938. }
  1939. }
  1940. if(jiShu==1)
  1941. return F[i].z;
  1942. else
  1943. jiShu=0;
  1944. }
  1945. MessageBox("这里出错了YuanShuF(4)");
  1946. break;
  1947. case 5:
  1948. for(i=0;i<5;i++)
  1949. {
  1950. for(j=0;j<5;j++)
  1951. {
  1952. if(F[i].z%13!=F[j].z%13)
  1953. {
  1954. jiShu++;
  1955. }
  1956. }
  1957. if(jiShu==2)
  1958. return F[i].z;
  1959. else
  1960. jiShu=0;
  1961. }
  1962. MessageBox("这里出错了YuanShuF(5)");
  1963. break;
  1964. default:
  1965. break;
  1966. }
  1967. }
  1968. int CMyView::MagicL(int num)
  1969. {
  1970. int i=0;
  1971. int j=0;
  1972. int jiShu=0;
  1973. switch(num)
  1974. {
  1975. case 4:
  1976. for(i=0;i<4;i++)
  1977. {
  1978. if(L[i].z==53||L[i].z==54)
  1979. return 1000;
  1980. for(j=0;j<4;j++)
  1981. {
  1982. if(L[i].z%13!=L[j].z%13)
  1983. jiShu++;
  1984. }
  1985. }
  1986. return jiShu;
  1987. case 5:
  1988. for(i=0;i<5;i++)
  1989. {
  1990. if(L[i].z==53||L[i].z==54)
  1991. return 1000;
  1992. for(j=0;j<5;j++)
  1993. {
  1994. if(L[i].z%13!=L[j].z%13)
  1995. jiShu++;
  1996. }
  1997. }
  1998. return jiShu;
  1999. case 6:
  2000. for(i=0;i<6;i++)
  2001. {
  2002. if(L[i].z==53||L[i].z==54)
  2003. return 1000;
  2004. for(j=0;j<6;j++)
  2005. {
  2006. if(L[i].z%13!=L[j].z%13)
  2007. jiShu++;
  2008. }
  2009. }
  2010. return jiShu;
  2011. case 7:
  2012. for(i=0;i<7;i++)
  2013. {
  2014. if(L[i].z==53||L[i].z==54)
  2015. return 1000;
  2016. for(j=0;j<7;j++)
  2017. {
  2018. if(L[i].z%13!=L[j].z%13)
  2019. jiShu++;
  2020. }
  2021. }
  2022. return jiShu;
  2023. case 8:
  2024. for(i=0;i<8;i++)
  2025. {
  2026. if(L[i].z==53||L[i].z==54)
  2027. return 1000;
  2028. for(j=0;j<8;j++)
  2029. {
  2030. if(L[i].z%13!=L[j].z%13)
  2031. jiShu++;
  2032. }
  2033. }
  2034. return jiShu;
  2035. case 9:
  2036. for(i=0;i<9;i++)
  2037. {
  2038. if(L[i].z==53||L[i].z==54)
  2039. return 1000;
  2040. for(j=0;j<9;j++)
  2041. {
  2042. if(L[i].z%13!=L[j].z%13)
  2043. jiShu++;
  2044. }
  2045. }
  2046. return jiShu;
  2047. case 10:
  2048. for(i=0;i<10;i++)
  2049. {
  2050. if(L[i].z==53||L[i].z==54)
  2051. return 1000;
  2052. for(j=0;j<10;j++)
  2053. {
  2054. if(L[i].z%13!=L[j].z%13)
  2055. jiShu++;
  2056. }
  2057. }
  2058. return jiShu;
  2059. case 11:
  2060. for(i=0;i<11;i++)
  2061. {
  2062. if(L[i].z==53||L[i].z==54)
  2063. return 1000;
  2064. for(j=0;j<11;j++)
  2065. {
  2066. if(L[i].z%13!=L[j].z%13)
  2067. jiShu++;
  2068. }
  2069. }
  2070. return jiShu;
  2071. case 12:
  2072. for(i=0;i<12;i++)
  2073. {
  2074. if(L[i].z==53||L[i].z==54)
  2075. return 1000;
  2076. for(j=0;j<12;j++)
  2077. {
  2078. if(L[i].z%13!=L[j].z%13)
  2079. jiShu++;
  2080. }
  2081. }
  2082. return jiShu;
  2083. default:
  2084. break;
  2085. }
  2086. }
  2087. int CMyView::YuanShuL(int num)
  2088. {
  2089. int i=0;
  2090. int j=0;
  2091. int jiShu=0;
  2092. switch(num)
  2093. {
  2094. case 4:
  2095. for(i=0;i<4;i++)
  2096. {
  2097. for(j=0;j<4;j++)
  2098. {
  2099. if(L[i].z%13!=L[j].z%13)
  2100. {
  2101. jiShu++;
  2102. }
  2103. }
  2104. if(jiShu==1)
  2105. return L[i].z;
  2106. else
  2107. jiShu=0;
  2108. }
  2109. MessageBox("这里出错了YuanShuL(4)");
  2110. break;
  2111. case 5:
  2112. for(i=0;i<5;i++)
  2113. {
  2114. for(j=0;j<5;j++)
  2115. {
  2116. if(L[i].z%13!=L[j].z%13)
  2117. {
  2118. jiShu++;
  2119. }
  2120. }
  2121. if(jiShu==2)
  2122. return L[i].z;
  2123. else
  2124. jiShu=0;
  2125. }
  2126. MessageBox("YuanShuL(5)");
  2127. break;
  2128. default:
  2129. break;
  2130. }
  2131. }
  2132. BOOL CMyView::NoJokerF(int num)
  2133. {
  2134. int i=0;
  2135. switch(num)
  2136. {
  2137. case 4:
  2138. for(i=0;i<4;i++)
  2139. {
  2140. if(F[i].z==54||F[i].z==53)
  2141. return FALSE;
  2142. }
  2143. return TRUE;
  2144. case 5:
  2145. for(i=0;i<5;i++)
  2146. {
  2147. if(F[i].z==54||F[i].z==53)
  2148. return FALSE;
  2149. }
  2150. default:
  2151. break;
  2152. }
  2153. }
  2154. void CMyView::BuYao()
  2155. {
  2156. int i=0;
  2157. int j=0;
  2158. int yShua=0;
  2159. switch(nIsWho)
  2160. {
  2161. case 0:
  2162. yShua=150;
  2163. break;
  2164. case 1:
  2165. yShua=214;
  2166. break;
  2167. case 2:
  2168. yShua=278;
  2169. break;
  2170. }
  2171. for(i=0;i<20;i++)
  2172. {
  2173. nCusor[i]=0;
  2174. InvalidateRect(CRect(i*32,yShua,i*32+32,yShua+32));
  2175. }
  2176. nIsWho=++nIsWho%3;
  2177. InvalidateRect(CRect(0,0,72,16));
  2178. //自己的牌要给自己让路
  2179. nLastFormWho--;
  2180. if(nLastFormWho<=0)
  2181. {
  2182. for(i=0;i<20;i++)
  2183. {
  2184. if(L[i].z!=0)
  2185. {
  2186. L[i].z=0;
  2187. InvalidateRect(CRect(0,342,640,374));
  2188. }
  2189. }
  2190. }
  2191. }
  2192. void CMyView::AllQingKong()
  2193. {
  2194. int i=0;
  2195. for(i=0;i<20;i++)
  2196. {
  2197. C1[i].z=0;
  2198. C2[i].z=0;
  2199. P[i].z=0;
  2200. L[i].z=0;
  2201. F[i].z=0;
  2202. }
  2203. }