Example #1
0
        protected void dealButton_Click(object sender, EventArgs e)
        {
            Battle battle  = new Battle();
            Player player1 = new Player();
            Player player2 = new Player();

            resultLabel.Text = "";
            Random random = new Random();

            Deck deck = new Deck();


            player1.Name = "Player 1";
            player2.Name = "Player 2";

            deck.Shuffle(random);

            deck.Deal(player1, player2);

            for (int i = 0; i < 20; i++)
            {
                resultLabel.Text += String.Format("<h2>Round {0}</h2>", i + 1);
                resultLabel.Text += battle.PerformBattle(player1, player2);
                resultLabel.Text += String.Format("Player 1 : {0}<br>Player 2 : {1}<br>",
                                                  player1.MyCards.Count, player2.MyCards.Count);
            }
        }
Example #2
0
        public string Play()
        {
            Deck deck = new Deck();


            string result = "<h3>Dealing cards ...</h3>";

            result += deck.Deal(_player1, _player2);

            result += "<h3>Begin Battle...</h3>";
            int round = 0;

            while (_player1.Cards.Count != 0 && _player2.Cards.Count != 0)
            {
                Battle battle = new Battle();
                result += battle.PerformBattle(_player1, _player2);


                round++;
                if (round > 20)
                {
                    break;
                }
            }
            result += determineWinner();
            return(result);
        }
Example #3
0
        public string Play()
        {
            Deck deck = new Deck();

            string result = "<h3>Dealing cards ...</h3>";
            result +=   deck.Deal(_player1, _player2);

            result += "<h3>Begin Battle...</h3>";
            int round = 0;

            while (_player1.Cards.Count != 0 && _player2.Cards.Count != 0)
            {
                Battle battle = new Battle();
                result += battle.PerformBattle(_player1, _player2);

                round++;
                if (round>20)
                    break;
            }
            result += determineWinner();
            return result;
        }