Exemple #1
0
 /// <summary>
 /// Moves the given Hunter to the given Location, along with all Hunters in the given Hunter's group
 /// </summary>
 /// <param name="game">The GameState</param>
 /// <param name="hunterIndex">A string to be converted to the Hunter discarding the card</param>
 /// <param name="location">The name of the Location to move to</param>
 /// <returns>The position of the card in Dracula's trail (0-5) or catacombs (6-8) that corresponds to the given location, or -1 if not in the trail/catacombs</returns>
 private static int MoveHunter(GameState game, string hunterIndex, string location, out Hunter hunterMoved,
     out Location originatingLocation, DecisionMaker logic)
 {
     var hunterToMove = Hunter.Nobody;
     int index;
     if (int.TryParse(hunterIndex, out index))
     {
         hunterToMove = game.GetHunterFromInt(index);
     }
     var line = "";
     while (hunterToMove == Hunter.Nobody && index != -1)
     {
         Console.WriteLine("Who is moving? {0}= {1}, {2}= {3}, {4}= {5}, {6}= {7} (-1 to cancel)",
             (int)Hunter.LordGodalming, Hunter.LordGodalming.Name(), (int)Hunter.DrSeward,
             Hunter.DrSeward.Name(), (int)Hunter.VanHelsing, Hunter.VanHelsing.Name(), (int)Hunter.MinaHarker,
             Hunter.MinaHarker.Name());
         line = Console.ReadLine();
         if (int.TryParse(line, out index))
         {
             if (index == -1)
             {
                 Console.WriteLine("Cancelled");
                 hunterMoved = Hunter.Nobody;
                 originatingLocation = Location.Nowhere;
                 return -1;
             }
             hunterToMove = game.GetHunterFromInt(index);
             Console.WriteLine(hunterToMove.Name());
         }
         else
         {
             Console.WriteLine("I didn't understand that");
         }
     }
     hunterMoved = (Hunter)index;
     originatingLocation = game.Hunters[(int)hunterMoved].CurrentLocation;
     Location destination;
     if (DraculaIsPlayingControlStorms(game, hunterMoved, logic))
     {
         Console.WriteLine("Dracula is controlling the ship's movement");
         destination = logic.ChoosePortToMoveHuntersToWithControlStorms(game, hunterMoved);
     }
     else
     {
         destination = Enumerations.GetLocationFromString(location);
         while (destination == Location.Nowhere && line.ToLower() != "cancel")
         {
             Console.WriteLine("Where is {0} moving? (Type cancel to cancel)", hunterToMove.Name());
             line = Console.ReadLine();
             destination = Enumerations.GetLocationFromString(line);
             Console.WriteLine(destination.Name());
         }
         if (line.ToLower() == "cancel")
         {
             Console.WriteLine("Cancelled");
             return -1;
         }
     }
     Console.Write("{0} moved from {1} to ", hunterToMove.Name(),
         game.Hunters[(int)hunterToMove].CurrentLocation.Name());
     foreach (var h in game.Hunters[(int)hunterToMove].HuntersInGroup)
     {
         game.Hunters[(int)h].MoveTo(destination);
     }
     Console.WriteLine(destination.Name() +
                       (game.Hunters[(int)hunterToMove].HuntersInGroup.Count() > 1 ? " with his group" : ""));
     for (var i = 0; i < 6; i++)
     {
         if (game.Dracula.Trail[i] != null && game.Dracula.Trail[i].DraculaCards.First().Location == destination)
         {
             return i;
         }
     }
     for (var i = 0; i < 3; i++)
     {
         if (game.Dracula.Catacombs[i] != null &&
             game.Dracula.Catacombs[i].DraculaCards.First().Location == destination)
         {
             return i + 6;
         }
     }
     return -1;
 }