public bool PlayRound() { if (!CanContinue()) { return(false); } //Play cards, add them to winnings and compare Card a = p1.PlayCard(true); Card b = p2.PlayCard(true); winnings.Add(a); winnings.Add(b); if (a.value > b.value) { p1.WinHand(winnings); winnings.Clear(); } else if (b.value > a.value) { p2.WinHand(winnings); winnings.Clear(); } else { return(CardWar()); } return(CanContinue()); }
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(); } }
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; } } }
public List <Card> PlayCards(Player player, int amountOfCards) { return(player.PlayCard(amountOfCards)); }
public Card PlayCard(Player player) { return(player.PlayCard()); }