static void Main(string[] args) { try { using (BotFactory factory = new BotFactory()) { Random random = new Random(); factory.SetupFactory(random.Next(Settings.Default.MinBotsCount, Settings.Default.MaxBotsCount)); GC.KeepAlive(factory); } } catch(UnauthorizedAccessException ex) { Console.WriteLine(ex.Message); Console.WriteLine("Try running the application as Administrator or check if the files have the Read-Only flag set"); Console.ReadLine(); } catch(ConfigurationException ex) { Console.WriteLine(ex.Message); if (ex.InnerException != null) Console.WriteLine(ex.InnerException.Message); Console.ReadLine(); } }
static void Main(string[] args) { try { using (BotFactory factory = new BotFactory()) { Random random = new Random(); factory.SetupFactory(random.Next(Settings.Default.MinBotsCount, Settings.Default.MaxBotsCount)); GC.KeepAlive(factory); } } catch (UnauthorizedAccessException ex) { Console.WriteLine(ex.Message); Console.WriteLine("Try running the application as Administrator or check if the files have the Read-Only flag set"); Console.ReadLine(); } catch (ConfigurationException ex) { Console.WriteLine(ex.Message); if (ex.InnerException != null) { Console.WriteLine(ex.InnerException.Message); } Console.ReadLine(); } }
public BotFactory() { Instance = this; logger = new StreamWriter(logPath); logger.WriteLine("Starting BotFactory"); if (!File.Exists(botsInfosPath)) { botInfos = new List <BotInfo>(); } else { using (StreamReader sr = new StreamReader(botsInfosPath)) { try { XmlSerializer serializer = new XmlSerializer(typeof(List <BotInfo>)); botInfos = (List <BotInfo>)serializer.Deserialize(sr); } catch (InvalidOperationException) { botInfos = new List <BotInfo>(); } } } factoryGame = new AutomatedGame(Settings.Default.Hostname, Settings.Default.Port, Settings.Default.Username, Settings.Default.Password, Settings.Default.RealmID, 0); factoryGame.Start(); }
static void Main(string[] args) { using (BotFactory factory = new BotFactory()) { factory.SetupFactory(Settings.Default.BotsCount); GC.KeepAlive(factory); } }
static void Main(string[] args) { using (BotFactory factory = new BotFactory()) { Random random = new Random(); factory.SetupFactory(random.Next(Settings.Default.MinBotsCount, Settings.Default.MaxBotsCount)); GC.KeepAlive(factory); } }
static void Main(string[] args) { using (BotFactory factory = new BotFactory()) { Random random = new Random(); factory.SetupFactory(random.Next(Settings.Default.MinBotsCount, Settings.Default.MaxBotsCount)); GC.KeepAlive(factory); } }
public BotFactory() { Instance = this; logger = new StreamWriter(logPath); logger.WriteLine("Starting BotFactory"); if (!File.Exists(botsInfosPath)) { botInfos = new List <BotInfo>(); } else { using (StreamReader sr = new StreamReader(botsInfosPath)) { try { XmlSerializer serializer = new XmlSerializer(typeof(List <BotInfo>)); botInfos = (List <BotInfo>)serializer.Deserialize(sr); } catch (InvalidOperationException) { botInfos = new List <BotInfo>(); } } } factoryGame = new AutomatedGame(Settings.Default.Hostname, Settings.Default.Port, Settings.Default.Username, Settings.Default.Password, Settings.Default.RealmID, 0); factoryGame.Start(); int tries = 0; while (!factoryGame.LoggedIn) { Thread.Sleep(1000); tries++; if (tries > 15) { throw new TimeoutException("Could not login after 15 tries"); } } }
public BotFactory() { Instance = this; logger = TextWriter.Synchronized(new StreamWriter(logPath)); logger.WriteLine("Starting BotFactory"); if (!File.Exists(botsInfosPath)) botInfos = new List<BotInfo>(); else using (StreamReader sr = new StreamReader(botsInfosPath)) { try { XmlSerializer serializer = new XmlSerializer(typeof(List<BotInfo>)); botInfos = (List<BotInfo>)serializer.Deserialize(sr); } catch(InvalidOperationException) { botInfos = new List<BotInfo>(); } } foreach (BotBehaviorSettings behavior in Settings.Default.Behaviors) botBehaviors[behavior.Name] = behavior; if (botBehaviors.Count == 0) { Log("Behaviors not found in the configuration file, exiting"); Environment.Exit(0); } if (!botBehaviors.ContainsKey(defaultBehaviorName)) { Log("'" + defaultBehaviorName + "' behavior not found in the configuration file, exiting"); Environment.Exit(0); } if (botBehaviors.Sum(behavior => behavior.Value.Probability) != 100) { Log("Behaviors total Probability != 100 (" + botBehaviors.Sum(behavior => behavior.Value.Probability) + "), exiting"); Environment.Exit(0); } foreach (BotInfo botInfo in botInfos) { if (string.IsNullOrEmpty(botInfo.BehaviorName)) { Log(botInfo.Username + " has missing behavior, setting to default one"); botInfo.BehaviorName = defaultBehaviorName; continue; } if (!botBehaviors.ContainsKey(botInfo.BehaviorName)) { Log(botInfo.Username + " has inexistent behavior '" + botInfo.BehaviorName + "', setting to default one"); botInfo.BehaviorName = defaultBehaviorName; continue; } } DetourCLI.Detour.Initialize(Settings.Default.MMAPsFolderPath); VMapCLI.VMap.Initialize(Settings.Default.VMAPsFolderPath); MapCLI.Map.Initialize(Settings.Default.MAPsFolderPath); DBCStoresCLI.DBCStores.Initialize(Settings.Default.DBCsFolderPath); DBCStoresCLI.DBCStores.LoadDBCs(); factoryGame = new AutomatedGame(Settings.Default.Hostname, Settings.Default.Port, Settings.Default.Username, Settings.Default.Password, Settings.Default.RealmID, 0); factoryGame.Start(); }
public BotFactory() { Instance = this; logger = TextWriter.Synchronized(new StreamWriter(logPath)); logger.WriteLine("Starting BotFactory"); if (!File.Exists(botsInfosPath)) { botInfos = new List <BotInfo>(); } else { using (StreamReader sr = new StreamReader(botsInfosPath)) { try { XmlSerializer serializer = new XmlSerializer(typeof(List <BotInfo>)); botInfos = (List <BotInfo>)serializer.Deserialize(sr); } catch (InvalidOperationException) { botInfos = new List <BotInfo>(); } } } foreach (BotBehaviorSettings behavior in Settings.Default.Behaviors) { botBehaviors[behavior.Name] = behavior; } if (botBehaviors.Count == 0) { Log("Behaviors not found in the configuration file, exiting"); Environment.Exit(0); } if (!botBehaviors.ContainsKey(defaultBehaviorName)) { Log("'" + defaultBehaviorName + "' behavior not found in the configuration file, exiting"); Environment.Exit(0); } if (botBehaviors.Sum(behavior => behavior.Value.Probability) != 100) { Log("Behaviors total Probability != 100 (" + botBehaviors.Sum(behavior => behavior.Value.Probability) + "), exiting"); Environment.Exit(0); } foreach (BotInfo botInfo in botInfos) { if (string.IsNullOrEmpty(botInfo.BehaviorName)) { Log(botInfo.Username + " has missing behavior, setting to default one"); botInfo.BehaviorName = defaultBehaviorName; continue; } if (!botBehaviors.ContainsKey(botInfo.BehaviorName)) { Log(botInfo.Username + " has inexistent behavior '" + botInfo.BehaviorName + "', setting to default one"); botInfo.BehaviorName = defaultBehaviorName; continue; } } DetourCLI.Detour.Initialize(Settings.Default.MMAPsFolderPath); VMapCLI.VMap.Initialize(Settings.Default.VMAPsFolderPath); MapCLI.Map.Initialize(Settings.Default.MAPsFolderPath); DBCStoresCLI.DBCStores.Initialize(Settings.Default.DBCsFolderPath); DBCStoresCLI.DBCStores.LoadDBCs(); factoryGame = new AutomatedGame(Settings.Default.Hostname, Settings.Default.Port, Settings.Default.Username, Settings.Default.Password, Settings.Default.RealmID, 0); factoryGame.Start(); }