示例#1
0
        public static string PrintWar(CardDeck player1Deck, CardDeck player2Deck)
        {
            // Determine how many wars, ie Double, Triple, etc...
            int wars = WarRound.HowManyCards(player1Deck, player2Deck);

            // Define cards to print
            List <Card> _cards = new List <Card>();

            for (int i = 0; i < (wars * 4 + 1); i++)
            {
                _cards.Add(player1Deck.Deck.ElementAt(i));
                _cards.Add(player2Deck.Deck.ElementAt(i));
            }

            // Resulting string with HTML imbedded
            return(string.Format(
                       "<div class=\"bg-warning rounded my-3 p-2 text-light text-center\">{0}" +
                       "<h5><strong class=\"{1} player\">{2}</strong> wins the WAR</h5></div>",
                       WarRound.PrintWarCards(_cards),
                       WarRound.PrintRoundWinnerCSSClass(_cards, wars),
                       WarRound.PrintRoundWinner(_cards, wars)));
        }
示例#2
0
        public static void War(CardDeck player1Deck, CardDeck player2Deck)
        {
            // Determine how many wars, ie Double, Triple, etc...
            int wars = WarRound.HowManyCards(player1Deck, player2Deck);

            // Define cards to print
            List <Card> _cards = new List <Card>();

            for (int i = 0; i < (wars * 4 + 1); i++)
            {
                _cards.Add(player1Deck.Deck.ElementAt(i));
                _cards.Add(player2Deck.Deck.ElementAt(i));
            }

            // Add cards from round to bottom of winners deck
            if (_cards.ElementAt(8 * wars).Rank > _cards.ElementAt(8 * wars + 1).Rank)
            {
                CardDeck.MoveCards(player1Deck, player2Deck, _cards);
            }
            else if (_cards.ElementAt(8 * wars).Rank < _cards.ElementAt(8 * wars + 1).Rank)
            {
                CardDeck.MoveCards(player2Deck, player1Deck, _cards);
            }
        }