public PlayAction PlayCard() { // Since this is a dummy player he will randomly return one of the possible cards // TODO: Ask for the list of allowed cards var cardToPlay = this.cards[RandomProvider.Next(0, this.cards.Count)]; this.cards.Remove(cardToPlay); var action = new PlayAction { Card = cardToPlay }; return action; }
public CardPlayedEventArgs(PlayerPosition position, PlayAction playAction, IEnumerable<Card> currentTrickCards) { this.Position = position; this.PlayAction = playAction; this.CurrentTrickCards = currentTrickCards; }
public PlayAction PlayCard(IList<Card> allowedCards, IList<Card> currentTrickCards) { var sb = new StringBuilder(); var allowedCardsList = new CardsCollection(allowedCards); allowedCardsList.Sort(this.Contract.Type); for (int i = 0; i < allowedCardsList.Count; i++) { sb.AppendFormat("{0}({1}); ", i + 1, allowedCardsList[i]); } // this.Draw(); while (true) { var action = new PlayAction(); ConsoleHelper.WriteOnPosition(new string(' ', 78), 0, Settings.ConsoleHeight - 3); ConsoleHelper.WriteOnPosition(new string(' ', 78), 0, Settings.ConsoleHeight - 2); ConsoleHelper.WriteOnPosition(sb.ToString().Trim(), 0, Settings.ConsoleHeight - 2); ConsoleHelper.WriteOnPosition("It's your turn! Please select card to play: ", 0, Settings.ConsoleHeight - 3); var cardIndexAsString = Console.ReadLine(); int cardIndex; if (int.TryParse(cardIndexAsString, out cardIndex)) { if (cardIndex > 0 && cardIndex <= allowedCardsList.Count) { var cardToPlay = allowedCardsList[cardIndex - 1]; action.Card = cardToPlay; if (this.hand.IsBeloteAllowed(Contract, currentTrickCards, cardToPlay)) { ConsoleHelper.WriteOnPosition(new string(' ', 78), 0, Settings.ConsoleHeight - 3); ConsoleHelper.WriteOnPosition(new string(' ', 78), 0, Settings.ConsoleHeight - 2); ConsoleHelper.WriteOnPosition(new string(' ', 78), 0, Settings.ConsoleHeight - 1); ConsoleHelper.WriteOnPosition("Y(es) / N(o)", 0, Settings.ConsoleHeight - 2); ConsoleHelper.WriteOnPosition("You have belote! Do you want to announce it? Y/N ", 0, Settings.ConsoleHeight - 3); var answer = Console.ReadLine(); if (!string.IsNullOrWhiteSpace(answer) && answer.Trim()[0] == 'N') { action.AnnounceBeloteIfAvailable = false; } } this.hand.Remove(cardToPlay); return action; } } } }
public CardPlayedEventArgs(PlayerPosition position, PlayAction playAction, IEnumerable <Card> currentTrickCards) { this.Position = position; this.PlayAction = playAction; this.CurrentTrickCards = currentTrickCards; }