Exemplo n.º 1
0
        public Battle(Player player1, Player player2, Label label)
        {
            Bounty             = new List <Card>();
            _label             = label;
            _player1           = player1;
            _player2           = player2;
            _player1BattleCard = _player1.PlayCard();
            _player2BattleCard = _player2.PlayCard();
            Bounty.Add(_player1BattleCard);
            Bounty.Add(_player2BattleCard);

            _label.Text += $"Battle Cards: {_player1BattleCard.Name} vs {_player2BattleCard.Name}</br>";

            if (GetBattleWinner() == "player1")
            {
                _player1.AddToBountyCount(2);
                DisplayBounty();
                _label.Text += "<b>Player 1 Wins!</b></br></br>";
            }
            else if (GetBattleWinner() == "player2")
            {
                _player2.AddToBountyCount(2);
                DisplayBounty();
                _label.Text += "<b>Player 2 Wins!</b></br></br>";
            }
            else if (GetBattleWinner() == "war")
            {
                War();
            }
        }
Exemplo n.º 2
0
        private void War()
        {
            var         winner    = false;
            List <Card> warBounty = new List <Card>();

            while (!winner)
            {
                _label.Text += "******** WAR ********</br></br>";
                warBounty.AddRange(_player1.PlayCard(2));
                warBounty.AddRange(_player2.PlayCard(2));

                var player1WarBattleCard = _player1.PlayCard();
                var player2WarBattleCard = _player2.PlayCard();

                warBounty.Add(player1WarBattleCard);
                warBounty.Add(player2WarBattleCard);

                Bounty.AddRange(warBounty);


                DisplayBounty();

                if (player1WarBattleCard.Value > player2WarBattleCard.Value)
                {
                    _player1.AddToBountyCount(warBounty.Count + 2);
                    _label.Text += "<b>Player 1 Wins!</b></br></br>";
                    winner       = true;
                }

                if (player1WarBattleCard.Value < player2WarBattleCard.Value)
                {
                    _player2.AddToBountyCount(warBounty.Count + 2);
                    _label.Text += "<b>Player 2 Wins!</b></br></br>";
                    winner       = true;
                }
            }
        }