コード例 #1
0
        protected static void InitializeConfiguration()
        {
            new Configuration();
            Console.WriteLine("Configuration loaded!");
            Thread.Sleep(1000);
            var usingmysql = Configuration.IsMySQLEnabled ? "YES" : "NO";
            Console.WriteLine("Using MySQL: " + usingmysql);
            if (Configuration.IsMySQLEnabled)
            {
                Console.WriteLine("Connecting to MySQL");
                new WebService();
                while (!WebService.ConnectionEntablished)
                    Thread.Sleep(100);
                Console.WriteLine("Connected!");
            }
            else if (!File.Exists("Settings.ini"))
            {
                Console.WriteLine("Configuration file not found. Enter required information." + Environment.NewLine);

                Console.Write("League of Legends game path: ");
                var GamePath = Console.ReadLine();

                Console.Write(Environment.NewLine + "Select region [EUW, EUNE, NA, TR, ...]: ");
                var Region = Console.ReadLine();

                Console.Write(Environment.NewLine + "Max bots value: ");
                var MaxBots = Console.ReadLine();

                Console.Write(Environment.NewLine + "Queue type: [ARAM, MEDIUM_BOT, EASY_BOT, NORMAL5X5]: ");
                var Queue = Console.ReadLine();


                string SelectedDifficulty = string.Empty;
                int SelectedQueue = int.MaxValue;

                switch (Queue)
                {
                    case "MEDIUM_BOT":
                        SelectedDifficulty = "MEDIUM";
                        SelectedQueue = 33;
                        break;
                    case "EASY_BOT":
                        SelectedQueue = 32;
                        SelectedDifficulty = "EASY";
                        break;
                    case "ARAM":
                        SelectedQueue = 65;
                        break;
                    case "NORMAL5X5":
                        SelectedQueue = 2;
                        break;
                }

                if (MaxBots == null || GamePath == null || SelectedQueue == int.MaxValue || Region == null)
                {
                    Console.WriteLine("Some of settings was left not set. Please run ChallengerBot again and set all settings as it should be.");    
                    return;
                }

                var mbots = String.Join("", MaxBots.Where(char.IsDigit));
                Settings SFile = new Settings
                {
                    GamePath = GamePath,
                    MaxBots = Convert.ToInt32(mbots),
                    Difficulty = SelectedDifficulty,
                    QueueType = SelectedQueue,
                    Region = Region.ToUpper()
                };


                WebService.Setting = SFile;
                using (StreamWriter file = File.CreateText("Settings.ini"))
                using (JsonTextWriter writer = new JsonTextWriter(file))
                {
                    writer.WriteRaw(JsonConvert.SerializeObject(SFile, Formatting.Indented));
                }
                
                Thread.Sleep(1000);
                Console.WriteLine("Settings.ini file saved.");
            }
            else if (File.Exists("Settings.ini")) Configuration.LoadSettings();
     
            if (!File.Exists("accounts.txt") && !Configuration.IsMySQLEnabled)
            {
                Console.WriteLine("Missing accounts.txt file.");
                Console.WriteLine("One account per line. " + Environment.NewLine +
                                  " Format: accountname|accountpassword|maxlevel[1-31]|xpboostbuy[0 - NO and 1 YES]");
                while (true) Thread.Sleep(100);
            }
            else
            {
                int LoadedPlayers = 0;
                StreamReader file = new StreamReader("accounts.txt");
                string line;

                while ((line = file.ReadLine()) != null)
                {
                    string[] account = line.Split('|');

                    bool boost = account[3] != "0";

                    Accounts bot = new Accounts
                    {
                        Account = account[0],
                        Password = account[1],
                        Maxlevel = Convert.ToInt32(account[2]),
                        Autoboost = boost
                    };
                  
                    WebService.Players.Add(bot);
                    LoadedPlayers++;
                }

                Console.WriteLine("Loaded " + LoadedPlayers + " players.");
                file.Close();
            }

            if (!File.Exists("version.txt"))
                ClientVersion = Controller.GetCurrentVersion(WebService.Setting.GamePath);
            else ClientVersion = File.ReadAllText("version.txt");
            Console.WriteLine("Client version: " + ClientVersion);
            Console.WriteLine("Selected region: " + WebService.Setting.Region);

            
            Console.WriteLine("Bot will start in few seconds...");
            System.Timers.Timer eTimer = new System.Timers.Timer
            {
                AutoReset = false,
                Interval = 3000
            };
            eTimer.Elapsed += InitializeBotting;
            eTimer.Start();
        }
コード例 #2
0
        private static void LoadAccounts()
        {
            if (!Configuration.IsMySQLEnabled) return;
            using (var con = new MySqlConnection(Configuration.ConnectionString))
            {
                using (MySqlCommand cmd = con.CreateCommand())
                {
                    con.Open();
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = "SELECT * FROM accounts WHERE level < maxlevel;";

                    using (MySqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Accounts account = new Accounts
                            {
                                Id = (int) reader["id"],
                                Account = (string) reader["account"],
                                Password = (string) reader["password"],
                                Champion = (string) reader["champion"],
                                Maxlevel = (int) reader["maxlevel"],
                                Autoboost = Convert.ToBoolean(reader["autoboost"])
                            };

                            Players.Add(account);
                        }
                    }
                    con.Close();
                }
            }
        }