Example #1
0
        public static IList <Carta> EncontraStraightFlush(Carta [] Cartas)
        {
            IList <Carta> sflush = Straight.Encontra(Cartas);

            if (sflush == null)
            {
                return(null);
            }



            return(null);
        }
Example #2
0
        internal bool GetStraigth(IList <Carta> CartasAvaliar, out IList <Carta> Straight)
        {
            Straight = new List <Carta>();
            int NumAs = CartasAvaliar.Count - 1;

            // Corrige o Problema do As
            IList <Carta> CartasAvaliarAuxiliar = new List <Carta>();

            while (CartasAvaliar[NumAs].Numero == 14)
            {
                CartasAvaliarAuxiliar.Add(
                    new Carta(1, CartasAvaliar[NumAs].Naipe)
                    );
                NumAs--;
            }
            if (NumAs != CartasAvaliar.Count - 1)
            {
                CartasAvaliarAuxiliar = CartasAvaliarAuxiliar.Concat(CartasAvaliar).ToList();
            }
            else
            {
                CartasAvaliarAuxiliar = CartasAvaliar;
            }

            Straight.Add(CartasAvaliarAuxiliar[CartasAvaliarAuxiliar.Count - 1]);

            for (int i = CartasAvaliarAuxiliar.Count - 1; i > -1; i--)
            {
                if (i == 0)
                {
                    Straight = new List <Carta>();
                    return(false);
                }

                // Ignora cartas iguais
                if (CartasAvaliarAuxiliar[i].Numero == CartasAvaliarAuxiliar[i - 1].Numero)
                {
                    continue;
                }

                if (CartasAvaliarAuxiliar[i].Numero == CartasAvaliarAuxiliar[i - 1].Numero + 1)
                {
                    Straight.Add(CartasAvaliarAuxiliar[i - 1]);
                    if (Straight.Count == 5)
                    {
                        return(true);
                    }
                }
                else
                {
                    if (i < 4)
                    {
                        return(false);
                    }
                    Straight = new List <Carta>()
                    {
                        CartasAvaliarAuxiliar[i - 1]
                    };
                }
            }

            return(false);
        }