Exemplo n.º 1
0
 public bool ResolveSpy(List<Hunter> huntersEncountered, UserInterface ui)
 {
     ui.TellUser(huntersEncountered.First().Name + " encountered a spy" + (huntersEncountered.Count() > 1 ? " with his group" : ""));
     foreach (Hunter h in huntersEncountered)
     {
         List<String> itemsAlreadyKnownToDracula = new List<String>();
         for (int i = 0; i < h.NumberOfItems; i++)
         {
             string line = "";
             do
             {
                 line = ui.GetNameOfItemInHandFromHunter(h.Name);
                 if (GetItemByNameFromItemDeck(line).Name == "Unknown item" && h.ItemsKnownToDracula.FindIndex(item => item.Name == line) == -1)
                 {
                     ui.TellUser("I didn't recognise that card name");
                 }
             } while (GetItemByNameFromItemDeck(line).Name == "Unknown item" && h.ItemsKnownToDracula.FindIndex(item => item.Name == line) == -1);
             itemsAlreadyKnownToDracula.Add(line);
         }
         List<ItemDetail> itemsToAddToKnownItems = new List<ItemDetail>();
         itemsToAddToKnownItems.AddRange(h.ItemsKnownToDracula);
         foreach (string name in itemsAlreadyKnownToDracula)
         {
             if (itemsToAddToKnownItems.FindIndex(it => it.Name == name) > -1)
             {
                 itemsToAddToKnownItems.Remove(itemsToAddToKnownItems.Find(it => it.Name == name));
             }
             else
             {
                 h.ItemsKnownToDracula.Add(GetItemByNameFromItemDeck(name));
             }
         }
         List<String> eventsAlreadyKnownToDracula = new List<String>();
         for (int i = 0; i < h.NumberOfItems; i++)
         {
             string line = "";
             do
             {
                 line = ui.GetNameOfEventInHandFromHunter(h.Name);
                 if (GetEventByNameFromEventDeck(line).name == "Unknown event" && h.EventsKnownToDracula.FindIndex(ev => ev.name == line) == -1)
                 {
                     ui.TellUser("I didn't recognise that card name");
                 }
             } while (GetEventByNameFromEventDeck(line).name == "Unknown event" && h.EventsKnownToDracula.FindIndex(ev => ev.name == line) == -1);
             eventsAlreadyKnownToDracula.Add(line);
         }
         List<EventDetail> eventsToAddToKnownEvents = new List<EventDetail>();
         eventsToAddToKnownEvents.AddRange(h.EventsKnownToDracula);
         foreach (string name in eventsAlreadyKnownToDracula)
         {
             if (eventsToAddToKnownEvents.FindIndex(eve => eve.name == name) > -1)
             {
                 eventsToAddToKnownEvents.Remove(eventsToAddToKnownEvents.Find(eve => eve.name == name));
             }
             else
             {
                 h.EventsKnownToDracula.Add(GetEventByNameFromEventDeck(name));
             }
         }
         h.TravelType = ui.AskHunterWhatTravelTypeForSpy(h.Name);
         string lineB;
         do
         {
             lineB = ui.AskHunterWhichLocationTheyAreMovingToNextTurn(h.Name);
         } while (GetLocationFromName(lineB).Name == "Unknown location" || GetLocationFromName(lineB).Name == "Multiple locations");
         h.Destination = GetLocationFromName(lineB);
     }
     return true;
 }