Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CannotDisprove"/> class.
 /// </summary>
 /// <param name="unablePlayer">The player that cannot disprove the suspicion.</param>
 /// <param name="suspicion">The suspicion.</param>
 public CannotDisprove(Player unablePlayer, Suspicion suspicion)
     : base(unablePlayer)
 {
     Contract.Requires<ArgumentNullException>(unablePlayer != null, "unablePlayer");
     Contract.Requires<ArgumentNullException>(suspicion != null, "suspicion");
     this.suspicion = suspicion;
 }
Example #2
0
 public void DisprovedConstructorWithForeignCardTest()
 {
     Player disprovingPlayer = new Player("opponent");
     Suspicion suggestion = new Suspicion(new Suspect("test"), new Weapon("test"), new Place("test"));
     Card cardShown = new Suspect("some other suspect");
     new Disproved(disprovingPlayer, suggestion, cardShown);
 }
Example #3
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;
     }
 }
Example #4
0
 public void CardsTest()
 {
     var w = new Weapon("weapon");
     var s = new Suspect("suspect");
     var l = new Place("location");
     Suspicion target = new Suspicion(s, w, l);
     List<Card> cards = target.Cards.ToList();
     CollectionAssert.Contains(cards, w);
     CollectionAssert.Contains(cards, s);
     CollectionAssert.Contains(cards, l);
     Assert.AreEqual(3, cards.Count);
 }
Example #5
0
        public void AddSeveralCluesTest()
        {
            Game g = StartPresetGame();
            g.AutoAnalysis = false;
            Suspicion s = new Suspicion(g.Suspects.First(), g.Weapons.First(), g.Places.First());
            //Debug.WriteLine("Adding that no one has these cards: " + s.Suspect.ToString() + ", " + s.Weapon.ToString() + ", " + s.Place.ToString());
            foreach (Player p in g.Players) {
                Clue clue = new CannotDisprove(p, s);
                g.Clues.Add(clue);
            }

            Assert.AreSame(s.Suspect, g.CaseFile.Suspect);
            Assert.AreSame(s.Weapon, g.CaseFile.Weapon);
            Assert.AreSame(s.Place, g.CaseFile.Place);
        }
Example #6
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 another opponent (besides the interacting <see cref="Player"/>.)
 /// </summary>
 /// <param name="disprovingPlayer">
 /// The player disproving the <see cref="Suspicion">suggestion</see>.
 /// </param>
 /// <param name="suggestion">
 /// The weapon, suspect and place being suspected.
 /// </param>
 public Disproved(Player disprovingPlayer, Suspicion suggestion)
     : this(disprovingPlayer, suggestion, null)
 {
 }
Example #7
0
 /// <summary>
 /// Gets a suggestion from the user.
 /// </summary>
 /// <returns>The suggestion.</returns>
 private Suspicion GetSuggestion()
 {
     var suggestion = new Suspicion();
     suggestion.Place = ConsoleHelper.Choose(
         "Where?", true, this.GetCardSuggestionStrength, this.game.Places.ToArray());
     if (suggestion.Place == null) {
         return null;
     }
     suggestion.Suspect = ConsoleHelper.Choose(
         "Who?", true, this.GetCardSuggestionStrength, this.game.Suspects.ToArray());
     if (suggestion.Suspect == null) {
         return null;
     }
     suggestion.Weapon = ConsoleHelper.Choose(
         "How?", true, this.GetCardSuggestionStrength, this.game.Weapons.ToArray());
     if (suggestion.Weapon == null) {
         return null;
     }
     return suggestion;
 }
Example #8
0
 /// <summary>
 /// Makes an accusation.
 /// </summary>
 private void Accusation()
 {
     var suggestion = new Suspicion();
     suggestion.Place = ConsoleHelper.Choose(
         "Where?", true, p => this.GetCardSuggestionStrength(p), this.game.Places.ToArray());
     if (suggestion.Place == null) {
         return;
     }
     suggestion.Suspect = ConsoleHelper.Choose(
         "Who?", true, s => this.GetCardSuggestionStrength(s), this.game.Suspects.ToArray());
     if (suggestion.Suspect == null) {
         return;
     }
     suggestion.Weapon = ConsoleHelper.Choose(
         "How?", true, w => this.GetCardSuggestionStrength(w), this.game.Weapons.ToArray());
     if (suggestion.Weapon == null) {
         return;
     }
     switch (
         ConsoleHelper.Choose(string.Format("Was the accusation correct ({0})?", suggestion), false, new[] { "Yes", "No", "Abort accusation" })) {
         case 0: // Correct
             return; // game over
         case 1: // Incorrect
             // Add a clue that this solution is impossible
             this.game.Clues.Add(new BadAccusation(suggestion, this.game.CaseFile));
             break;
         case 2: // Abort
             break;
     }
 }