private void ApplyClue(CardInHand card, ClueType clue) { var thought = GetThoughtsAboutCard(card); thought.Clues.Add(clue); clue.Accept(thought.Guess); }
private int CardsToClue(ClueType clue) { if (clue == null) { throw new ArgumentNullException(nameof(clue)); } return(_playerContext.Hand .Select(cih => cih.Card) .Where(_boardContext.GetWhateverToPlayCards().Contains) .Select(card => new ClueAndCardMatcher(card)) .Count(clue.Accept)); }
public static Clue Create(ClueType clueType, IEnumerable <CardInHand> hand) { if (clueType == null) { throw new ArgumentNullException(nameof(clueType)); } var result = new List <CardInHand>(); foreach (var cardInHand in hand) { var matcher = new ClueAndCardMatcher(cardInHand.Card); if (clueType.Accept(matcher)) { result.Add(cardInHand); } } var readOnlyCollection = new ReadOnlyCollectionBuilder <CardInHand>(result).ToReadOnlyCollection(); return(new Clue(clueType, readOnlyCollection)); }
public IClueSituationStrategy FindClueCandidate(IReadOnlyList <Player> players) { // поищем подсказки "на ход" var expectedCards = _boardContext.GetExpectedCards(); var expectedOneRankedCards = expectedCards.Where(card => card.Rank == Rank.One); if (expectedOneRankedCards.Any()) { var situation = FindClueToPlayOneRankedCard(players, expectedOneRankedCards); if (situation != null) { return(situation); } expectedCards = expectedCards.Except(expectedOneRankedCards); } foreach (var player in players) { var playerContext = new PlayerContext(player, player.ShowCards(_clueGiver)); ClueType clue = FindClueToPlay(playerContext, expectedCards); if (clue == null) { continue; } return(new OnlyClueExistsSituation(playerContext, clue)); } var uniqueCards = _boardContext.GetUniqueCards(); // поищем подсказки из серии "как бы чего не вышло" foreach (var player in players) { var playerContext = new PlayerContext(player, player.ShowCards(_clueGiver)); ClueType clue = FindClueToDiscard(playerContext, uniqueCards); if (clue == null) { continue; } return(new OnlyClueExistsSituation(playerContext, clue)); } // поищем подсказки из серии "на будущее" var whateverToPlayCards = _boardContext.GetWhateverToPlayCards(); foreach (var player in players) { var playerContext = new PlayerContext(player, player.ShowCards(_clueGiver)); ClueType clue = FindClueToWhateverPlay(playerContext, whateverToPlayCards); if (clue == null) { continue; } return(new OnlyClueExistsSituation(playerContext, clue)); } return(new ClueNotExistsSituation()); }
public OnlyClueExistsSituation(IPlayerContext playerContext, ClueType clueType) { _playerContext = playerContext; _clueType = clueType; }
private Clue(ClueType type, IReadOnlyCollection <CardInHand> cards) { Cards = cards; Type = type; }