public void RemoveBot(BotGame bot) { lock (bots) { botInfos.Remove(botInfos.Single(info => info.Username == bot.Username && info.Password == bot.Password)); bots.Remove(bot); } bot.Dispose().Wait(); }
public BotGame CreateBot() { Log("Creating new bot"); Random random = new Random(); BotGame game = null; do { string username = "******" + random.Next(); string password = random.Next().ToString(); factoryGame.DoSayChat(".account create " + username + " " + password); Thread.Sleep(1000); for (int loginTries = 0; loginTries < 5; loginTries++) { game = new BotGame(Settings.Default.Hostname, Settings.Default.Port, username, password, Settings.Default.RealmID, 0); game.SettingUp = true; game.Start(); for (int tries = 0; !game.Connected && tries < 10; tries++) { Thread.Sleep(1000); } if (!game.Connected) { game.Dispose(); game = null; } else { botInfos.Add(new BotInfo(username, password)); break; } } } while (game == null); game.CreateCharacter(); Thread.Sleep(1000); game.SendPacket(new OutPacket(WorldCommand.ClientEnumerateCharacters)); Thread.Sleep(1000); game.SettingUp = false; return(game); }