Esempio n. 1
0
        public void AttachToStack(CardStack s)
        {
            var c = this;

            if (c.CurrentStack != null)
            {
                c.CurrentStack.Cards.Remove(c);
            }

            c.CurrentStack = s;

            s.Cards.Add(c);

            Helper.Invoke(this.Moved);
        }
Esempio n. 2
0
        public void AttachToStack(CardStack s)
        {
            var c = this;

            if (c.CurrentStack != null)
            {
                c.CurrentStack.Cards.Remove(c);
            }

            c.CurrentStack = s;

            s.Cards.Add(c);

            Helper.Invoke(this.Moved);
        }
Esempio n. 3
0
        private Card[] GetGoodSuit(CardStack s)
        {
            if (!PlayStacks.Contains(s))
                return null;


            var xx = s.Cards.Range(s.Cards.Count - 13, 13);

            if (xx.Length != 13)
            {
                return null;
            }

            var p = xx.First();

            if (p == null)
                throw new System.Exception("First card is null");

            var z = xx.Last();

            if (z == null)
                throw new System.Exception("Last card is null");

            if (p.ModifiedRank != (int)SpiderRankEnum.RankKing)
            {
                System.Console.WriteLine("first isnt king...");

                return null;

            }
            if (z.ModifiedRank != (int)SpiderRankEnum.RankAce)
            {
                System.Console.WriteLine("last isnt ace...");

                return null;

            }



            System.Console.WriteLine("checking for good suit...");

            var r = true;

            var arr = xx/*.ToArray()*/;

            Card u = null;

            foreach (Card c in arr)
            {
                if (u != null)
                {

                    if (u.Info.Suit != c.Info.Suit)
                    {
                        System.Console.WriteLine("bad suit...");


                        arr = null;
                        break;
                    }

                    if (u.IsParentRankOf(c))
                    {
                        System.Console.WriteLine("rank mismatch");

                        arr = null;
                        break;
                    }
                }

                u = c;
            }


            return arr;
        }
Esempio n. 4
0
        private void CheckForGoodSuit(CardStack s)
        {
            var gs = GetGoodSuit(s);

            if (gs != null)
            {
                System.Console.WriteLine("got good suit...");

                MyStatus.Score += 100;
                MyStatus.Update();

                var sxx = DeadStacks.Last();

                MyStatus.Ready = false;

                CardStack.CardByCard(
                    delegate(Pair<Card, System.Action> p)
                    {
                        if (p.A == null)
                        {
                            MyStatus.Ready = true;


                            DeadStacks.Add(
                                new CardStack(sxx.Position + new Point(0, 4))
                            );

                            CheckForWin();

                            s.RevealLastCard();
                        }
                        else
                        {
                            MySounds.PlaySoundDeal();

                            p.A.AttachToStack(sxx);

                            p.A.BringToFront();

                            sxx.MoveSlow(p.A, p.B);
                        }
                    }
                    , gs);
            }
        }
Esempio n. 5
0
        public static bool IsStackTypeAndDoesNotFit(Card c, IEnumerable<CardStack> s, CardStack p, System.Action<Predicate<CardStack, Card>> h)
        {
            if (s.Count(i => i == p) > 0)
            {
                if (!Predicate.Invoke(p, c, h))
                    return true;
            }

            return false;
        }