示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SpyCard"/> class.
 /// </summary>
 /// <param name="playerShowingCard">
 /// The player showing card.
 /// </param>
 /// <param name="cardSeen">
 /// The card seen.
 /// </param>
 public SpyCard(Player playerShowingCard, Card cardSeen)
     : base(playerShowingCard)
 {
     Contract.Requires<ArgumentNullException>(playerShowingCard != null, "player");
     Contract.Requires<ArgumentNullException>(cardSeen != null, "cardSeen");
     this.card = cardSeen;
 }
示例#2
0
 protected virtual void OnCardClicked(Card card)
 {
     if (card == null) throw new ArgumentNullException("card");
     var cardClicked = CardClicked;
     if (cardClicked != null) {
         cardClicked(this, new CardClickedEventArgs(card));
     }
 }
示例#3
0
文件: Node.cs 项目: AArnott/ClueBuddy
        /// <summary>
        /// Initializes a new instance of the <see cref="Node"/> class.
        /// </summary>
        /// <param name="cardHolder">The card holder.</param>
        /// <param name="card">The card.</param>
        public Node(ICardHolder cardHolder, Card card)
        {
            Contract.Requires<ArgumentNullException>(cardHolder != null, "cardHolder");
            Contract.Requires<ArgumentNullException>(card != null, "card");

            this.CardHolder = cardHolder;
            this.Card = card;
        }
示例#4
0
 public override void Setup()
 {
     base.Setup();
     cardShown = suggestion.Place;
     nodes.Clear();
     nodes.AddRange(from c in suggestion.Cards
                    select new Node(disprovingPlayer, c));
 }
示例#5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Disproved"/> class. 
 /// Creates a clue from when an opponent disproves the <see cref="Suspicion"/>
 /// of the interacting <see cref="Player"/>.
 /// </summary>
 /// <param name="opponent">
 /// The player who disproved the <see cref="Suspicion"/>.
 /// </param>
 /// <param name="suggestion">
 /// The weapon, suspect and place being suspected.
 /// </param>
 /// <param name="cardShown">
 /// The card that the opponent showed to disprove the <see cref="Suspicion"/>.
 /// </param>
 public Disproved(Player opponent, Suspicion suggestion, Card cardShown)
     : base(opponent)
 {
     Contract.Requires<ArgumentNullException>(suggestion != null, "suggestion");
     this.suspicion = suggestion;
     if (cardShown != null) {
         if (!suggestion.Cards.Contains(cardShown))
             throw new ArgumentException(string.Format(Strings.DisprovingCardNotInSuspicion, "cardShown", "suggestion"));
         this.cardShown = cardShown;
     }
 }
示例#6
0
        public void test_alabi_group_vertical_elimination_intelligence()
        {
            // Verify that this    		   Becomes this
            // P1: A _ _ A _ _ A _ _		1 _ _ 0 _ _ 0 _ _
            // P2: _ _ _ A _ _ A _ _		0 _ _ A _ _ A _ _
            // P3: _ _ _ A _ _ A _ _		0 _ _ A _ _ A _ _
            // P4: _ _ _ _ _ _ _ _ _		0 _ _ 0 _ _ 0 _ _
            // CF: _ _ _ _ _ _ _ _ _		0 _ _ 0 _ _ 0 _ _
            var suggestion = new Card[] { this.suspects[0], this.weapons[0], this.places[0] };
            this.players[0].disproved(suggestion);
            this.players[1].disproved(suggestion.Skip(1).ToArray());
            this.players[2].disproved(suggestion.Skip(1).ToArray());

            this.game.Analyze();

            // Verify P1, all cards
            Assert.IsTrue(this.players[0].has(suggestion[0]).Value);
            Assert.IsTrue(this.players[0].has_not(suggestion[1]).Value);
            Assert.IsTrue(this.players[0].has_not(suggestion[2]).Value);

            // Verify P2, P3
            foreach (Player p in this.players.Skip(1).Take(2))
            {
                Assert.IsTrue(p.has_not(suggestion[0]).Value);
                Assert.IsFalse(p.has(suggestion[1]).HasValue);
                Assert.IsFalse(p.has(suggestion[2]).HasValue);
            }

            foreach (Card card in suggestion)
            {
                foreach (Player p in this.players.Skip(3))
                {
                    Assert.IsTrue(p.has_not(card).Value);
                }
                Assert.IsTrue(this.game.CaseFile.has_not(card).Value);
            }
        }
示例#7
0
        public void test_two_card_alabi_group_by_two_player_reserves_cards()
        {
            // Verify that this    		   Becomes this
            // P1: _ _ _ A _ _ A _ _		_ _ _ A _ _ A _ _
            // P2: _ _ _ A _ _ A _ _		_ _ _ A _ _ A _ _
            // P3: _ _ _ _ _ _ _ _ _		_ _ _ 0 _ _ 0 _ _
            // P4: _ _ _ _ _ _ _ _ _		_ _ _ 0 _ _ 0 _ _
            // CF: _ _ _ _ _ _ _ _ _		_ _ _ 0 _ _ 0 _ _
            var suggestion = new Card[] { this.weapons[0], this.places[0] };
            foreach (Player p in this.players.Take(suggestion.Length)) {
                p.disproved(suggestion);
            }

            this.game.Analyze();
            foreach (Card card in suggestion) {
                foreach (Player p in this.players.Skip(suggestion.Length)) {
                    Assert.IsTrue(p.has_not(card).Value);
                }
                Assert.IsTrue(this.game.CaseFile.has_not(card).Value);
            }
        }
示例#8
0
        public void test_disproven_three_times_then_not_in_CaseFile()
        {
            // Verify that this    		   Becomes this        (underscores are not set or checked, allowing for additional behavior)
            // P1: A _ _ A _ _ A _ _		A _ _ A _ _ A _ _
            // P2: A _ _ A _ _ A _ _		A _ _ A _ _ A _ _
            // P3: A _ _ A _ _ A _ _		A _ _ A _ _ A _ _
            // P4: _ _ _ _ _ _ _ _ _		_ _ _ _ _ _ _ _ _
            // CF: _ _ _ _ _ _ _ _ _		0 _ _ 0 _ _ 0 _ _
            var suggestion = new Card[] { this.suspects[0], this.weapons[0], this.places[0] };
            foreach (Player p in this.players.Take(suggestion.Length)) {
                // Debug.WriteLine(p.Name + " disproving suggestion");
                p.disproved(suggestion);
            }

            this.game.Analyze();
            foreach (Card card in suggestion) {
                Assert.IsTrue(this.game.CaseFile.has_not(card).Value);
            }
        }
示例#9
0
 /// <summary>
 /// Determines whether this player holds a given card.
 /// </summary>
 /// <param name="card">The card in question.</param>
 /// <returns>True if the player holds the card, false if not, or null if it is unknown.</returns>
 public bool? HasCard(Card card)
 {
     return this.Game.Nodes.First(n => n.CardHolder == this && n.Card == card).IsSelected;
 }
示例#10
0
 public CardClickedEventArgs(Card card)
 {
     this.card = card;
 }
示例#11
0
 /// <summary>
 /// Determines whether this player holds a given card.
 /// </summary>
 /// <param name="card">The card in question.</param>
 /// <returns>
 /// True if the player holds the card, false if not, or null if it is unknown.
 /// </returns>
 bool? ICardHolder.HasCard(Card card)
 {
     Contract.Requires<InvalidOperationException>(((ICardHolder)this).Game != null);
     Contract.Requires<ArgumentNullException>(card != null, "card");
     throw new NotImplementedException();
 }
示例#12
0
 bool? node(ICardHolder holder, Card card)
 {
     return this.game.Nodes.Where(n => n.CardHolder == holder && n.Card == card).First().IsSelected;
 }
示例#13
0
 void disproved(Player disprovingPlayer, Card cardShown)
 {
     this.cc.Responses[disprovingPlayer].Disproved = true;
     this.cc.Responses[disprovingPlayer].Alabi = cardShown;
 }
示例#14
0
        private string GetCardSuggestionStrength(Card card)
        {
            int strength = 0;

            // Consider the card worthwhile if its existence in the Case File is not known.
            if (!this.game.CaseFile.HasCard(card).HasValue) {
                // Its strength is based on how much we know about it so far, which is based
                // on how many constraints we already have on it.
                int constraintWithCardCount =
                    this.game.Constraints.Count(
                        c => c is ConstraintBase && ((ConstraintBase)c).Nodes.Any(cn => ((Node)cn).Card == card));
                strength = 50 - constraintWithCardCount;
            }
            return string.Format("{0,-20}", card.Name) + string.Format("{0,4}", strength);
        }