Esempio n. 1
0
        public void CopyMoves(ref cMoveClass cMC)
        {
            cMoveData cmd;
            cMoveInfo cmi;

            TheseMoves.Clear();
            ThisMoveInfo.Clear();
            for (int i = 0; i < cMC.TheseMoves.Count; i++)
            {
                cMoveData dcMC = cMC.TheseMoves[i];
                cmd            = new cMoveData(dcMC.ID, dcMC.Src, dcMC.Des, dcMC.Score, dcMC.bWasFacedown, dcMC.NumMoved);
                cmd.ShrinkCode = dcMC.ShrinkCode;
                cmd.WhereInfo  = dcMC.WhereInfo;
                TheseMoves.Add(cmd);
            }
            for (int i = 0; i < cMC.ThisMoveInfo.Count; i++)
            {
                cmi                 = new cMoveInfo();
                cmi.deal            = cMC.ThisMoveInfo[i].deal;
                cmi.id              = cMC.ThisMoveInfo[i].id;
                cmi.MinutesLastDeal = cMC.ThisMoveInfo[i].MinutesLastDeal;
                cmi.suit            = cMC.ThisMoveInfo[i].suit;
                cmi.suiter          = cMC.ThisMoveInfo[i].suiter;
                cmi.score           = cMC.ThisMoveInfo[i].score;
                cmi.TimeOfMove      = cMC.ThisMoveInfo[i].TimeOfMove;
                ThisMoveInfo.Add(cmi);
            }
            InitialCardTime = cMC.InitialCardTime;
            LastBuildTime   = cMC.LastBuildTime;
            LastDealTime    = cMC.LastDealTime;
            bOnFirstBuild   = cMC.bOnFirstBuild;
            bOnFirstDeal    = cMC.bOnFirstDeal;
        }
Esempio n. 2
0
        //public static string CVTMoveValueToText(cMoveData cMD)
        //{
        //    string strText;
        //    int CardType;
        //    int irank, isuit, src, des;
        //    CardType = cMD.ID;
        //    if (CardType > 51)
        //        CardType -= 52;
        //    isuit = GlobalClass.cRST[CardType].suit;
        //    irank = GlobalClass.cRST[CardType].rank;
        //    des = cMD.Des;
        //    src = cMD.Src;
        //    string strInfo = "";
        //    string strNumMoved = (cMD.NumMoved == 1) ? "" : cMD.NumMoved.ToString();
        //    if (cMD.bWasFacedown)
        //    {
        //        if (cMD.NumMoved == 1)
        //            strInfo = "[f]";
        //        else strInfo = "[f" + cMD.NumMoved.ToString() + "]";
        //    }
        //    else if (cMD.NumMoved > 1)
        //        strInfo = "[" + cMD.NumMoved.ToString() + "]";

        //    strText = utils.GetFormattedName(isuit, irank, true) + " " + (src + 1) + "->" + (des + 1);
        //    return utils.Rpadto(strText, 10) + strInfo;
        //}


        public static string CVTMoveValueToText(cMoveData cMD, string SuitCompleted)
        {
            string strText;
            int    CardType;
            int    irank, isuit, src, des;

            CardType = cMD.ID;
            if (CardType > 51)
            {
                CardType -= 52;
            }
            isuit = GlobalClass.cRST[CardType].suit;
            irank = GlobalClass.cRST[CardType].rank;
            des   = cMD.Des;
            src   = cMD.Src;
            // jys 8nov2012
            des++; if (des == 10)
            {
                des = 0;
            }
            src++; if (src == 10)
            {
                src = 0;
            }
            string strInfo = "";

#if SHOW_FACE_INFO
            string strNumMoved = (cMD.NumMoved == 1) ? "" : cMD.NumMoved.ToString();
            if (cMD.bWasFacedown)
            {
                if (cMD.NumMoved == 1)
                {
                    strInfo = "[f]";
                }
                else
                {
                    strInfo = "[f" + cMD.NumMoved.ToString() + "]";
                }
            }
            else if (cMD.NumMoved > 1)
            {
                strInfo = "[" + cMD.NumMoved.ToString() + "]";
            }

            strInfo = utils.Rpadto(strInfo, 5);
#endif

            if (cMD.ShrinkCode != "")
            {
                strInfo = "[" + cMD.ShrinkCode + "]";
            }
            if (SuitCompleted == "")
            {
                SuitCompleted = utils.Lpadto(cMD.Score.ToString(), 5) + strInfo;
            }
            strText = utils.GetFormattedName(isuit, irank, true) + " " + (src) + "-" + (des);
            return(utils.Rpadto(strText, 7) + SuitCompleted);
        }
Esempio n. 3
0
        public static pseudoCard CVTMoveValueToInfo(cMoveData cMD)
        {
            pseudoCard pCard = new pseudoCard(cMD.ID);

            pCard.score           = cMD.Score;
            pCard.desID           = cMD.Des;
            pCard.iStack          = cMD.Src;
            pCard.desID_is_iStack = true;
            return(pCard);
        }
Esempio n. 4
0
        /*
         * fixes problems such as
         * JD 3->6  [s]  (uncovered card had same suit as the 3)
         * JD 6->3  [s]  (uncovered card had same suit as the 6)
         * the above cannot be replaced if it was used to expose a card
         * otherwise BOTH can be deleted
         *
         * AC 9->3       if suits uncovered are different ..
         * AC 6->9       if cards above were already
         * the above can be replace with AC 6->3 only if
         * no cards were exposed
         *
         * the number of cards moved are the same (1)
         *
         * */
        public bool IsLastMoveDuplicated(ref cMoveData cMD)
        {
            int n = TheseMoves.Count - 1;

            if (n < 0)
            {
                return(false);
            }
            cMoveData LastMove = TheseMoves[n];
            bool      bIsDup   = false;


            return(bIsDup);
        }
Esempio n. 5
0
        public void AddMove(int CardID, int srcStack, int desStack, int score, bool bSameSuit, int NumMoved)
        {
            int       i, j, n, m = 24, v1, v2, t = 0, NumMoves;
            cMoveData cMD = new cMoveData(CardID, srcStack, desStack, score, bSameSuit, NumMoved);

            TheseMoves.Add(cMD);
            NumMoves = TheseMoves.Count;
            if (NumMoves > m)
            {
                n = NumMoves - m;   // last move to test is NumMoves-1 and first to test is NumMoves-16
                for (i = 0; i < (m - 1); i++)
                {
                    v1 = TheseMoves[n + i].ID;
                    for (j = i + 1; j < m; j++)
                    {
                        v2 = TheseMoves[n + j].ID;
                        if (v1 == v2)
                        {
                            t++;            // increment total duplicate move count
                        }
                    }
                }
                // use 35 with m=16 or 84 with m=24
                if (t < 84)
                {
                    return;         // see test program:  catches a pattern of 3 or less moves repeating
                }
                Debug.Assert(true);
                Console.WriteLine("Runaway moves?  t:" + t);
                TraceBoard();
                for (i = 0; i < m; i++)
                {
                    Console.Write("{0:X} ", TheseMoves[n + i].ID);
                }
                Console.WriteLine("");
                GlobalClass.Runaway_Moves.Data.Add("MSG", "Runaway moves!  moves are repeating");
                throw GlobalClass.Runaway_Moves;
            }
        }
Esempio n. 6
0
        //  this displays the board in a console (null) or writes to a file (sw not null)
        public string TraceBoard(StreamWriter sw)
        {
            int i, j, k, e, r, NumMoves = TheseMoves.Count;
            int MaxRows = TheseMoves.Count + 10; // leave room for info such as "Deal" after the move statements
            int padSize = 19;                    // can use 13 if we abbreviate diamonds to diamon

            char[] charsToTrim = { ' ' };
            int    nInfo       = 0;
            string strMove;
            string strAccumulate = "";

            string[,] page = new string[6, MaxRows];
            int[]    lCnt        = new int[6];
            string[] strMoveInfo = null;

            for (i = 0; i < 6; i++)
            {
                for (j = 0; j < MaxRows; j++)
                {
                    page[i, j] = utils.Rpadto(" ", padSize);
                }
                lCnt[i] = 0;
            }

            e = 0;
            r = 0;
            for (i = 0; i < TheseMoves.Count; i++)
            {
                cMoveData cMD = TheseMoves[i];
                if (cMD.WhereInfo >= 0)
                {
                    nInfo = HasInfo(cMD.WhereInfo, ref strMoveInfo);
                }
                else
                {
                    nInfo = 0;
                }
                string strTemp = "";
                if (nInfo == 3)
                {
                    strTemp = strMoveInfo[0];
                }
                strMove    = utils.CVTMoveValueToText(cMD, strTemp);
                page[e, r] = utils.Rpadto(strMove, padSize);
                lCnt[e]++;
                r++;
                if (nInfo == 2)
                {
                    Debug.Assert(strMoveInfo != null);
                    for (j = 0; j < strMoveInfo.Length; j++)
                    {
                        page[e, r] = utils.Rpadto(strMoveInfo[j], padSize);
                        lCnt[e]++;
                        r++;
                    }
                    if (nInfo == 2)
                    {
                        e++;
                        r = 0;
                    }
                }
            }

            k = 0;
            for (i = 0; i < 6; i++)
            {
                if (k < lCnt[i])
                {
                    k = lCnt[i];
                }
            }

            for (i = 0; i < k; i++)
            {
                strMove = utils.Lpadto(i.ToString(), 3) + " ";
                for (j = 0; j < 6; j++)
                {
                    strMove += page[j, i];
                }
                strMove = strMove.TrimEnd(charsToTrim);
                if (sw == null)
                {
                    strAccumulate += strMove + "\r\n";
                }
                else
                {
                    sw.WriteLine(strMove);
                }
            }
            if (sw == null)
            {
                return(strAccumulate);
            }
            return("");
        }
Esempio n. 7
0
        // on FIRST_CARD vInfo is the number of deals, if any, before the first card
        // on BUILT_SUIT vInfo is the suit and vInfo1 the id of the suit builder
        // on DEALT_CARD vInfo is the score and vInfo1 is the dealcounter
        public void AddMoveInfo(int iInfo, int vInfo, int vInfo1)
        {
            cMoveInfo thisMI = new cMoveInfo();

            switch (iInfo)
            {
            case GlobalClass.FIRST_CARD:
                InitialCardTime = DateTime.Now;
                return;                    // cannot add anything since there have been no cards moved.  just record time

            case GlobalClass.DEALT_A_CARD: // is always appended to the last move

                thisMI.score      = vInfo;
                thisMI.deal       = vInfo1;
                thisMI.TimeOfMove = DateTime.Now;
                if (bOnFirstDeal)
                {
                    LastDealTime = InitialCardTime;
                }
                ts = thisMI.TimeOfMove.Subtract(LastDealTime);
                thisMI.MinutesLastDeal = Convert.ToInt32(ts.TotalMinutes);
                LastDealTime           = thisMI.TimeOfMove;
                bOnFirstDeal           = false;
                break;

            case GlobalClass.BUILT_SUIT:      // is always appended to the last move
                thisMI.suit       = vInfo;
                thisMI.suiter     = vInfo1;
                thisMI.TimeOfMove = DateTime.Now;
                if (bOnFirstBuild)
                {
                    LastBuildTime = InitialCardTime;
                }
                ts = thisMI.TimeOfMove.Subtract(LastBuildTime);
                thisMI.MinutesLastDeal = Convert.ToInt32(ts.TotalMinutes);
                LastBuildTime          = thisMI.TimeOfMove;
                bOnFirstBuild          = false;
                break;

            default: Debug.Assert(false);
                break;
            }
            thisMI.id = iInfo;
            // jys nov2012 the problem is the deal is not added if there are no moves!!!!
            // cannot append if there are no moves
            if (TheseMoves.Count > 0)
            {
                TheseMoves[TheseMoves.Count - 1].WhereInfo = ThisMoveInfo.Count;
            }
            else
            {
                if (iInfo == GlobalClass.DEALT_A_CARD)
                {
                    cMoveData cm = new cMoveData(GlobalClass.DEALT_A_CARD, -1, -1, -1, true, 0);
                    TheseMoves.Add(cm);
                    TheseMoves[TheseMoves.Count - 1].WhereInfo = ThisMoveInfo.Count;
                }
            }
            if (ThisMoveInfo.Count > 0) // THIS CODE IS FOR DEBUGGING (BREAKPOINTS)
            {
                int iCnt = ThisMoveInfo.Count - 1;
                if (ThisMoveInfo[iCnt].id == GlobalClass.DEALT_A_CARD && thisMI.id == GlobalClass.DEALT_A_CARD)
                {
                    iCnt = 0;
                }
            }
            ThisMoveInfo.Add(thisMI);
        }
Esempio n. 8
0
 public static int GetIDFromMoveValue(cMoveData cMD)
 {
     return(cMD.ID);   // 0..103
 }