/// <summary> /// Obtiene las 5 cartas para jugar. /// </summary> /// <returns></returns> public static PokerCard[] GetCards() { int sizeCard = 1; listCard = new List <PokerCard>(); while (sizeCard <= 5) { PokerCard randomCard = PokerCard.GetCardRandom(); if (AddPokerCard(randomCard)) { sizeCard++; } } return(listCard.ToArray()); }
/// <summary> /// agrega las cartas a listado de cartas disponibles /// </summary> /// <param name="Card"> Carta para agregar</param> /// <returns></returns> public static bool AddPokerCard(PokerCard Card) { List <PokerCard> CardsFind = listCard .Where(x => x.Number == Card.Number && x.Symbol == Card.Symbol) .ToList(); if (CardsFind == null || CardsFind.Count() <= 0) { listCard.Add(Card); listResumen.Add(Card); } else { return(false); } return(true); }
/// <summary> /// Obtiene de forma random una carta. /// </summary> /// <returns></returns> public static PokerCard GetCardRandom() { Random RndCard = new Random((int)DateTime.Now.Ticks & 0x0000FFFF); int Symbol = RndCard.Next(1, 5); RndCard = new Random((int)DateTime.Now.Ticks & 0x0000FFFF); int Number = RndCard.Next(2, 15); PokerCard Card = new PokerCard(); Card.Number = Number; Card.Symbol = (CardSymbol)Symbol; Card.ImageName = GetImage(Card.Symbol, Card.Number); return(Card); }