Esempio n. 1
0
        public static async Task Initialize(TestContext context)
        {
            var hostname  = Settings.Default.Hostname;
            var port      = Settings.Default.Port;
            var username  = Settings.Default.Username;
            var password  = Settings.Default.Password;
            var realmId   = Settings.Default.RealmID;
            var character = Settings.Default.Character;

            game = new AutomatedGame(hostname, port, username, password, realmId, character);

            game.Start();
            int tries = 0;

            while (!game.LoggedIn)
            {
                await Task.Delay(1000);

                tries++;
                if (tries > 15)
                {
                    throw new TimeoutException("Could not login after 15 tries");
                }
            }
            await Task.Delay(5000);

            await game.ScheduleActionAndWait(() => game.DoSayChat("Connected"));
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
 public bool Activate(AutomatedGame game)
 {
     this.game = game as BotGame;
     if (this.game == null)
     {
         return(false);
     }
     ScheduledBegging();
     return(true);
 }
Esempio n. 4
0
        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");
                }
            }
        }
Esempio n. 5
0
 public bool Activate(AutomatedGame game)
 {
     return(true);
 }
Esempio n. 6
0
 public bool Activate(AutomatedGame game)
 {
     this.game = game;
     ScheduleFollowLeader();
     return(true);
 }
Esempio n. 7
0
        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();
        }
Esempio n. 8
0
 public bool Activate(AutomatedGame game)
 {
     return true;
 }