Example #1
0
        public DB_AGIN_Baccarat_Cell Clone()
        {
            DB_AGIN_Baccarat_Cell cell = new DB_AGIN_Baccarat_Cell();

            cell.CoordinateX = CoordinateX;
            cell.CoordinateY = CoordinateY;
            cell.PercentB    = PercentB;
            cell.PercentG    = PercentG;
            cell.PercentR    = PercentR;
            Matches.ForEach(x => { cell.Matches.Add(x); });
            cell.Order        = Order;
            cell.OrderConfuse = OrderConfuse;
            cell.CircleFsLen  = CircleFsLen;
            return(cell);
        }
Example #2
0
        public static int DistMerge(DB_AGIN_Baccarat_Tbl tblOrg, DB_AGIN_Baccarat_Tbl tblNew, int distMax)
        {
            int  dist   = 0;
            bool merged = 0 == tblOrg.TotalCol; // For: Can merge with origin was empty

            for (int x_new = tblNew.TotalCol - 1; x_new > -1; x_new--)
            {
                // For: Determine distance, for new
                dist = tblNew.TotalCol - 1 - x_new;
                if (distMax < dist) // For: Distance too far, not merge
                {
                    break;
                }
                // For: Determine min index, for origin
                int x_org_min = tblOrg.TotalCol - tblNew.TotalCol + dist;
                if (0 > x_org_min) // For: Columns not enough, ignore it
                {
                    continue;
                }
                // For: Check cells were order, for origin
                bool flag = true;
                for (int x_org = tblOrg.TotalCol - 1; x_org > x_org_min - 1; x_org--)
                {
                    for (int y_org = tblOrg.TotalRow - 1; y_org > -1; y_org--)
                    {
                        DB_AGIN_Baccarat_Cell cell_org = tblOrg.Cells[x_org][y_org];
                        DB_AGIN_Baccarat_Cell cell_new = tblNew.Cells[x_org - x_org_min][y_org];
                        string color_org = cell_org.Matches.Contains("circle-blue") ? "circle-blue" : cell_org.Matches.Contains("circle-red") ? "circle-red" : "";
                        string color_new = cell_new.Matches.Contains("circle-blue") ? "circle-blue" : cell_new.Matches.Contains("circle-red") ? "circle-red" : "";
                        if (0 != cell_org.Order && color_org != color_new) // For: Cell was order but different, ignore it
                        {
                            flag = false;
                            break;
                        }
                    }
                    if (!flag)
                    {
                        break;
                    }
                }
                if (flag) // For: Can merge with dist, for new
                {
                    merged = true; break;
                }
            }
            return(merged ? dist : -1);
        }
Example #3
0
 /// <summary>
 /// Description: Update values for latest-order | latest-order-circle | latest-order-x | latest-order-y | latest-order-xr | latest-order-yr properties
 /// </summary>
 public void UpdOrder(int latestOrder, string latestOrderCircle, int latestOrderX, int latestOrderY, int latestOrderXR, int latestOrderYR)
 {
     #region For: Get some values
     int    latest_order        = latestOrder;
     string latest_order_circle = latestOrderCircle;
     int    latest_order_x      = latestOrderX;
     int    latest_order_y      = latestOrderY;
     int    latest_order_xr     = latestOrderXR;
     int    latest_order_yr     = latestOrderYR;
     #endregion
     for (int x = 0; x < TotalCol; x++)
     {
         #region For: If current value less than latest-order-x, then ignore it to continue with other value
         if (x < latestOrderX)
         {
             continue;
         }
         #endregion
         for (int y = 0; y < TotalRow; y++)
         {
             #region For: If current value less than latest-order-y, then ignore it to continue with other value
             if (x == latestOrderX && y < latestOrderY)
             {
                 continue;
             }
             #endregion
             bool set_order                = false;
             DB_AGIN_Baccarat_Cell cell    = Cells[x][y];
             DB_AGIN_Baccarat_Cell cell_py = y - 1 > -1 ? Cells[x][y - 1] : null;
             bool go_to_vertical           = x == latestOrderX && y == latestOrderY;
             bool go_to_horizontal         = go_to_vertical && -1 != latestOrderXR && -1 != LatestOrderYR;
             if (!go_to_vertical && 2 > cell.Matches.Count) // For: Current cell was empty, break loop
             {
                 break;
             }
             if (!go_to_vertical && 0 == cell.Order && 0 == y) // For: Current cell was new, set order
             {
                 set_order           = true;
                 cell.Order          = ++latest_order;
                 latest_order_circle = cell.Matches.Contains("circle-blue") ? "circle-blue" : cell.Matches.Contains("circle-red") ? "circle-red" : "";
                 #region For: Set some values
                 latest_order_x  = x;
                 latest_order_y  = y;
                 latest_order_xr = -1;
                 latest_order_yr = -1;
                 #endregion
             }
             if (!go_to_vertical && 0 == cell.Order && cell.Matches.Contains(latest_order_circle)) // For: Current cell was valid, set order
             {
                 set_order           = true;
                 cell.Order          = ++latest_order;
                 latest_order_circle = cell.Matches.Contains("circle-blue") ? "circle-blue" : "circle-red";
                 #region For: Set some values
                 latest_order_x  = x;
                 latest_order_y  = y;
                 latest_order_xr = -1;
                 latest_order_yr = -1;
                 #endregion
             }
             // if (go_to_horizontal || 0 != cell.Order && !set_order || TotalRow - 1 == y && set_order) // For: Current cell was order or max index, consider right side
             if (!go_to_vertical && (0 != cell.Order && !set_order || TotalRow - 1 == y && set_order) ||
                 go_to_vertical && (go_to_horizontal || 0 != cell.Order && null != cell_py && latestOrder == cell_py.Order || TotalRow - 1 == y && latestOrder == cell.Order))  // For: Current cell was order or max index, consider right side
             {
                 int y_r = go_to_horizontal ? latestOrderYR :
                           !go_to_vertical && 0 != cell.Order && !set_order || go_to_vertical && 0 != cell.Order && null != cell_py && latestOrder == cell_py.Order ? y - 1 : y;
                 if (-1 != y_r) // For: Coordinate-y of right side was wrong, ignore this case
                 {
                     for (int x_r = x + 1; x_r < TotalCol; x_r++)
                     {
                         #region For: If current value less than or equal latest-order-xr, then ignore it to continue with other value
                         if (x_r <= latestOrderXR)
                         {
                             continue;
                         }
                         #endregion
                         var cell_r = Cells[x_r][y_r];
                         if (!cell_r.Matches.Contains(latest_order_circle)) // For: Right cell was invalid, break loop
                         {
                             break;
                         }
                         var order_confuse = true; // For: Order can confuse, not sure about this check
                         for (int y_c = y_r - 1; y_c > -1; y_c++)
                         {
                             var cell_c = Cells[x_r][y_c];
                             if (!cell_c.Matches.Contains(latest_order_circle) || x_r < TotalCol && Cells[x_r + 1][y_c].Matches.Contains(latest_order_circle))
                             {
                                 order_confuse = false;
                                 break;
                             }
                         }
                         cell_r.Order        = ++latest_order;
                         cell_r.OrderConfuse = order_confuse;
                         #region For: Set some values
                         latest_order_x  = x;
                         latest_order_y  = y;
                         latest_order_xr = x_r;
                         latest_order_yr = y_r;
                         #endregion
                     }
                 }
                 break;
             }
         }
     }
     #region For: Set some values
     LatestOrder       = latest_order;
     LatestOrderCircle = latest_order_circle;
     LatestOrderX      = latest_order_x;
     LatestOrderY      = latest_order_y;
     LatestOrderXR     = latest_order_xr;
     LatestOrderYR     = latest_order_yr;
     #endregion
 }