Beispiel #1
0
        /// <summary>
        /// To perform this action, the player must remove a blue counter from the tin lid
        /// (and place it next to it, with the red counters). They can then give a clue to one of the other players
        /// about the cards they hold.
        /// The player must indicate clearly - by pointing - which cards he is offering a clue about.
        /// A player must give a full clue: e.g. if a player has two yellow cards, the clue-giver must not indicate only one!
        /// </summary>
        public bool OfferClue()
        {
            if (ClueCounter == 0)
            {
                return(false);
            }

            if (_game.Deck.IsEmpty() && !_game.GetPlayersToTurn(this).Any())
            {
                return(false);
            }

            var           otherPlayerCards = GetOtherPlayersCards().Select(cih => cih.Card).Concat(GetKnownCards());
            IClueStrategy strategy;
            IBoardContext boardContext = new BoardContext.Builder()
                                         .WithBoard(_game.Board)
                                         .WithPilesAnalyzer(_pilesAnalyzer)
                                         .WithOtherPlayersCards(otherPlayerCards)
                                         .Build();

            if (ClueCounter == 1)
            {
                strategy = new LastTinClueStrategy(this, boardContext, GameProvider, otherPlayerCards);
            }
            else
            {
                strategy = new ManyTinClueStrategy(this, boardContext);
            }

            var solution      = strategy.FindClueCandidate(_game.GetPlayersToTurn(this));
            var clueCandidate = solution.GetClueCandidate();

            if (clueCandidate == null)
            {
                Logger.Log.Info(String.Format($"Player {Name} has to discard, because there isn't a clue"));
                return(false);
            }

            GiveClue(clueCandidate.Candidate, clueCandidate.Clue);
            return(true);
        }
Beispiel #2
0
        public IBoardContext ChangeContext(IEnumerable <Card> otherPlayerCards)
        {
            var newContext =
                new BoardContext.Builder()
                .WithFireworkPile(_fireworkPile)
                .WithDiscardPile(_discardPile)
                .WithPilesAnalyzer(_pilesAnalyzer)
                .WithOtherPlayersCards(otherPlayerCards)
                .WithBlowCounter(BlowCounter)
                .Build();

            foreach (var card in _possiblePlayed)
            {
                newContext.AddToFirework(card);
            }

            foreach (var card in _possibleDiscarded)
            {
                newContext.Discard(card);
            }

            return(newContext);
        }