예제 #1
0
파일: Program.cs 프로젝트: UncleGus/dracula
 /// <summary>
 /// Resolves EncounterTiles in front of a Hunter
 /// </summary>
 /// <param name="game">The GameState</param>
 /// <param name="hunterIndex">The string to be converted to a Hunter</param>
 /// <param name="logic">The artificial intelligence component</param>
 private static void HandleEncountersInFrontOfHunter(GameState game, string hunterIndex, DecisionMaker logic)
 {
     var hunterWithEncounter = Hunter.Nobody;
     int index = -2;
     if (int.TryParse(hunterIndex, out index))
     {
         hunterWithEncounter = game.GetHunterFromInt(index);
     }
     var line = "";
     while (hunterWithEncounter == Hunter.Nobody && index != -1)
     {
         Console.WriteLine("Who is resolving an Encounter in front of them? {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 || index > 4)
             {
                 index = -2;
             }
             if (index == -1)
             {
                 Console.WriteLine("Cancelled");
                 return;
             }
             hunterWithEncounter = game.GetHunterFromInt(index);
             Console.WriteLine(hunterWithEncounter.Name());
         }
         else
         {
             Console.WriteLine("I didn't understand that");
         }
     }
     while (game.Hunters[(int)hunterWithEncounter].EncountersInFrontOfPlayer.Any())
     {
         switch (game.Hunters[(int)hunterWithEncounter].EncountersInFrontOfPlayer.First().Encounter)
         {
             case Encounter.Fog:
                 game.EncounterPool.Add(game.Hunters[(int)hunterWithEncounter].EncountersInFrontOfPlayer.First());
                 game.Hunters[(int)hunterWithEncounter].EncountersInFrontOfPlayer.Remove(game.Hunters[(int)hunterWithEncounter].EncountersInFrontOfPlayer.First());
                 Console.WriteLine("Fog tile returned to the Encounter pool");
                 break;
             case Encounter.Bats:
                 game.EncounterPool.Add(game.Hunters[(int)hunterWithEncounter].EncountersInFrontOfPlayer.First());
                 game.Hunters[(int)hunterWithEncounter].EncountersInFrontOfPlayer.Remove(game.Hunters[(int)hunterWithEncounter].EncountersInFrontOfPlayer.First());
                 Console.WriteLine("Dracula is controlling {0}'s movement", hunterWithEncounter.Name());
                 Location destination = logic.ChooseBatsDestination(game, hunterWithEncounter);
                 HandleMoveOperation(game, destination.Name(), ((int)hunterWithEncounter).ToString(), logic);
                 break;
         }
     }
 }