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--; }
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); } }
public bool ProcessHint(Hint hint) { if (hint is NumberHint) { return ProcessNumberHint((NumberHint) hint); } return ProcessSuitHint((SuitHint) hint); }
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); } }
public static Move DoHint(Hint h) { return new Move { Hint = h }; }
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); } }
public void HandleHint(Hint hint) { SpendHintToken(); hint.TargetPlayer.ProcessHint(hint); }
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); } } }