home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 Mobile / Chip_Mobile_2001.iso / palm / spiele / hkmajong / hkmajong.exe / majong / src / MJ.java < prev    next >
Text File  |  1999-03-01  |  40KB  |  1,290 lines

  1. import waba.fx.*;
  2. import waba.ui.*;
  3. import waba.sys.*;
  4.  
  5. class MJStage
  6. {
  7.   public final static int FOUR=0;
  8.   public final static int OPEN=1;
  9.   public final static int CLOSE=2;
  10.   public final static int SHOW=3;
  11.   public final static int HIDE=4;
  12.   public final static int SELECTED=5;
  13.  
  14.   public final static Image[] StageBmp = {
  15.         new Image("mj_open.wbm"),
  16.         new Image("mj_open.wbm"),
  17.         new Image("mj_close.wbm"),
  18.         new Image("mj_show.wbm"),
  19.         new Image("mj_hide.wbm"),
  20.         new Image("mj_show.wbm")};
  21.  
  22.   public final static int X[] = {Var.MJOPENFACEX, Var.MJOPENFACEX, -1, Var.MJSHOWFACEX, -1, Var.MJSHOWFACEX};
  23.   public final static int Y[] = {Var.MJOPENFACEY, Var.MJOPENFACEY, -1, Var.MJSHOWFACEY, -1, Var.MJSHOWFACEY};
  24.   public final static boolean[] drawFace = {true, true, false, true, false, true};
  25.  
  26.   public static final Image BMP(int intWhich)
  27.   {
  28.     return StageBmp[intWhich];
  29.   }
  30. }
  31.  
  32. class MJ
  33. {
  34.   public static MJStage Stage;
  35.  
  36.   public final static Image FourBmp = new Image("four.wbm");
  37.   public final static Image DoneBmp = new Image("done.wbm");
  38.  
  39.   public final static Image[] DiceBmp = {
  40.          new Image("dice1.wbm"),
  41.          new Image("dice2.wbm"),
  42.          new Image("dice3.wbm"),
  43.          new Image("dice4.wbm"),
  44.          new Image("dice5.wbm"),
  45.          new Image("dice6.wbm")};
  46.  
  47.   public final static Image[] FaceBmp = {
  48.     new Image("m1.wbm"),
  49.     new Image("m2.wbm"),
  50.     new Image("m3.wbm"),
  51.     new Image("m4.wbm"),
  52.     new Image("m5.wbm"),
  53.     new Image("m6.wbm"),
  54.     new Image("m7.wbm"),
  55.     new Image("m8.wbm"),
  56.     new Image("m9.wbm"),
  57.     new Image("b1.wbm"),
  58.     new Image("b2.wbm"),
  59.     new Image("b3.wbm"),
  60.     new Image("b4.wbm"),
  61.     new Image("b5.wbm"),
  62.     new Image("b6.wbm"),
  63.     new Image("b7.wbm"),
  64.     new Image("b8.wbm"),
  65.     new Image("b9.wbm"),
  66.     new Image("t1.wbm"),
  67.     new Image("t2.wbm"),
  68.     new Image("t3.wbm"),
  69.     new Image("t4.wbm"),
  70.     new Image("t5.wbm"),
  71.     new Image("t6.wbm"),
  72.     new Image("t7.wbm"),
  73.     new Image("t8.wbm"),
  74.     new Image("t9.wbm"),
  75.     new Image("east.wbm"),
  76.     new Image("south.wbm"),
  77.     new Image("west.wbm"),
  78.     new Image("north.wbm"),
  79.     new Image("middle.wbm"),
  80.     new Image("fat.wbm"),
  81.     new Image("white.wbm")};
  82.  
  83.   public final static int M1=1; //0
  84.   public final static int M2=2; //1
  85.   public final static int M3=3; //2
  86.   public final static int M4=4; //3
  87.   public final static int M5=5; //4
  88.   public final static int M6=6; //5
  89.   public final static int M7=7; //6
  90.   public final static int M8=8; //7
  91.   public final static int M9=9; //8
  92.   public final static int B1=21; //9
  93.   public final static int B2=22; //10
  94.   public final static int B3=23; //11
  95.   public final static int B4=24; //12
  96.   public final static int B5=25; //13
  97.   public final static int B6=26; //14
  98.   public final static int B7=27; //15
  99.   public final static int B8=28; //16
  100.   public final static int B9=29; //17
  101.   public final static int T1=41; //18
  102.   public final static int T2=42; //19
  103.   public final static int T3=43; //20
  104.   public final static int T4=44; //21
  105.   public final static int T5=45; //22
  106.   public final static int T6=46; //23
  107.   public final static int T7=47; //24
  108.   public final static int T8=48; //25
  109.   public final static int T9=49; //26
  110.   public final static int EAST=60; //27
  111.   public final static int SOUTH=80; //28
  112.   public final static int WEST=100; //29
  113.   public final static int NORTH=120; //30
  114.   public final static int MIDDLE=140; //31
  115.   public final static int FAT=160; //32
  116.   public final static int WHITE=180; //33
  117.  
  118.   public final static int intFaceCount[]=new int[34];
  119.  
  120.   static float randomSeed=0;
  121.  
  122.   public static final void Init()
  123.   {
  124.     int i;
  125.  
  126.     for(i=0;i<34;i++)
  127.     {
  128.       intFaceCount[i]=0;
  129.     }
  130.   }
  131.  
  132.   public static final Image BMP(int intWhich)
  133.   {
  134.     return FaceBmp[Face2RealNum(intWhich)];
  135.   }
  136.  
  137.   public static final int Real2FaceNum(int intNum)
  138.   {
  139.     int intWhich=0;
  140.  
  141.     if(intNum<=8)
  142.     {
  143.       intWhich=intNum+1; // for m?
  144.     }
  145.     else if(intNum>=9 && intNum<=17)
  146.     {
  147.       intWhich=intNum+12;
  148.     }
  149.     else if(intNum>=18 && intNum<=26)
  150.     {
  151.       intWhich=intNum+23;
  152.     }
  153.     else
  154.     {
  155.       intWhich=(intNum-27)*20+60;
  156.     }
  157.     return intWhich;
  158.   }
  159.  
  160.   public static final int Face2RealNum(int intWhich)
  161.   {
  162.     if (intWhich>=M1 && intWhich<=M9)
  163.     {
  164.       intWhich=intWhich-M1;
  165.     }
  166.     else if (intWhich>=B1 && intWhich<=B9)
  167.     {
  168.       intWhich=intWhich-B1+9;
  169.     }
  170.     else if (intWhich>=T1 && intWhich<=T9)
  171.     {
  172.       intWhich=intWhich-T1+18;
  173.     }
  174.     else
  175.     {
  176.       intWhich=(intWhich-60)/20+27;
  177.     }
  178.     return intWhich;
  179.   }
  180.  
  181.   public static final String RealNum2Name(int intWhich)
  182.   {
  183.     String strRet;
  184.     switch(intWhich)
  185.     {
  186.       case MJ.EAST:
  187.         strRet="East";
  188.         break;
  189.       case MJ.SOUTH:
  190.         strRet="South";
  191.         break;
  192.       case MJ.WEST:
  193.         strRet="West";
  194.         break;
  195.       case MJ.NORTH:
  196.         strRet="North";
  197.         break;
  198.       case MJ.MIDDLE:
  199.         strRet="Middle";
  200.         break;
  201.       case MJ.FAT:
  202.         strRet="Fat";
  203.         break;
  204.       case MJ.WHITE:
  205.         strRet="White";
  206.         break;
  207.       default:
  208.         strRet="Unknown";
  209.         break;
  210.       }
  211.     return strRet;
  212.   }
  213.  
  214.   public static final Image CreateMaJong(int intStage, int intFace)
  215.   {
  216.     Image iMaJong=new Image(Var.MJW, Var.MJH);
  217.     Graphics gMaJong=new Graphics(iMaJong);
  218.     int intFaceX, intFaceY;
  219.  
  220.     gMaJong.copyRect(MJ.Stage.BMP(intStage),0,0,Var.MJW,Var.MJH,0,0);
  221.     if(MJ.Stage.drawFace[intStage]==true)
  222.     {
  223.       // place MaJong face
  224.       gMaJong.setDrawOp(gMaJong.DRAW_OR);
  225.       gMaJong.drawImage(MJ.BMP(intFace), MJ.Stage.X[intStage], MJ.Stage.Y[intStage]);
  226.       gMaJong.setDrawOp(gMaJong.DRAW_OVER);
  227.  
  228.       // check if four of a kind
  229.       if(intStage==Stage.FOUR)
  230.       {
  231.         gMaJong.setColor(Var.DARKGREY, Var.DARKGREY, Var.DARKGREY);
  232.         gMaJong.fillRect(MJ.Stage.X[intStage]+1, MJ.Stage.Y[intStage], Var.MJFOURW, Var.MJFOURH);
  233.       }
  234.     }
  235.  
  236.     return iMaJong;
  237.   }
  238.  
  239.   public static int rand(int intMax)
  240.   {
  241.     float temp;
  242.  
  243.     randomSeed = randomSeed * 1103 + 12345;
  244.     randomSeed = randomSeed % 65535;
  245.     temp=(randomSeed % 255);
  246.     temp=(int)(temp/255 * intMax);
  247.     if(temp>=intMax) temp=temp-intMax;
  248.     return((int)temp);
  249.   }
  250.  
  251.   public static void srand(float seed)
  252.   {
  253.     randomSeed=randomSeed+seed;
  254.   }
  255.  
  256. /*************************************************************************/
  257.   public static int CheckFan(int intMJFace[], int intByOwn, int intWind, int intSeat, boolean booShow, Graphics g)
  258.   {
  259.     int i=0, j=0;
  260.     int intFan;
  261.     boolean booDone;
  262.     int intGroup[]=new int[5];
  263.     int intType[]=new int[5]; //0=same, 1=in order
  264.     // for drawing
  265.     Image iFan=new Image(Var.SHOWFANW, Var.SHOWFANH);
  266.     Graphics gFan=new Graphics(iFan);
  267.     Font f = new Font("Arial", Font.PLAIN, 14);
  268.     FontMetrics fm = new FontMetrics(f, iFan);
  269.     int intLineSpace=fm.getHeight()+fm.getLeading();
  270.     int intCurLine=intLineSpace;
  271.  
  272.     if(booShow)
  273.     {
  274.       gFan.setColor(Var.BLACK,Var.BLACK,Var.BLACK);
  275.       gFan.fillRect(0, 0, Var.SHOWFANW, Var.SHOWFANH);
  276.       gFan.setColor(Var.LIGHTGREY,Var.LIGHTGREY,Var.LIGHTGREY);
  277.       gFan.fillRect(0+1, 0+1, Var.SHOWFANW-2, Var.SHOWFANH-2);
  278.       gFan.setColor(Var.BLACK,Var.BLACK,Var.BLACK);
  279.       gFan.setFont(f);
  280.     }
  281.  
  282.     intFan=0;
  283.     booDone=false;
  284.     for(i=0;i<5;i++)
  285.     {
  286.       if(intMJFace[i*3]>=1 && intMJFace[i*3]<=9)
  287.         intGroup[i]=1;
  288.       else if(intMJFace[i*3]>=21 && intMJFace[i*3]<=29)
  289.         intGroup[i]=21;
  290.       else if(intMJFace[i*3]>=41 && intMJFace[i*3]<=49)
  291.         intGroup[i]=41;
  292.       else
  293.         intGroup[i]=intMJFace[i*3];
  294.  
  295.       if(intMJFace[i*3] != intMJFace[(i*3)+1]) // in order
  296.       {
  297.         intType[i]=1;
  298.       }
  299.     }
  300.  
  301.     if (intByOwn>0) // got by own
  302.     {
  303.       if(booShow) gFan.drawText("Own last tile = 1", intLineSpace, intCurLine); intCurLine=intCurLine+intLineSpace;
  304.       intFan=intFan+1;
  305.       intByOwn--;
  306.     }
  307.  
  308.     if (intByOwn>0) // got by four
  309.     {
  310.       if(booShow) gFan.drawText("Last tile after four = 1", intLineSpace, intCurLine); intCurLine=intCurLine+intLineSpace;
  311.       intFan=intFan+1;
  312.     }
  313.  
  314.     if (booDone == false) // check 13 fan
  315.     {
  316.       if (intMJFace[0]+1 < intMJFace[1])
  317.       {
  318.         if(booShow) gFan.drawText("13 Faces = 13", intLineSpace, intCurLine); intCurLine=intCurLine+intLineSpace;
  319.         intFan=intFan+13;
  320.         booDone=true;
  321.       }
  322.     }
  323.  
  324.     if (booDone == false) // check Big ESWN
  325.     {
  326.       if (intGroup[0]>=60 && intGroup[0]<=120 &&
  327.           intGroup[1]>=60 && intGroup[1]<=120 &&
  328.           intGroup[2]>=60 && intGroup[2]<=120 &&
  329.           intGroup[3]>=60 && intGroup[3]<=120)
  330.       {
  331.         if(booShow) gFan.drawText("Big E S W N = 7", intLineSpace, intCurLine); intCurLine=intCurLine+intLineSpace;
  332.         intFan=intFan+7;
  333.         booDone=true;
  334.       }
  335.     }
  336.  
  337.     if (booDone == false) // check Small ESWN
  338.     {
  339.       if (intGroup[1]>=60 && intGroup[1]<=120 &&
  340.           intGroup[2]>=60 && intGroup[2]<=120 &&
  341.           intGroup[3]>=60 && intGroup[3]<=120 &&
  342.           intGroup[4]>=60 && intGroup[4]<=120)
  343.       {
  344.         if(booShow) gFan.drawText("Small E S W N = 4", intLineSpace, intCurLine); intCurLine=intCurLine+intLineSpace;
  345.         intFan=intFan+4;
  346.         booDone=true;
  347.       }
  348.     }
  349.  
  350.     if (booDone == false) // check Big MFW
  351.     {
  352.       if (intGroup[1]>=140 && intGroup[1]<=180 &&
  353.           intGroup[2]>=140 && intGroup[2]<=180 &&
  354.           intGroup[3]>=140 && intGroup[3]<=180)
  355.       {
  356.         if(booShow) gFan.drawText("Big M F W = 7", intLineSpace, intCurLine); intCurLine=intCurLine+intLineSpace;
  357.         intFan=intFan+7;
  358.         booDone=true;
  359.       }
  360.     }
  361.  
  362.     if (booDone == false) // check Small MFW
  363.     {
  364.       if (intGroup[2]>=140 && intGroup[2]<=180 &&
  365.           intGroup[3]>=140 && intGroup[3]<=180 &&
  366.           intGroup[4]>=140 && intGroup[4]<=180)
  367.       {
  368.         if(booShow) gFan.drawText("Small M F W = 4", intLineSpace, intCurLine); intCurLine=intCurLine+intLineSpace;
  369.         intFan=intFan+4;
  370.         booDone=true;
  371.       }
  372.     }
  373.  
  374.     if (booDone == false) // check All Same
  375.     {
  376.       if ( (intGroup[0]==intGroup[1] && intGroup[1]==intGroup[2] && intGroup[2]==intGroup[3] && intGroup[3]==intGroup[4]) ||
  377.            (intGroup[0]>=60 && intGroup[1]>=60 && intGroup[2]>=60 && intGroup[3]>=60 && intGroup[4]>=60) )
  378.       {
  379.         if(booShow) gFan.drawText("All in same group = 7", intLineSpace, intCurLine); intCurLine=intCurLine+intLineSpace;
  380.         intFan=intFan+7;
  381.       }
  382.     }
  383.  
  384.     // check mixed
  385.     {
  386.       if (intGroup[0]>=60 || intGroup[1]>=60 || intGroup[2]>=60 || intGroup[3]>=60 || intGroup[4]>=60)
  387.       {
  388.         if ((intGroup[0]==intGroup[1] || intGroup[0]>=60 || intGroup[1]>=60) &&
  389.             (intGroup[0]==intGroup[2] || intGroup[0]>=60 || intGroup[2]>=60) &&
  390.             (intGroup[0]==intGroup[3] || intGroup[0]>=60 || intGroup[3]>=60) &&
  391.             (intGroup[0]==intGroup[4] || intGroup[0]>=60 || intGroup[4]>=60) &&
  392.             (intGroup[1]==intGroup[2] || intGroup[1]>=60 || intGroup[2]>=60) &&
  393.             (intGroup[1]==intGroup[3] || intGroup[1]>=60 || intGroup[3]>=60) &&
  394.             (intGroup[1]==intGroup[4] || intGroup[1]>=60 || intGroup[4]>=60) &&
  395.             (intGroup[2]==intGroup[3] || intGroup[2]>=60 || intGroup[3]>=60) &&
  396.             (intGroup[2]==intGroup[4] || intGroup[2]>=60 || intGroup[4]>=60) &&
  397.             (intGroup[3]==intGroup[4] || intGroup[3]>=60 || intGroup[4]>=60))
  398.         {
  399.           if(booShow) gFan.drawText("Mixed = 3", intLineSpace, intCurLine); intCurLine=intCurLine+intLineSpace;
  400.           intFan=intFan+3;
  401.         }
  402.       }
  403.     }
  404.  
  405.     // check All Three of a Kind
  406.     {
  407.       if (intType[0]==0 && intType[1]==0 && intType[2]==0 && intType[3]==0)
  408.       {
  409.         if(booShow) gFan.drawText("All three of a kind = 3", intLineSpace, intCurLine); intCurLine=intCurLine+intLineSpace;
  410.         intFan=intFan+3;
  411.       }
  412.     }
  413.  
  414.     // check All In Ordered
  415.     {
  416.       if (intType[0]==1 && intType[1]==1 && intType[2]==1 && intType[3]==1)
  417.       {
  418.         if(booShow) gFan.drawText("All in ordered = 1", intLineSpace, intCurLine); intCurLine=intCurLine+intLineSpace;
  419.         intFan=intFan+1;
  420.       }
  421.     }
  422.  
  423.  
  424.     // check wind
  425.     if (booDone == false)
  426.     {
  427.       for (i=0;i<4;i++)
  428.       {
  429.         if (intGroup[i]==intWind)
  430.         {
  431.           if(booShow) gFan.drawText(RealNum2Name(intGroup[i])+" wind has fan = 1", intLineSpace, intCurLine); intCurLine=intCurLine+intLineSpace;
  432.           intFan=intFan+1;
  433.         }
  434.       }
  435.     }
  436.  
  437.     // check seat
  438.     if (booDone == false)
  439.     {
  440.       for (i=0;i<4;i++)
  441.       {
  442.         if (intGroup[i]==intSeat)
  443.         {
  444.           if(booShow) gFan.drawText(RealNum2Name(intGroup[i])+" seat has fan = 1", intLineSpace, intCurLine); intCurLine=intCurLine+intLineSpace;
  445.           intFan=intFan+1;
  446.         }
  447.       }
  448.     }
  449.  
  450.     // check M F W
  451.     if (booDone == false)
  452.     {
  453.       for (i=0;i<4;i++)
  454.       {
  455.         if (intGroup[i]>=140)
  456.         {
  457.           if(booShow) gFan.drawText("Tile "+RealNum2Name(intGroup[i])+" has fan = 1", intLineSpace, intCurLine); intCurLine=intCurLine+intLineSpace;
  458.           intFan=intFan+1;
  459.         }
  460.       }
  461.     }
  462.  
  463.     if(booShow)
  464.     {
  465.       gFan.drawText("Total = "+intFan+" fan(s)", intLineSpace, intCurLine); intCurLine=intCurLine+intLineSpace;
  466.       gFan.drawImage(new Image("closebutton.wbm"), Var.SHOWFANW-Var.CLOSEBUTTONW, 0);
  467.       g.drawImage(iFan, Var.SHOWFANX, Var.SHOWFANY);
  468.     }
  469.  
  470.     return intFan;
  471.   }
  472.  
  473. /*************************************************************************/
  474.   public static int[] CheckDone13Face(int intMJFace[])
  475.   {
  476.     int i=0, j=0, k=0, l=0;
  477.     boolean booChecked[]=new boolean[14];
  478.     int intDoneFace[]=new int[14];
  479.     int int13Face[]={MJ.M1, MJ.M9, MJ.B1, MJ.B9, MJ.T1, MJ.T9, MJ.EAST, MJ.SOUTH, MJ.WEST, MJ.NORTH, MJ.MIDDLE, MJ.FAT, MJ.WHITE};
  480.     boolean booEye=false;
  481.  
  482.     // check 13 faces
  483. if (Var.DEBUG) System.out.println("--- check 13 faces ---");
  484.     for(i=0;i<14;i++)
  485.     {
  486.       booChecked[i]=false;
  487.       intDoneFace[i]=Var.MJNOTDEFINED;
  488.     }
  489.     for(i=0;i<13;i++)
  490.     {
  491.       for(j=0;j<14;j++)
  492.       {
  493.         if(int13Face[i]==intMJFace[j] && booChecked[j]==false)
  494.         {
  495.           booChecked[j]=true;
  496.           l++;
  497.           intDoneFace[k++]=intMJFace[j];
  498.           break;
  499.         }
  500.       }
  501.     }
  502.     for(i=0;i<14 && booEye==false;i++)  // check last MJ
  503.     {
  504.       if(booChecked[i]==false)
  505.       {
  506.         for(j=0;j<13 && booEye==false;j++)
  507.         {
  508.           if(intMJFace[i]==int13Face[j])
  509.           {
  510.             intDoneFace[k++]=intMJFace[i];
  511.             booEye=true;
  512.           }
  513.         }
  514.       }
  515.     }
  516.     if(l!=13 || booEye==false)
  517.     {
  518.       intDoneFace[0]=Var.MJNOTDEFINED; // not done!
  519.     }
  520.  
  521.     return intDoneFace;
  522.   }
  523.  
  524. /*************************************************************************/
  525.   public static int[] CheckDoneLeft2RightOPE(int intMJFace[])
  526.   {
  527.     int i=0, j=0, k=0, l=0;
  528.     boolean booChecked[]=new boolean[14];
  529.     int intDoneFace[]=new int[14];
  530.     int int3Kind=0;
  531.     boolean booEye=false;
  532.     boolean booFoundPair=false;
  533.  
  534.     // check from left to right
  535. if (Var.DEBUG) System.out.println("--- check from left to right in order first ---");
  536.     for(i=0;i<14;i++)
  537.     {
  538.       booChecked[i]=false;
  539.       intDoneFace[i]=Var.MJNOTDEFINED;
  540.     }
  541.     for(i=0;i<14;i++)
  542.     {
  543.       booFoundPair=false;
  544.       if(booChecked[i]==false)
  545.       {
  546. if (Var.DEBUG) System.out.println("checking pos:"+i+" Face:"+intMJFace[i]);
  547.         booChecked[i]=true;
  548.         // check in order
  549.         for(j=0;j<14 && booFoundPair==false;j++)
  550.         {
  551.           if(booChecked[j]==false && intMJFace[i]+1==intMJFace[j])
  552.           {
  553.             booChecked[j]=true;
  554.             for(k=0;k<14 && booFoundPair==false;k++)
  555.             {
  556.               if(booChecked[k]==false && intMJFace[j]+1==intMJFace[k]) //found in order
  557.               {
  558. if (Var.DEBUG) System.out.println("in order");
  559.                 booChecked[k]=true;
  560.                 int3Kind++;
  561.                 booFoundPair=true;
  562.                 intDoneFace[l++]=intMJFace[i];
  563.                 intDoneFace[l++]=intMJFace[j];
  564.                 intDoneFace[l++]=intMJFace[k];
  565.               }
  566.             }
  567.             if(booFoundPair==false) booChecked[j]=false; //reset
  568.           }
  569.         }
  570.  
  571.         // check three of a kind
  572.         for(j=0;j<14 && booFoundPair==false;j++)
  573.         {
  574.           if(booChecked[j]==false && intMJFace[i]==intMJFace[j])
  575.           {
  576.             booChecked[j]=true;
  577.             for(k=0;k<14 && booFoundPair==false;k++)
  578.             {
  579.               if(booChecked[k]==false && intMJFace[j]==intMJFace[k]) //found three of a kind
  580.               {
  581. if (Var.DEBUG) System.out.println("three of a kind");
  582.                 booChecked[k]=true;
  583.                 int3Kind++;
  584.                 booFoundPair=true;
  585.                 intDoneFace[l++]=intMJFace[i];
  586.                 intDoneFace[l++]=intMJFace[j];
  587.                 intDoneFace[l++]=intMJFace[k];
  588.               }
  589.             }
  590.             if(booFoundPair==false) booChecked[j]=false; //reset
  591.           }
  592.         }
  593.  
  594.         // check for a pair(eye)
  595.         for(j=0;j<14 && booFoundPair==false && booEye==false;j++)
  596.         {
  597.           if(booChecked[j]==false && intMJFace[i]==intMJFace[j])
  598.           {
  599. if (Var.DEBUG) System.out.println("eye");
  600.             booChecked[j]=true;
  601.             booEye=true;
  602.             booFoundPair=true;
  603.             intDoneFace[12]=intMJFace[i];
  604.             intDoneFace[13]=intMJFace[j];
  605.           }
  606.         }
  607.  
  608.         if(booFoundPair==false) booChecked[i]=false; //reset
  609.       }
  610.     }
  611. if (Var.DEBUG) System.out.println("kind:"+int3Kind+" Eye:"+booEye);
  612.     if(int3Kind!=4 || booEye==false)
  613.     {
  614.       intDoneFace[0]=Var.MJNOTDEFINED; // not done!
  615.     }
  616.  
  617.     return intDoneFace;
  618.   }
  619.  
  620. /*************************************************************************/
  621.   public static int[] CheckDoneRight2LeftOPE(int intMJFace[])
  622.   {
  623.     int i=0, j=0, k=0, l=0;
  624.     boolean booChecked[]=new boolean[14];
  625.     int intDoneFace[]=new int[14];
  626.     int int3Kind=0;
  627.     boolean booEye=false;
  628.     boolean booFoundPair=false;
  629.  
  630.     // check from right to left
  631. if (Var.DEBUG) System.out.println("--- check from right to left in order first ---");
  632.     for(i=0;i<14;i++)
  633.     {
  634.       booChecked[i]=false;
  635.       intDoneFace[i]=Var.MJNOTDEFINED;
  636.     }
  637.     for(i=13;i>=0;i--)
  638.     {
  639.       booFoundPair=false;
  640.       if(booChecked[i]==false)
  641.       {
  642. if (Var.DEBUG) System.out.println("checking pos:"+i+" Face:"+intMJFace[i]);
  643.         booChecked[i]=true;
  644.         // check in order
  645.         for(j=13;j>=0 && booFoundPair==false;j--)
  646.         {
  647.           if(booChecked[j]==false && intMJFace[i]-1==intMJFace[j])
  648.           {
  649.             booChecked[j]=true;
  650.             for(k=13;k>=0 && booFoundPair==false;k--)
  651.             {
  652.               if(booChecked[k]==false && intMJFace[j]-1==intMJFace[k]) //found in order
  653.               {
  654. if (Var.DEBUG) System.out.println("in order");
  655.                 booChecked[k]=true;
  656.                 int3Kind++;
  657.                 booFoundPair=true;
  658.                 intDoneFace[l++]=intMJFace[k];
  659.                 intDoneFace[l++]=intMJFace[j];
  660.                 intDoneFace[l++]=intMJFace[i];
  661.               }
  662.             }
  663.             if(booFoundPair==false) booChecked[j]=false; //reset
  664.           }
  665.         }
  666.  
  667.         // check three of a kind
  668.         for(j=13;j>=0 && booFoundPair==false;j--)
  669.         {
  670.           if(booChecked[j]==false && intMJFace[i]==intMJFace[j])
  671.           {
  672.             booChecked[j]=true;
  673.             for(k=13;k>=0 && booFoundPair==false;k--)
  674.             {
  675.               if(booChecked[k]==false && intMJFace[j]==intMJFace[k]) //found three of a kind
  676.               {
  677. if (Var.DEBUG) System.out.println("three of a kind");
  678.                 booChecked[k]=true;
  679.                 int3Kind++;
  680.                 booFoundPair=true;
  681.                 intDoneFace[l++]=intMJFace[k];
  682.                 intDoneFace[l++]=intMJFace[j];
  683.                 intDoneFace[l++]=intMJFace[i];
  684.               }
  685.             }
  686.             if(booFoundPair==false) booChecked[j]=false; //reset
  687.           }
  688.         }
  689.  
  690.         // check for a pair(eye)
  691.         for(j=13;j>=0 && booFoundPair==false && booEye==false;j--)
  692.         {
  693.           if(booChecked[j]==false && intMJFace[i]==intMJFace[j])
  694.           {
  695. if (Var.DEBUG) System.out.println("eye");
  696.             booChecked[j]=true;
  697.             booEye=true;
  698.             booFoundPair=true;
  699.             intDoneFace[12]=intMJFace[i];
  700.             intDoneFace[13]=intMJFace[j];
  701.           }
  702.         }
  703.  
  704.         if(booFoundPair==false) booChecked[i]=false; //reset
  705.       }
  706.     }
  707. if (Var.DEBUG) System.out.println("kind:"+int3Kind+" Eye:"+booEye);
  708.     if(int3Kind!=4 || booEye==false)
  709.     {
  710.       intDoneFace[0]=Var.MJNOTDEFINED; // not done!
  711.     }
  712.  
  713.     return intDoneFace;
  714.   }
  715.  
  716. /*************************************************************************/
  717.   public static int[] CheckDoneLeft2RightPOE(int intMJFace[])
  718.   {
  719.     int i=0, j=0, k=0, l=0;
  720.     boolean booChecked[]=new boolean[14];
  721.     int intDoneFace[]=new int[14];
  722.     int int3Kind=0;
  723.     boolean booEye=false;
  724.     boolean booFoundPair=false;
  725.  
  726.     // check from left to right
  727. if (Var.DEBUG) System.out.println("--- check from left to right 3 Kind first ---");
  728.     for(i=0;i<14;i++)
  729.     {
  730.       booChecked[i]=false;
  731.       intDoneFace[i]=Var.MJNOTDEFINED;
  732.     }
  733.     for(i=0;i<14;i++)
  734.     {
  735.       booFoundPair=false;
  736.       if(booChecked[i]==false)
  737.       {
  738. if (Var.DEBUG) System.out.println("checking pos:"+i+" Face:"+intMJFace[i]);
  739.         booChecked[i]=true;
  740.         // check three of a kind
  741.         for(j=0;j<14 && booFoundPair==false;j++)
  742.         {
  743.           if(booChecked[j]==false && intMJFace[i]==intMJFace[j])
  744.           {
  745.             booChecked[j]=true;
  746.             for(k=0;k<14 && booFoundPair==false;k++)
  747.             {
  748.               if(booChecked[k]==false && intMJFace[j]==intMJFace[k]) //found three of a kind
  749.               {
  750. if (Var.DEBUG) System.out.println("three of a kind");
  751.                 booChecked[k]=true;
  752.                 int3Kind++;
  753.                 booFoundPair=true;
  754.                 intDoneFace[l++]=intMJFace[i];
  755.                 intDoneFace[l++]=intMJFace[j];
  756.                 intDoneFace[l++]=intMJFace[k];
  757.               }
  758.             }
  759.             if(booFoundPair==false) booChecked[j]=false; //reset
  760.           }
  761.         }
  762.  
  763.         // check in order
  764.         for(j=0;j<14 && booFoundPair==false;j++)
  765.         {
  766.           if(booChecked[j]==false && intMJFace[i]+1==intMJFace[j])
  767.           {
  768.             booChecked[j]=true;
  769.             for(k=0;k<14 && booFoundPair==false;k++)
  770.             {
  771.               if(booChecked[k]==false && intMJFace[j]+1==intMJFace[k]) //found in order
  772.               {
  773. if (Var.DEBUG) System.out.println("in order");
  774.                 booChecked[k]=true;
  775.                 int3Kind++;
  776.                 booFoundPair=true;
  777.                 intDoneFace[l++]=intMJFace[i];
  778.                 intDoneFace[l++]=intMJFace[j];
  779.                 intDoneFace[l++]=intMJFace[k];
  780.               }
  781.             }
  782.             if(booFoundPair==false) booChecked[j]=false; //reset
  783.           }
  784.         }
  785.  
  786.         // check for a pair(eye)
  787.         for(j=0;j<14 && booFoundPair==false && booEye==false;j++)
  788.         {
  789.           if(booChecked[j]==false && intMJFace[i]==intMJFace[j])
  790.           {
  791. if (Var.DEBUG) System.out.println("eye");
  792.             booChecked[j]=true;
  793.             booEye=true;
  794.             booFoundPair=true;
  795.             intDoneFace[12]=intMJFace[i];
  796.             intDoneFace[13]=intMJFace[j];
  797.           }
  798.         }
  799.  
  800.         if(booFoundPair==false) booChecked[i]=false; //reset
  801.       }
  802.     }
  803. if (Var.DEBUG) System.out.println("kind:"+int3Kind+" Eye:"+booEye);
  804.     if(int3Kind!=4 || booEye==false)
  805.     {
  806.       intDoneFace[0]=Var.MJNOTDEFINED; // not done!
  807.     }
  808.  
  809.     return intDoneFace;
  810.   }
  811.  
  812. /*************************************************************************/
  813.   public static int[] CheckDoneRight2LeftPOE(int intMJFace[])
  814.   {
  815.     int i=0, j=0, k=0, l=0;
  816.     boolean booChecked[]=new boolean[14];
  817.     int intDoneFace[]=new int[14];
  818.     int int3Kind=0;
  819.     boolean booEye=false;
  820.     boolean booFoundPair=false;
  821.  
  822.     // check from right to left
  823. if (Var.DEBUG) System.out.println("--- check from right to left 3 Kind first ---");
  824.     for(i=0;i<14;i++)
  825.     {
  826.       booChecked[i]=false;
  827.       intDoneFace[i]=Var.MJNOTDEFINED;
  828.     }
  829.     for(i=13;i>=0;i--)
  830.     {
  831.       booFoundPair=false;
  832.       if(booChecked[i]==false)
  833.       {
  834. if (Var.DEBUG) System.out.println("checking pos:"+i+" Face:"+intMJFace[i]);
  835.         booChecked[i]=true;
  836.         // check three of a kind
  837.         for(j=13;j>=0 && booFoundPair==false;j--)
  838.         {
  839.           if(booChecked[j]==false && intMJFace[i]==intMJFace[j])
  840.           {
  841.             booChecked[j]=true;
  842.             for(k=13;k>=0 && booFoundPair==false;k--)
  843.             {
  844.               if(booChecked[k]==false && intMJFace[j]==intMJFace[k]) //found three of a kind
  845.               {
  846. if (Var.DEBUG) System.out.println("three of a kind");
  847.                 booChecked[k]=true;
  848.                 int3Kind++;
  849.                 booFoundPair=true;
  850.                 intDoneFace[l++]=intMJFace[k];
  851.                 intDoneFace[l++]=intMJFace[j];
  852.                 intDoneFace[l++]=intMJFace[i];
  853.               }
  854.             }
  855.             if(booFoundPair==false) booChecked[j]=false; //reset
  856.           }
  857.         }
  858.  
  859.         // check in order
  860.         for(j=13;j>=0 && booFoundPair==false;j--)
  861.         {
  862.           if(booChecked[j]==false && intMJFace[i]-1==intMJFace[j])
  863.           {
  864.             booChecked[j]=true;
  865.             for(k=13;k>=0 && booFoundPair==false;k--)
  866.             {
  867.               if(booChecked[k]==false && intMJFace[j]-1==intMJFace[k]) //found in order
  868.               {
  869. if (Var.DEBUG) System.out.println("in order");
  870.                 booChecked[k]=true;
  871.                 int3Kind++;
  872.                 booFoundPair=true;
  873.                 intDoneFace[l++]=intMJFace[k];
  874.                 intDoneFace[l++]=intMJFace[j];
  875.                 intDoneFace[l++]=intMJFace[i];
  876.               }
  877.             }
  878.             if(booFoundPair==false) booChecked[j]=false; //reset
  879.           }
  880.         }
  881.  
  882.         // check for a pair(eye)
  883.         for(j=13;j>=0 && booFoundPair==false && booEye==false;j--)
  884.         {
  885.           if(booChecked[j]==false && intMJFace[i]==intMJFace[j])
  886.           {
  887. if (Var.DEBUG) System.out.println("eye");
  888.             booChecked[j]=true;
  889.             booEye=true;
  890.             booFoundPair=true;
  891.             intDoneFace[12]=intMJFace[i];
  892.             intDoneFace[13]=intMJFace[j];
  893.           }
  894.         }
  895.  
  896.         if(booFoundPair==false) booChecked[i]=false; //reset
  897.       }
  898.     }
  899. if (Var.DEBUG) System.out.println("kind:"+int3Kind+" Eye:"+booEye);
  900.     if(int3Kind!=4 || booEye==false)
  901.     {
  902.       intDoneFace[0]=Var.MJNOTDEFINED; // not done!
  903.     }
  904.  
  905.     return intDoneFace;
  906.   }
  907. /*************************************************************************/
  908.   public static int[] CheckDoneLeft2RightOEP(int intMJFace[])
  909.   {
  910.     int i=0, j=0, k=0, l=0;
  911.     boolean booChecked[]=new boolean[14];
  912.     int intDoneFace[]=new int[14];
  913.     int int3Kind=0;
  914.     boolean booEye=false;
  915.     boolean booFoundPair=false;
  916.  
  917.     // check from left to right
  918. if (Var.DEBUG) System.out.println("--- check from left to right in order first ---");
  919.     for(i=0;i<14;i++)
  920.     {
  921.       booChecked[i]=false;
  922.       intDoneFace[i]=Var.MJNOTDEFINED;
  923.     }
  924.     for(i=0;i<14;i++)
  925.     {
  926.       booFoundPair=false;
  927.       if(booChecked[i]==false)
  928.       {
  929. if (Var.DEBUG) System.out.println("checking pos:"+i+" Face:"+intMJFace[i]);
  930.         booChecked[i]=true;
  931.         // check in order
  932.         for(j=0;j<14 && booFoundPair==false;j++)
  933.         {
  934.           if(booChecked[j]==false && intMJFace[i]+1==intMJFace[j])
  935.           {
  936.             booChecked[j]=true;
  937.             for(k=0;k<14 && booFoundPair==false;k++)
  938.             {
  939.               if(booChecked[k]==false && intMJFace[j]+1==intMJFace[k]) //found in order
  940.               {
  941. if (Var.DEBUG) System.out.println("in order");
  942.                 booChecked[k]=true;
  943.                 int3Kind++;
  944.                 booFoundPair=true;
  945.                 intDoneFace[l++]=intMJFace[i];
  946.                 intDoneFace[l++]=intMJFace[j];
  947.                 intDoneFace[l++]=intMJFace[k];
  948.               }
  949.             }
  950.             if(booFoundPair==false) booChecked[j]=false; //reset
  951.           }
  952.         }
  953.  
  954.         // check for a pair(eye)
  955.         for(j=0;j<14 && booFoundPair==false && booEye==false;j++)
  956.         {
  957.           if(booChecked[j]==false && intMJFace[i]==intMJFace[j])
  958.           {
  959. if (Var.DEBUG) System.out.println("eye");
  960.             booChecked[j]=true;
  961.             booEye=true;
  962.             booFoundPair=true;
  963.             intDoneFace[12]=intMJFace[i];
  964.             intDoneFace[13]=intMJFace[j];
  965.           }
  966.         }
  967.  
  968.         // check three of a kind
  969.         for(j=0;j<14 && booFoundPair==false;j++)
  970.         {
  971.           if(booChecked[j]==false && intMJFace[i]==intMJFace[j])
  972.           {
  973.             booChecked[j]=true;
  974.             for(k=0;k<14 && booFoundPair==false;k++)
  975.             {
  976.               if(booChecked[k]==false && intMJFace[j]==intMJFace[k]) //found three of a kind
  977.               {
  978. if (Var.DEBUG) System.out.println("three of a kind");
  979.                 booChecked[k]=true;
  980.                 int3Kind++;
  981.                 booFoundPair=true;
  982.                 intDoneFace[l++]=intMJFace[i];
  983.                 intDoneFace[l++]=intMJFace[j];
  984.                 intDoneFace[l++]=intMJFace[k];
  985.               }
  986.             }
  987.             if(booFoundPair==false) booChecked[j]=false; //reset
  988.           }
  989.         }
  990.  
  991.         if(booFoundPair==false) booChecked[i]=false; //reset
  992.       }
  993.     }
  994. if (Var.DEBUG) System.out.println("kind:"+int3Kind+" Eye:"+booEye);
  995.     if(int3Kind!=4 || booEye==false)
  996.     {
  997.       intDoneFace[0]=Var.MJNOTDEFINED; // not done!
  998.     }
  999.  
  1000.     return intDoneFace;
  1001.   }
  1002.  
  1003. /*************************************************************************/
  1004.   public static int[] CheckDoneRight2LeftOEP(int intMJFace[])
  1005.   {
  1006.     int i=0, j=0, k=0, l=0;
  1007.     boolean booChecked[]=new boolean[14];
  1008.     int intDoneFace[]=new int[14];
  1009.     int int3Kind=0;
  1010.     boolean booEye=false;
  1011.     boolean booFoundPair=false;
  1012.  
  1013.     // check from right to left
  1014. if (Var.DEBUG) System.out.println("--- check from right to left in order first ---");
  1015.     for(i=0;i<14;i++)
  1016.     {
  1017.       booChecked[i]=false;
  1018.       intDoneFace[i]=Var.MJNOTDEFINED;
  1019.     }
  1020.     for(i=13;i>=0;i--)
  1021.     {
  1022.       booFoundPair=false;
  1023.       if(booChecked[i]==false)
  1024.       {
  1025. if (Var.DEBUG) System.out.println("checking pos:"+i+" Face:"+intMJFace[i]);
  1026.         booChecked[i]=true;
  1027.         // check in order
  1028.         for(j=13;j>=0 && booFoundPair==false;j--)
  1029.         {
  1030.           if(booChecked[j]==false && intMJFace[i]-1==intMJFace[j])
  1031.           {
  1032.             booChecked[j]=true;
  1033.             for(k=13;k>=0 && booFoundPair==false;k--)
  1034.             {
  1035.               if(booChecked[k]==false && intMJFace[j]-1==intMJFace[k]) //found in order
  1036.               {
  1037. if (Var.DEBUG) System.out.println("in order");
  1038.                 booChecked[k]=true;
  1039.                 int3Kind++;
  1040.                 booFoundPair=true;
  1041.                 intDoneFace[l++]=intMJFace[k];
  1042.                 intDoneFace[l++]=intMJFace[j];
  1043.                 intDoneFace[l++]=intMJFace[i];
  1044.               }
  1045.             }
  1046.             if(booFoundPair==false) booChecked[j]=false; //reset
  1047.           }
  1048.         }
  1049.  
  1050.         // check for a pair(eye)
  1051.         for(j=13;j>=0 && booFoundPair==false && booEye==false;j--)
  1052.         {
  1053.           if(booChecked[j]==false && intMJFace[i]==intMJFace[j])
  1054.           {
  1055. if (Var.DEBUG) System.out.println("eye");
  1056.             booChecked[j]=true;
  1057.             booEye=true;
  1058.             booFoundPair=true;
  1059.             intDoneFace[12]=intMJFace[i];
  1060.             intDoneFace[13]=intMJFace[j];
  1061.           }
  1062.         }
  1063.  
  1064.         // check three of a kind
  1065.         for(j=13;j>=0 && booFoundPair==false;j--)
  1066.         {
  1067.           if(booChecked[j]==false && intMJFace[i]==intMJFace[j])
  1068.           {
  1069.             booChecked[j]=true;
  1070.             for(k=13;k>=0 && booFoundPair==false;k--)
  1071.             {
  1072.               if(booChecked[k]==false && intMJFace[j]==intMJFace[k]) //found three of a kind
  1073.               {
  1074. if (Var.DEBUG) System.out.println("three of a kind");
  1075.                 booChecked[k]=true;
  1076.                 int3Kind++;
  1077.                 booFoundPair=true;
  1078.                 intDoneFace[l++]=intMJFace[k];
  1079.                 intDoneFace[l++]=intMJFace[j];
  1080.                 intDoneFace[l++]=intMJFace[i];
  1081.               }
  1082.             }
  1083.             if(booFoundPair==false) booChecked[j]=false; //reset
  1084.           }
  1085.         }
  1086.  
  1087.         if(booFoundPair==false) booChecked[i]=false; //reset
  1088.       }
  1089.     }
  1090. if (Var.DEBUG) System.out.println("kind:"+int3Kind+" Eye:"+booEye);
  1091.     if(int3Kind!=4 || booEye==false)
  1092.     {
  1093.       intDoneFace[0]=Var.MJNOTDEFINED; // not done!
  1094.     }
  1095.  
  1096.     return intDoneFace;
  1097.   }
  1098.  
  1099. /*************************************************************************/
  1100.   public static int[] CheckDoneLeft2RightPEO(int intMJFace[])
  1101.   {
  1102.     int i=0, j=0, k=0, l=0;
  1103.     boolean booChecked[]=new boolean[14];
  1104.     int intDoneFace[]=new int[14];
  1105.     int int3Kind=0;
  1106.     boolean booEye=false;
  1107.     boolean booFoundPair=false;
  1108.  
  1109.     // check from left to right
  1110. if (Var.DEBUG) System.out.println("--- check from left to right 3 Kind first ---");
  1111.     for(i=0;i<14;i++)
  1112.     {
  1113.       booChecked[i]=false;
  1114.       intDoneFace[i]=Var.MJNOTDEFINED;
  1115.     }
  1116.     for(i=0;i<14;i++)
  1117.     {
  1118.       booFoundPair=false;
  1119.       if(booChecked[i]==false)
  1120.       {
  1121. if (Var.DEBUG) System.out.println("checking pos:"+i+" Face:"+intMJFace[i]);
  1122.         booChecked[i]=true;
  1123.         // check three of a kind
  1124.         for(j=0;j<14 && booFoundPair==false;j++)
  1125.         {
  1126.           if(booChecked[j]==false && intMJFace[i]==intMJFace[j])
  1127.           {
  1128.             booChecked[j]=true;
  1129.             for(k=0;k<14 && booFoundPair==false;k++)
  1130.             {
  1131.               if(booChecked[k]==false && intMJFace[j]==intMJFace[k]) //found three of a kind
  1132.               {
  1133. if (Var.DEBUG) System.out.println("three of a kind");
  1134.                 booChecked[k]=true;
  1135.                 int3Kind++;
  1136.                 booFoundPair=true;
  1137.                 intDoneFace[l++]=intMJFace[i];
  1138.                 intDoneFace[l++]=intMJFace[j];
  1139.                 intDoneFace[l++]=intMJFace[k];
  1140.               }
  1141.             }
  1142.             if(booFoundPair==false) booChecked[j]=false; //reset
  1143.           }
  1144.         }
  1145.  
  1146.         // check for a pair(eye)
  1147.         for(j=0;j<14 && booFoundPair==false && booEye==false;j++)
  1148.         {
  1149.           if(booChecked[j]==false && intMJFace[i]==intMJFace[j])
  1150.           {
  1151. if (Var.DEBUG) System.out.println("eye");
  1152.             booChecked[j]=true;
  1153.             booEye=true;
  1154.             booFoundPair=true;
  1155.             intDoneFace[12]=intMJFace[i];
  1156.             intDoneFace[13]=intMJFace[j];
  1157.           }
  1158.         }
  1159.  
  1160.         // check in order
  1161.         for(j=0;j<14 && booFoundPair==false;j++)
  1162.         {
  1163.           if(booChecked[j]==false && intMJFace[i]+1==intMJFace[j])
  1164.           {
  1165.             booChecked[j]=true;
  1166.             for(k=0;k<14 && booFoundPair==false;k++)
  1167.             {
  1168.               if(booChecked[k]==false && intMJFace[j]+1==intMJFace[k]) //found in order
  1169.               {
  1170. if (Var.DEBUG) System.out.println("in order");
  1171.                 booChecked[k]=true;
  1172.                 int3Kind++;
  1173.                 booFoundPair=true;
  1174.                 intDoneFace[l++]=intMJFace[i];
  1175.                 intDoneFace[l++]=intMJFace[j];
  1176.                 intDoneFace[l++]=intMJFace[k];
  1177.               }
  1178.             }
  1179.             if(booFoundPair==false) booChecked[j]=false; //reset
  1180.           }
  1181.         }
  1182.  
  1183.         if(booFoundPair==false) booChecked[i]=false; //reset
  1184.       }
  1185.     }
  1186. if (Var.DEBUG) System.out.println("kind:"+int3Kind+" Eye:"+booEye);
  1187.     if(int3Kind!=4 || booEye==false)
  1188.     {
  1189.       intDoneFace[0]=Var.MJNOTDEFINED; // not done!
  1190.     }
  1191.  
  1192.     return intDoneFace;
  1193.   }
  1194.  
  1195. /*************************************************************************/
  1196.   public static int[] CheckDoneRight2LeftPEO(int intMJFace[])
  1197.   {
  1198.     int i=0, j=0, k=0, l=0;
  1199.     boolean booChecked[]=new boolean[14];
  1200.     int intDoneFace[]=new int[14];
  1201.     int int3Kind=0;
  1202.     boolean booEye=false;
  1203.     boolean booFoundPair=false;
  1204.  
  1205.     // check from right to left
  1206. if (Var.DEBUG) System.out.println("--- check from right to left 3 Kind first ---");
  1207.     for(i=0;i<14;i++)
  1208.     {
  1209.       booChecked[i]=false;
  1210.       intDoneFace[i]=Var.MJNOTDEFINED;
  1211.     }
  1212.     for(i=13;i>=0;i--)
  1213.     {
  1214.       booFoundPair=false;
  1215.       if(booChecked[i]==false)
  1216.       {
  1217. if (Var.DEBUG) System.out.println("checking pos:"+i+" Face:"+intMJFace[i]);
  1218.         booChecked[i]=true;
  1219.         // check three of a kind
  1220.         for(j=13;j>=0 && booFoundPair==false;j--)
  1221.         {
  1222.           if(booChecked[j]==false && intMJFace[i]==intMJFace[j])
  1223.           {
  1224.             booChecked[j]=true;
  1225.             for(k=13;k>=0 && booFoundPair==false;k--)
  1226.             {
  1227.               if(booChecked[k]==false && intMJFace[j]==intMJFace[k]) //found three of a kind
  1228.               {
  1229. if (Var.DEBUG) System.out.println("three of a kind");
  1230.                 booChecked[k]=true;
  1231.                 int3Kind++;
  1232.                 booFoundPair=true;
  1233.                 intDoneFace[l++]=intMJFace[k];
  1234.                 intDoneFace[l++]=intMJFace[j];
  1235.                 intDoneFace[l++]=intMJFace[i];
  1236.               }
  1237.             }
  1238.             if(booFoundPair==false) booChecked[j]=false; //reset
  1239.           }
  1240.         }
  1241.  
  1242.         // check for a pair(eye)
  1243.         for(j=13;j>=0 && booFoundPair==false && booEye==false;j--)
  1244.         {
  1245.           if(booChecked[j]==false && intMJFace[i]==intMJFace[j])
  1246.           {
  1247. if (Var.DEBUG) System.out.println("eye");
  1248.             booChecked[j]=true;
  1249.             booEye=true;
  1250.             booFoundPair=true;
  1251.             intDoneFace[12]=intMJFace[i];
  1252.             intDoneFace[13]=intMJFace[j];
  1253.           }
  1254.         }
  1255.  
  1256.         // check in order
  1257.         for(j=13;j>=0 && booFoundPair==false;j--)
  1258.         {
  1259.           if(booChecked[j]==false && intMJFace[i]-1==intMJFace[j])
  1260.           {
  1261.             booChecked[j]=true;
  1262.             for(k=13;k>=0 && booFoundPair==false;k--)
  1263.             {
  1264.               if(booChecked[k]==false && intMJFace[j]-1==intMJFace[k]) //found in order
  1265.               {
  1266. if (Var.DEBUG) System.out.println("in order");
  1267.                 booChecked[k]=true;
  1268.                 int3Kind++;
  1269.                 booFoundPair=true;
  1270.                 intDoneFace[l++]=intMJFace[k];
  1271.                 intDoneFace[l++]=intMJFace[j];
  1272.                 intDoneFace[l++]=intMJFace[i];
  1273.               }
  1274.             }
  1275.             if(booFoundPair==false) booChecked[j]=false; //reset
  1276.           }
  1277.         }
  1278.  
  1279.         if(booFoundPair==false) booChecked[i]=false; //reset
  1280.       }
  1281.     }
  1282. if (Var.DEBUG) System.out.println("kind:"+int3Kind+" Eye:"+booEye);
  1283.     if(int3Kind!=4 || booEye==false)
  1284.     {
  1285.       intDoneFace[0]=Var.MJNOTDEFINED; // not done!
  1286.     }
  1287.  
  1288.     return intDoneFace;
  1289.   }
  1290. }