Ejemplo n.º 1
0
 public void Hint(Hint h)
 {
     if (this.Hints <= 0) throw new InvalidOperationException("no hints available");
     Log.WriteLine("hints to player {0}: {1}", h.For.Index + 1, h.ToString());
     h.For.GetHint(h);
     this.Hints--;
 }
Ejemplo n.º 2
0
        public void ProcessHint(Hint hint)
        {
            var relevantCards = cards.Where(card => card.ProcessHint(hint));

            if (hint is NumberHint)
            {
                ContemplateNumberHint(((NumberHint)hint).Number, relevantCards);
            }
            else
            {
                ContemplateSuitHint(((SuitHint)hint).Suit, relevantCards);
            }
        }
Ejemplo n.º 3
0
 public bool ProcessHint(Hint hint)
 {
     if (hint is NumberHint)
      {
     return ProcessNumberHint((NumberHint) hint);
      }
      return ProcessSuitHint((SuitHint) hint);
 }
Ejemplo n.º 4
0
 public void ProcessHint(Hint hint)
 {
     var relevantCards = cards.Where(card => card.ProcessHint(hint));
      if (hint is NumberHint)
      {
     ContemplateNumberHint( ((NumberHint) hint).Number, relevantCards);
      }
      else
      {
     ContemplateSuitHint( ((SuitHint) hint).Suit, relevantCards);
      }
 }
Ejemplo n.º 5
0
 public static Move DoHint(Hint h)
 {
     return new Move { Hint = h };
 }
Ejemplo n.º 6
0
 public void GetHint(Hint h)
 {
     // TODO: store a history of received hints ... do we need a full move history?
     for (int i = 0; i < this.Cards.Count; i++)
     {
         HeldCard card = this.Cards[i];
         bool match = h.Positions.Contains(i);
         int value = h.Number.HasValue ? h.Number.Value : h.Suit.Value;
         Func<Card, int> get = c => h.Number.HasValue ? c.Number : c.Suit;
         // If the hint matches this card, remove all other values.
         // If the hint does not match this card, remove the hinted value.
         card.Possible.RemoveAll(c => match ? get(c) != value : get(c) == value);
     }
 }
Ejemplo n.º 7
0
 public void HandleHint(Hint hint)
 {
     SpendHintToken();
     hint.TargetPlayer.ProcessHint(hint);
 }
Ejemplo n.º 8
0
 public void GetHint(Hint h)
 {
     for (int i = 0; i < this.Cards.Count; i++)
     {
         HeldCard c = this.Cards[i];
         var match = h.Positions.Contains(i);
         var list = h.Number.HasValue ? c.Numbers : c.Suits;
         var value = h.Number.HasValue ? h.Number.Value : h.Suit.Value;
         if (match) // is definitely the given value
         {
             list.Clear();
             list.Add(value);
         }
         else // cannot be the given value
         {
             list.Remove(value);
         }
     }
 }