// Logic for a single round
 public void PlaySingleRound()
 {
     wars = (int)ViewState["Wars"];
     if (player1Deck.Deck.Count() >= 10 || player2Deck.Deck.Count() >= 10)
     {
         if (player1Deck.Deck.ElementAt(0).Rank == player2Deck.Deck.ElementAt(0).Rank)
         {
             // Actions for a round of war
             resultLabel.Text += WarRound.PrintWar(player1Deck, player2Deck);
             WarRound.War(player1Deck, player2Deck);
             ViewState["Wars"] = ++wars;
             StoreDecks();
         }
         else
         {
             // Actions for a normal round
             resultLabel.Text += RegularRound.PrintRound(player1Deck, player2Deck);
             RegularRound.Fight(player1Deck, player2Deck);
             StoreDecks();
         }
     }
     else
     {
         PrintWinner();
     }
 }
Beispiel #2
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)));
        }
Beispiel #3
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);
            }
        }