示例#1
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);
        }