public static void MoveToNewLocation() { IPlayerRepository playerRepo = new EFPlayerRepository(); var fae = playerRepo.Players.FirstOrDefault(f => f.BotId == AIStatics.JewdewfaeBotId); IJewdewfaeEncounterRepository faeRepo = new EFJewdewfaeEncounterRepository(); IAIDirectiveRepository aiRepo = new EFAIDirectiveRepository(); var directive = aiRepo.AIDirectives.FirstOrDefault(i => i.OwnerId == fae.Id); // add fae's current location to the list of places visited directive.sVar2 += fae.dbLocationName + ";"; var fairyLocations = faeRepo.JewdewfaeEncounters.Where(f => f.IsLive).Select(f => f.dbLocationName).ToList(); var visitedFairyLocations = directive.sVar2.Split(';').Where(f => f.Length > 1).ToList(); var possibleLocations = fairyLocations.Except(visitedFairyLocations).ToList(); // if there are no locations left to visit, reset if (!possibleLocations.Any()) { possibleLocations = fairyLocations; directive.sVar2 = ""; } double max = possibleLocations.Count(); var rand = new Random(); var num = rand.NextDouble(); var index = Convert.ToInt32(Math.Floor(num * max)); var newLocation = possibleLocations.ElementAt(index); directive.Var1 = 0; directive.Var2 = PvPWorldStatProcedures.GetWorldTurnNumber(); directive.sVar1 = ";"; aiRepo.SaveAIDirective(directive); LocationLogProcedures.AddLocationLog(fae.dbLocationName, "<b>Jewdewfae got bored and flew away from here.</b>"); fae.dbLocationName = newLocation; playerRepo.SavePlayer(fae); LocationLogProcedures.AddLocationLog(fae.dbLocationName, "<b>Jewdewfae flew here. She looks bored and wants to play with someone.</b>"); }
public static JewdewfaeEncounter GetFairyChallengeInfoAtLocation(string location) { IJewdewfaeEncounterRepository repo = new EFJewdewfaeEncounterRepository(); return(repo.JewdewfaeEncounters.FirstOrDefault(e => e.dbLocationName == location)); }