Exemple #1
0
        public static ExtendendList <Structure> CreateStructureList(Game currentGame)
        {
            ExtendendList <Cart>       mCarts = Class.Cart.CreateNewCarts(currentGame.GameMode);
            ExtendendList <Structure>  mStructures = new ExtendendList <Class.Structure>();
            ExtendendList <Class.Cart> tmpLst = new ExtendendList <Class.Cart>();
            int index = 0, ct = 0;

            for (int i = 0; i <= 9; i++)
            {
                Structure.SType cType  = (i >= 4) ? Structure.SType.Five : SType.Six;
                Structure       str    = new Structure(null, cType);
                int             cCards = (i >= 4) ? 5 : 6;
                for (int c = 0; c <= cCards - 1; c++)
                {
                    Cart curCart = mCarts[index];
                    //  curCart.owner = str;
                    if (c == cCards - 1)
                    {
                        curCart.Active = true;
                    }
                    tmpLst.Add(curCart);
                    index++;
                    ct++;
                }
                str.lstCards = tmpLst.Clone();
                tmpLst.Clear();
                mStructures.Add(str);
            }

            currentGame.OtherCards.Clear();
            for (int c = ct; c <= mCarts.Count - 1; c++)
            {
                currentGame.OtherCards.Add(mCarts[c]);
            }
            return(mStructures);
        }
Exemple #2
0
        public static ExtendendList <Tipp> ShowsAllTipps(ExtendendList <Structure> lst)
        {
            ExtendendList <Tipp> toReturn = new ExtendendList <Tipp>();

            foreach (Structure ms in lst)
            {
                ExtendendList <Cart> active = new ExtendendList <Cart>();
                foreach (Cart cmr in ms.lstCards)
                {
                    if (cmr.Active)
                    {
                        active.Add(cmr);
                    }
                }
                ExtendendList <Cart> proove  = new ExtendendList <Cart>();
                ExtendendList <Cart> testLst = new ExtendendList <Cart>();
                bool okay = false;
                for (int i = 0; i <= active.Count - 1; i++)
                {
                    proove.Clear();
                    for (int j = i; j <= active.Count - 1; j++)
                    {
                        proove.Add(active[j]);
                    }

                    okay = Structure.CanMoveCards(proove);
                    if (proove.Count != 1 && okay)
                    {
                        // If you try to switch more than one card, all cards have to be the same color.
                        Cart.GameMode currentMode = Cart.GameMode.Black;
                        bool          ok          = false;
                        for (int y = 0; y <= proove.Count - 1; y++)
                        {
                            if (y == 0)
                            {
                                currentMode = proove[y].GameMode_;
                            }
                            else
                            {
                                if (currentMode != proove[y].GameMode_)
                                {
                                    ok = false;
                                    break;
                                }
                            }
                        }
                        okay = ok;
                    }
                    if (okay)
                    {
                        // At first, we have have to check out, whether the structure fits to the last cart from another structure!
                        bool goOn = false;
                        foreach (Structure d1 in lst)
                        {
                            if (d1.lstCards.Count == 0)
                            {
                                goOn = true;
                            }
                            else
                            {
                                testLst.Clear();
                                testLst.Add(d1.lstCards[d1.lstCards.Count - 1]);
                                testLst.AddRange(proove);
                                goOn = Structure.CanMoveCards(testLst);
                                if (goOn)
                                {
                                    foreach (Cart cs1 in testLst)
                                    {
                                        cs1.IsTipp = true;
                                    }
                                }
                            }
                            if (goOn)
                            {
                                if (testLst.Count != 0)
                                {
                                    foreach (Cart cs1 in proove)
                                    {
                                        cs1.IsTipp = true;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(toReturn);
        }