public Team(Player player1, Player player2) { _player2 = player2; _player1 = player1; _player2.Partner = _player1; _player1.Partner = _player2; }
public TestGameDetermineWinner() { logger = new NoopLogger(); // Generation of players has been moved out of Game, so this logic // is duplicated in these tests and the Program class. player1InContract = new NaiveFirstCardPlayer(string.Empty); player2InContract = new NaiveFirstCardPlayer(string.Empty); player1NotInContract = new NaiveFirstCardPlayer(string.Empty); player2NotInContract = new NaiveFirstCardPlayer(string.Empty); player1InContract.Next = player1NotInContract; player1NotInContract.Next = player2InContract; player2InContract.Next = player2NotInContract; player2NotInContract.Next = player1InContract; teamInContract = new Team(player1InContract, player2InContract); teamNotInContract = new Team(player1NotInContract, player2NotInContract); contract = new Contract(teamInContract, 1, Suit.Spades); game = new Game(new[] { teamInContract, teamNotInContract }, contract, new Deck(), logger); }
public CardPlayed(Player player, Card card) { Player = player; Card = card; }
private CardsPlayedCollection PlayRound(Player current) { var cardsPlayed = new CardsPlayedCollection(); for (var i = 0; i < _numberOfPlayers; i++) { cardsPlayed.Add(new CardPlayed(current, current.Play(cardsPlayed))); current = current.Next; } return cardsPlayed; }
private void PlayGame(Player lead) { var current = lead; for (var i = 0; i < 13; i++) { var cardsPlayed = PlayRound(current); var winner = DetermineWinner(cardsPlayed); var trick = new Trick(lead, cardsPlayed, winner); ReviewTrick(trick); winner.WinTrick(trick); _logger.InfoFormat("{0} won trick {1} ({2}) with {3}", winner, i + 1, trick, cardsPlayed[winner]); current = winner; } }
private static void Deal(IEnumerable<Card> deck, Player target) { foreach (Card t in deck) { target.AddCardToHand(t); target = target.Next; } }