Esempio n. 1
0
        public static IPockyBot CreatePockyBot(PockyBotSettings settings, IChatHelper chatHelper, IResultsUploader resultsUploader, ILoggerFactory loggerFactory)
        {
            var wrappedSettings        = new OptionsWrapper <PockyBotSettings>(settings);
            var dbContext              = DatabaseContextBuilder.BuildDatabaseContext(settings.DatabaseConnectionString);
            var pockyUserRepository    = new PockyUserRepository(dbContext);
            var configRepository       = new ConfigRepository(dbContext);
            var pegRepository          = new PegRepository(dbContext);
            var locationRepository     = new LocationRepository(dbContext);
            var userLocationRepository = new UserLocationRepository(dbContext);

            var triggerResponseTester = new TriggerResponseTester(wrappedSettings, pockyUserRepository);
            var pegRequestValidator   = new PegRequestValidator(wrappedSettings, configRepository);
            var pegHelper             = new PegHelper(configRepository);
            var pegGiver = new PegGiver(pegRepository, chatHelper);
            var directResultsMessageSender = new DirectResultsMessageSender(chatHelper.Messages);
            var pegResultsHelper           = new PegResultsHelper(configRepository, pegHelper);
            var userLocationGetter         = new UserLocationGetter(pockyUserRepository);
            var userLocationSetter         =
                new UserLocationSetter(pockyUserRepository, locationRepository, userLocationRepository, chatHelper);
            var userLocationDeleter  = new UserLocationDeleter(userLocationRepository);
            var resultsFileGenerator = new ResultsFileGenerator(pegResultsHelper, loggerFactory.CreateLogger <ResultsFileGenerator>(), resultsUploader);
            var usernameUpdater      = new UsernameUpdater(chatHelper.People, pockyUserRepository);

            var triggers = new List <ITrigger>
            {
                new Ping(),
                new Help(pockyUserRepository, wrappedSettings, configRepository),
                new Welcome(wrappedSettings, configRepository),
                new Peg(pegRequestValidator, pockyUserRepository, pegHelper, configRepository, chatHelper, pegGiver, loggerFactory.CreateLogger <Peg>()),
                new Status(pockyUserRepository, configRepository, pegHelper, loggerFactory.CreateLogger <Status>()),
                new Results(pockyUserRepository, pegResultsHelper, resultsFileGenerator, loggerFactory.CreateLogger <Results>()),
                new Finish(pockyUserRepository, pegResultsHelper, directResultsMessageSender, resultsFileGenerator, loggerFactory.CreateLogger <Finish>(), usernameUpdater),
                new Reset(pegRepository, loggerFactory.CreateLogger <Reset>()),
                new Keywords(configRepository),
                new Rotation(configRepository),
                new LocationConfig(locationRepository, pockyUserRepository),
                new UserLocation(pockyUserRepository, userLocationGetter, userLocationSetter, userLocationDeleter),
                new NumberConfig(configRepository),
                new StringConfig(configRepository),
                new RoleConfig(pockyUserRepository, chatHelper),
                new RemoveUser(pockyUserRepository, loggerFactory.CreateLogger <RemoveUser>()),
                new LocationWeight(configRepository, locationRepository),
                new Default(wrappedSettings)
            };

            return(new PockyBot(triggers, triggerResponseTester, chatHelper, loggerFactory.CreateLogger <PockyBot>()));
        }
Esempio n. 2
0
        private void Play_Click(object sender, RoutedEventArgs e)
        {
            switch (InstallPlayIcon.Kind)
            {
            case PackIconKind.Download:
                switch (((MainWindow)Application.Current.MainWindow).GameInstall.Header)
                {
                case "Age of Empires II HD":
                    new Download("AoE2HD", $"http://{Properties.Settings.Default.ServerIP}/jeux/AoE2HD.zip").ShowDialog();
                    UsernameUpdater.SetName("AoE2HD");
                    InstallLocation = Properties.Settings.Default.AoE2HD_Location;
                    break;

                case "Battlefield 3":
                    new Download("BF3", $"http://{Properties.Settings.Default.ServerIP}/jeux/BF3.zip").ShowDialog();
                    UsernameUpdater.SetName("BF3");
                    InstallLocation = Properties.Settings.Default.BF3_Location;
                    break;

                case "Blur":
                    new Download("Blur", $"http://{Properties.Settings.Default.ServerIP}/jeux/Blur.zip").ShowDialog();
                    UsernameUpdater.SetName("Blur");
                    InstallLocation = Properties.Settings.Default.Blur_Location;
                    break;

                case "Call of Duty 2":
                    new Download("CoD2", $"http://{Properties.Settings.Default.ServerIP}/jeux/CoD2.zip").ShowDialog();
                    UsernameUpdater.SetName("CoD2");
                    InstallLocation = Properties.Settings.Default.CoD2_Location;
                    break;

                case "Call of Duty 4":
                    new Download("CoD4", $"http://{Properties.Settings.Default.ServerIP}/jeux/CoD4.zip").ShowDialog();
                    UsernameUpdater.SetName("CoD4");
                    InstallLocation = Properties.Settings.Default.CoD4_Location;
                    break;

                case "Call of Duty 5":
                    new Download("CoD5", $"http://{Properties.Settings.Default.ServerIP}/jeux/CoD5.zip").ShowDialog();
                    UsernameUpdater.SetName("CoD5");
                    InstallLocation = Properties.Settings.Default.CoD5_Location;
                    break;

                case "Counter Strike: Global Offensive":
                    new Download("CSGO", $"http://{Properties.Settings.Default.ServerIP}/jeux/CSGO.zip").ShowDialog();
                    UsernameUpdater.SetName("CSGO");
                    InstallLocation = Properties.Settings.Default.CSGO_Location;
                    break;

                case "DoTA 2":
                    new Download("DoTA2", $"http://{Properties.Settings.Default.ServerIP}/jeux/DoTA2.zip").ShowDialog();
                    UsernameUpdater.SetName("DoTA2");
                    InstallLocation = Properties.Settings.Default.DoTA2_Location;
                    break;

                case "Day of Defeat: Source":
                    new Download("DoDS", $"http://{Properties.Settings.Default.ServerIP}/jeux/DoDS.zip").ShowDialog();
                    UsernameUpdater.SetName("DoDS");
                    InstallLocation = Properties.Settings.Default.DoDS_Location;
                    break;

                case "Flatout 2":
                    new Download("Flatout2", $"http://{Properties.Settings.Default.ServerIP}/jeux/Flatout2.zip").ShowDialog();
                    UsernameUpdater.SetName("Flatout2");
                    InstallLocation = Properties.Settings.Default.F2_Location;
                    break;

                case "Left 4 Dead 2":
                    new Download("L4D2", $"http://{Properties.Settings.Default.ServerIP}/jeux/L4D2.zip").ShowDialog();
                    UsernameUpdater.SetName("L4D2");
                    InstallLocation = Properties.Settings.Default.L4D2_Location;
                    break;

                case "StarCraft 2":
                    new Download("SC2", $"http://{Properties.Settings.Default.ServerIP}/jeux/SC2.zip").ShowDialog();
                    UsernameUpdater.SetName("SC2");
                    InstallLocation = Properties.Settings.Default.SC2_Location;
                    break;

                case "Shootmania":
                    new Download("Shootmania", $"http://{Properties.Settings.Default.ServerIP}/jeux/Shootmania.zip").ShowDialog();
                    UsernameUpdater.SetName("Shootmania");
                    InstallLocation = Properties.Settings.Default.Shootmania_Location;
                    break;

                case "Star Wars: Jedi Knight 2":
                    new Download("SWJK2", $"http://{Properties.Settings.Default.ServerIP}/jeux/SWJK2.zip").ShowDialog();
                    UsernameUpdater.SetName("SWJK2");
                    InstallLocation = Properties.Settings.Default.SWJK2_Location;
                    break;

                case "Team Fortress 2":
                    new Download("TF2", $"http://{Properties.Settings.Default.ServerIP}/jeux/TF2.zip").ShowDialog();
                    UsernameUpdater.SetName("TF2");
                    InstallLocation = Properties.Settings.Default.TF2_Location;
                    break;

                case "Unreal Tournament 3":
                    new Download("UT3", $"http://{Properties.Settings.Default.ServerIP}/jeux/UT3.zip").ShowDialog();
                    UsernameUpdater.SetName("UT3");
                    InstallLocation = Properties.Settings.Default.UT3_Location;
                    break;
                }

                Properties.Settings.Default.Save();
                InstallPlayIcon.Kind = PackIconKind.Play;
                break;

            case PackIconKind.Play:
                var game = new ProcessStartInfo();

                switch (((MainWindow)Application.Current.MainWindow).GameInstall.Header)
                {
                case "Age of Empires II HD":
                    game = new ProcessStartInfo
                    {
                        WorkingDirectory = Path.Combine(Properties.Settings.Default.AoE2HD_Location),
                        FileName         = Path.Combine(Properties.Settings.Default.AoE2HD_Location, "SmartSteamLoader.exe")
                    };
                    Process.Start(game);
                    break;

                case "Battlefield 3":
                    game = new ProcessStartInfo
                    {
                        WorkingDirectory = Properties.Settings.Default.BF3_Location,
                        FileName         = Path.Combine(Properties.Settings.Default.BF3_Location, "_StartGame.bat")
                    };
                    Process.Start(game);
                    break;

                case "Blur":
                    game = new ProcessStartInfo
                    {
                        WorkingDirectory = Properties.Settings.Default.Blur_Location,
                        FileName         = Path.Combine(Properties.Settings.Default.Blur_Location, "BLUR_LAUNCHER.bat")
                    };
                    Process.Start(game);
                    break;

                case "Call of Duty 2":
                    game = new ProcessStartInfo
                    {
                        WorkingDirectory = Properties.Settings.Default.CoD2_Location,
                        FileName         = Path.Combine(Properties.Settings.Default.CoD2_Location, "CoD2MP_s.exe")
                    };
                    Process.Start(game);
                    break;

                case "Call of Duty 4":
                    game = new ProcessStartInfo
                    {
                        WorkingDirectory = Properties.Settings.Default.CoD4_Location,
                        FileName         = Path.Combine(Properties.Settings.Default.CoD4_Location, "iw3mp.exe")
                    };
                    Process.Start(game);
                    break;

                case "Call of Duty 5":
                    game = new ProcessStartInfo
                    {
                        WorkingDirectory = Properties.Settings.Default.CoD5_Location,
                        FileName         = Path.Combine(Properties.Settings.Default.CoD5_Location, "CoDWaW LanFixed.exe")
                    };
                    Process.Start(game);
                    break;

                case "Counter Strike: Global Offensive":
                    game = new ProcessStartInfo
                    {
                        WorkingDirectory = Properties.Settings.Default.CSGO_Location,
                        FileName         = Path.Combine(Properties.Settings.Default.CSGO_Location, "revLoader.exe")
                    };
                    Process.Start(game);
                    break;

                case "DoTA 2":
                    game = new ProcessStartInfo
                    {
                        WorkingDirectory = Properties.Settings.Default.DoTA2_Location,
                        FileName         = Path.Combine(Properties.Settings.Default.DoTA2_Location, "revLoader.exe")
                    };
                    Process.Start(game);
                    break;

                case "Day of Defeat: Source":
                    game = new ProcessStartInfo
                    {
                        WorkingDirectory = Properties.Settings.Default.DoDS_Location,
                        FileName         = Path.Combine(Properties.Settings.Default.DoDS_Location, "Day_of_Defeat_Source.exe")
                    };
                    Process.Start(game);
                    break;

                case "Flatout 2":
                    game = new ProcessStartInfo
                    {
                        WorkingDirectory = Properties.Settings.Default.F2_Location,
                        FileName         = Path.Combine(Properties.Settings.Default.F2_Location, "flatout2multi.exe")
                    };
                    Process.Start(game);
                    break;

                case "Left 4 Dead 2":
                    game = new ProcessStartInfo
                    {
                        WorkingDirectory = Properties.Settings.Default.L4D2_Location,
                        FileName         = Path.Combine(Properties.Settings.Default.L4D2_Location, "left4dead2.exe")
                    };
                    Process.Start(game);
                    break;

                case "StarCraft 2":
                    game = new ProcessStartInfo
                    {
                        WorkingDirectory = Properties.Settings.Default.SC2_Location,
                        FileName         = Path.Combine(Properties.Settings.Default.SC2_Location, "StarFriend_Client.exe")
                    };
                    Process.Start(game);
                    break;

                case "Shootmania":
                    game = new ProcessStartInfo
                    {
                        WorkingDirectory = Properties.Settings.Default.Shootmania_Location,
                        FileName         = Path.Combine(Properties.Settings.Default.Shootmania_Location, "ManiaPlanetLauncher.exe")
                    };
                    Process.Start(game);
                    break;

                case "Star Wars: Jedi Knight 2":
                    game = new ProcessStartInfo
                    {
                        WorkingDirectory = Path.Combine(Properties.Settings.Default.SWJK2_Location, "GameData"),
                        FileName         = Path.Combine(Properties.Settings.Default.SWJK2_Location, "GameData", "jk2mp.exe")
                    };
                    Process.Start(game);
                    break;

                case "Team Fortress 2":
                    game = new ProcessStartInfo
                    {
                        WorkingDirectory = Properties.Settings.Default.TF2_Location,
                        FileName         = Path.Combine(Properties.Settings.Default.TF2_Location, "revLoader.exe")
                    };
                    Process.Start(game);
                    break;

                case "Unreal Tournament 3":
                    game = new ProcessStartInfo
                    {
                        WorkingDirectory = Path.Combine(Properties.Settings.Default.UT3_Location, "Binaries"),
                        FileName         = Path.Combine(Properties.Settings.Default.UT3_Location, "Binaries", "UT3.exe")
                    };
                    Process.Start(game);
                    break;
                }
                break;
            }
        }