コード例 #1
0
ファイル: Player.cs プロジェクト: IvanovAndrew/Hanabi
        public void ListenClue(Clue clue)
        {
            if (clue == null)
            {
                throw new ArgumentNullException(nameof(clue));
            }
            if (!clue.Type.IsStraightClue)
            {
                throw new IncorrectClueException("You can give clues only about Rank IS or Nominal IS type");
            }

            // эвристика
            if (clue.IsSubtleClue(FireworkPile.GetExpectedCards()))
            {
                Logger.Log.Info("It's a subtle clue");
                _specialCards.Add(clue.Cards.First());
            }

            _memory.Update(clue);
        }
コード例 #2
0
        public void Update(Clue clue)
        {
            if (clue == null)
            {
                throw new ArgumentNullException(nameof(clue));
            }

            foreach (CardInHand card in clue.Cards)
            {
                ApplyClue(card, clue.Type);
            }

            IEnumerable <CardInHand> otherCards = _thoughts
                                                  .Select(thought => thought.CardInHand);

            Clue revertedClue = Clue.Revert(clue, otherCards);

            foreach (CardInHand otherCard in revertedClue.Cards)
            {
                ApplyClue(otherCard, revertedClue.Type);
            }
        }
コード例 #3
0
ファイル: Player.cs プロジェクト: IvanovAndrew/Hanabi
        private void GiveClue(Player playerToClue, Clue clue)
        {
            if (playerToClue == null)
            {
                throw new ArgumentNullException(nameof(playerToClue));
            }
            if (clue == null)
            {
                throw new ArgumentNullException(nameof(clue));
            }
            if (!clue.Type.IsStraightClue)
            {
                throw new IncorrectClueException("You must say rank or color!");
            }

            playerToClue.ListenClue(clue);

            Logger.Log.Info(string.Format(
                                $"Player {Name} gives clue to player {playerToClue.Name}: {clue.Type}"));

            RaiseClueGivenEvent();
        }
コード例 #4
0
ファイル: Clue.cs プロジェクト: IvanovAndrew/Hanabi
 public static Clue Revert(Clue clue, IEnumerable <CardInHand> hand)
 {
     return(Create(clue.Type.Revert(), hand));
 }