Beispiel #1
0
        private List <string> PreValidateDatabaseSettings(InitialSetup model)
        {
            List <string> errors = new List <string>();

            if (model == null)
            {
                errors.Add("Database Settings cannot be empty");
            }
            if (string.IsNullOrWhiteSpace(model.DatabaseServer))
            {
                errors.Add("You must set a Database Server");
            }
            if (string.IsNullOrWhiteSpace(model.DatabaseName))
            {
                errors.Add("You must set a Database Name");
            }
            if (
                model.IntegratedSecuritySSPI == false && (
                    string.IsNullOrWhiteSpace(model.DatabaseUserId) ||
                    string.IsNullOrWhiteSpace(model.DatabaseUserPassword)))
            {
                errors.Add("You must set UserId and Password when not using Integrated Security");
            }
            return(errors);
        }
Beispiel #2
0
    // Use this for initialization
    void Start()
    {
        //Last time a life collectible was spawned.
        lifeSpawnedAt = 0f;

        //Time to spawn the next wave of blocks.
        timeToSpawn = 2f;

        //Not spawned a life collectible yet.
        spawnedLife = false;

        gm = GameObject.Find("Game Manager").GetComponent <GameManager>();

        isScript = GameObject.Find("Initial Setup").GetComponent <InitialSetup>();

        //How often should we spawn the block waves.
        spawnRate = isScript.spawnRate;

        //Gravity on the blocks. Use this to control how fast they fall down.
        velocity = isScript.blockVelocity;

        twoSpacingUnit = isScript.spacingUnit * 2f;

        fourSpacingUnit = isScript.spacingUnit * 4f;
    }
    // Use this for initialization
    void Start()
    {
        isScript = GameObject.Find("Initial Setup").GetComponent <InitialSetup>();
        gmGO     = GameObject.Find("Game Manager").GetComponent <GameManager>();

        isNotInGame = false;

        transform.localScale = new Vector2(isScript.spacingUnit * 4f, isScript.spacingUnit * 4f);

        //Calculate half the cam height
        camHeightHalf = GameObject.Find("Main Camera").GetComponent <Camera>().orthographicSize;

        //Calculate half the cam width
        camWidthHalf = camHeightHalf * GameObject.Find("Main Camera").GetComponent <Camera>().aspect;

        playableAreaHalfWidth = camWidthHalf;

        playableAreaBoundsLeft = -playableAreaHalfWidth + (isScript.spacingUnit * 3f);

        playableAreaBoundsRight = playableAreaHalfWidth - (isScript.spacingUnit * 3f);

        playableAreaBoundsUp = camHeightHalf - (transform.localScale.y / 2) - 0.5f;

        playableAreaBoundsDown = -camHeightHalf + (transform.localScale.y / 2) + 0.5f;

        transform.position = new Vector3(transform.position.x, -camHeightHalf + 1f, transform.position.z);
    }
        public void ShouldHighlightMovablePositions()
        {
            var game = new Game(new Board(3, 3, _ => false));

            game.Board[new Position(0, 0)].Piece = InitialSetup.CreatePiece(Spy.Rank, game.Players[0]);
            game.Board[new Position(0, 1)].Piece = InitialSetup.CreatePiece(Spy.Rank, game.Players[0]);
            game.Board[new Position(1, 0)].Piece = InitialSetup.CreatePiece(Spy.Rank, game.Players[0]);

            game.Board[new Position(2, 2)].Piece = InitialSetup.CreatePiece(Spy.Rank, game.Players[1]);

            var viewModel     = new GameViewModel(game);
            var cellPositions = GetCellPositions(viewModel);

            cellPositions(c => c.IsMovable).Should().BeEquivalentTo(new[] { new Position(0, 1), new Position(1, 0) });

            viewModel.Board[new Position(1, 0)].Background.Should().Be(KnownColors.Movable);
            viewModel.Board[new Position(0, 1)].Background.Should().Be(KnownColors.Movable);
            viewModel.Board[new Position(0, 0)].Background.Should().Be(KnownColors.NotMovable);
            viewModel.Board[new Position(2, 2)].Background.Should().Be(KnownColors.NotMovable);

            viewModel.Board[new Position(1, 0)].OnClick();
            viewModel.Board[new Position(1, 1)].OnClick();

            cellPositions(c => c.IsMovable).Should().BeEquivalentTo(new[] { new Position(2, 2) });
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            InitialSetup.InitializeWindow();
            SnakePlayer  snakePlayer  = new SnakePlayer("Nikolay");
            AppleHandler appleHandler = new AppleHandler();
            Timer        timer        = new Timer(x => appleHandler.GenerateApple(), null, 1000, 3000);

            Print.PrintWindow(snakePlayer);
            while (true)
            {
                if (!snakePlayer.IsAlive)
                {
                    Print.PrintEndGame(snakePlayer);
                    break;
                }
                Print.ClearSnake(snakePlayer);
                if (!Console.KeyAvailable)
                {
                    snakePlayer.Move(appleHandler);
                }
                else
                {
                    ConsoleKeyInfo keyPressed = Console.ReadKey();
                    snakePlayer.Move(keyPressed, appleHandler);
                }
                Print.PrintApples(appleHandler);
                Print.PrintSnake(snakePlayer);
                Thread.Sleep(100);
            }
        }
Beispiel #6
0
        public MainWindow()
        {
            InitializeComponent();

            Config.AppPath = Path.Combine(Environment.CurrentDirectory, "data");

            Config config = new Config();

            if (!config.Settings.InitialSetupRan || config.Settings.BotProjectPath == "" || config.Settings.DBMRootPath == "")
            {
                var init = new InitialSetup(config);
                init.ShowDialog();
            }


            spwindow = new DownloadManager();


            this.Title = "DBM Mods - Mod Manager";
            this.CustomTitleBar.Text = this.Title;

            this.ModItems = new ObservableCollection <ModItem>();

            lvMods.ItemsSource = AddModsToList(@"D:\Steam\steamapps\common\Discord Bot Maker\actions").OrderBy(x => x.Section);


            lvMods2.ItemsSource = AddModsToList(@"F:\Wrex\Desktop\DBM-Mods\actions").OrderBy(x => x.Section);
        }
Beispiel #7
0
        internal static RunInfoBuilder.RunInfoBuilder Create()
        {
            var builder = new RunInfoBuilder.RunInfoBuilder();

            builder.Commands
            .Add(InitialSetup.GetCommand())
            .Add(ViewState.GetCommand())
            .Add(UpdateRosters.GetCommand())
            .Add(AddStats.GetCommand())
            .Add(UpdateRosteredPlayers.GetCommand());

            builder.Version.Set(@"
  Current version is 1.0.0-alpha.2

  For more info and docs:
  https://github.com/rushfive/FFDB");

            builder.Help
            .OnTrigger(DisplayHelp)
            .InvokeOnBuildFail(suppressException: false);

            builder.Parser.SetPredicateForType <WeekInfo?>(value =>
            {
                if (string.IsNullOrWhiteSpace(value))
                {
                    return(false, default);
Beispiel #8
0
        public ActionResult InitialSetup(InitialSetup setup)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            var conString = $"Data Source={setup.ServerName};Initial Catalog={setup.DatabaseName};Persist Security Info=True;";

            if (setup.IntegratedSecurity)
            {
                conString += "Integrated Security = true;";
            }
            else
            {
                conString += $"User ID={setup.Username};Password={setup.Password};";
            }

            var path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            System.IO.File.AppendAllText(path + "\\creds.txt", conString);

            using (var context = new StudentAppDbContext())
            {
                context.Logs.Add(new Log
                {
                    Message = "Initial setup completed"
                });
                context.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }
        /// <summary>
        /// Main
        /// </summary>
        /// <param name="args"></param>
        public static void Main(string[] args)
        {
            // Initial Sku defined
            var listSku = InitialSetup.InitializeSku();
            Dictionary <string, int> skuUnit = new Dictionary <string, int>();

            Console.WriteLine("Enter the scenario with comma separated value eg: 3A,2B,1C");
            Console.WriteLine("Make sure to enter combination values with % specifiier eg: 1C%1D");

            string scenario = Console.ReadLine();

            // Get all the values from the config file
            foreach (string value in scenario.Split(","))
            {
                if (!value.Contains("%"))
                {
                    skuUnit.Add(value.Substring(value.Length - 1), Convert.ToInt32(value.Substring(0, value.Length - 1)));
                }
                else
                {
                    // In case of value contains % then set it 0 and get it from calculation
                    skuUnit.Add(value, 0);
                }
            }

            // Get the price from the CalculatePromotion
            double totalPrice = CalculatePromotion(skuUnit, listSku);

            Console.WriteLine("Price for the Listed Items are:" + totalPrice);

            Console.ReadLine();
        }
Beispiel #10
0
        private static void Main()
        {
            InitialSetup.Run();             //Finds and sets paths and settings used in the app

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new WebControl());
        }
Beispiel #11
0
        public static Game CreateWithDefaultSetup()
        {
            var game = new Game(Board.CreateStandard());

            InitialSetup.Setup(game, KnownSetups.VincentDeboer, 0);
            InitialSetup.Setup(game, KnownSetups.VincentDeboer, 1);

            return(game);
        }
Beispiel #12
0
            AttackTestContext(int attackerRank, int defenderRank)
            {
                Game = new Game(new Board(2, 1, _ => false));

                Attacker = Game.Board[Position1].Piece = InitialSetup.CreatePiece(attackerRank, Game.Players[0]);
                Defender = Game.Board[Position2].Piece = InitialSetup.CreatePiece(defenderRank, Game.Players[1]);

                GameViewModel = new GameViewModel(Game);
            }
Beispiel #13
0
        static void Main()
        {
#if GENERATECLASSES
            GenerateClasses();
#else
            ConsoleRedirect = new ConsoleStringWriter();
            Console.SetOut(ConsoleRedirect);

            //Set up the crash handler
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;


            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Prompt the user to specify the Dota 2 path if it has not been set
            InitialSetup initial = new InitialSetup(true);
            if (!initial.IsDotaDirSet())
            {
                Application.Exit();
                return;
            }

            // Ensure that the AddOnPath user setting was set
            if (!initial.IsAddOnPathSet())
            {
                Application.Exit();
                return;
            }

            Application.ApplicationExit += Application_ApplicationExit;
            System.Threading.Thread.CurrentThread.CurrentUICulture =
                System.Globalization.CultureInfo.CreateSpecificCulture(Properties.Settings.Default.Language);


            // Extract the Dota 2 pack01_dir VPK file and load all of the data
            AssetLoadingDialog assets = new AssetLoadingDialog();
            assets.ShowDialog(AssetLoadingDialog.InitialLoad);



            //Construct the main form and load the default project (if any).
            MainForm mainForm = new MainForm();
            if (IsLoaddedAddonDirectoryValid())
            {
                mainForm.LoadProject(Properties.Settings.Default.LoadedAddonDirectory);
            }

            CheckForUpdate.Check(true);

            Application.Run(mainForm);

            Properties.Settings.Default.Save();
#endif
        }
        public static InitialSetup ToInitialSetup(this Models.InitialSetup initialSetup)
        {
            var i = new InitialSetup
            {
                BoardSize = initialSetup.BoardSize
            };

            i.Dragons.AddRange(initialSetup.Dragons.Select(d => d.ToDragon()));
            i.AdditionalPieces.AddRange(initialSetup.AdditionalPieces.Select(p => p.ToPiece()));
            return(i);
        }
Beispiel #15
0
    // Use this for initialization
    void Start()
    {
        isScript = GameObject.Find("Initial Setup").GetComponent <InitialSetup>();

        fadeTime = 1f;                                                                                       //Time to fade out over

        moveDist = 3f;                                                                                       //Distance to move upwards

        finalPos = new Vector3(transform.position.x, transform.position.y + moveDist, transform.position.z); //Final position to move to

        transform.localScale = new Vector2(isScript.spacingUnit * 2f, isScript.spacingUnit * 2f);

        StartCoroutine(FadeOut());
    }
Beispiel #16
0
 public void LoadConfig()
 {
     if (File.Exists(configFullPath))
     {
         toSerialize = JsonConvert.DeserializeObject <ClientConfigDeSerial>(File.ReadAllText(configFullPath));
     }
     else
     {
         InitialSetup setupUI = new InitialSetup();
         setupUI.ShowDialog();
         setupUI.Dispose();
         SaveConfig();
     }
     LoadConfigToMemory(); // Used to load deserialized config into ClientConfig
 }
        public static Models.InitialSetup ToInitialSetup(this InitialSetup initialSetup)
        {
            if (initialSetup == null)
            {
                return(null);
            }
            var i = new Models.InitialSetup
            {
                BoardSize        = initialSetup.BoardSize,
                Dragons          = initialSetup.Dragons.Select(d => d.ToDragon()).ToList(),
                AdditionalPieces = initialSetup.AdditionalPieces.Select(p => p.ToPiece()).ToList()
            };

            return(i);
        }
Beispiel #18
0
        static void Main()
        {
#if GENERATECLASSES
            GenerateClasses();
#else
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Prompt the user to specify the Dota 2 path if it has not been set
            InitialSetup initial = new InitialSetup(true);
            if (!initial.IsDotaDirSet())
            {
                Application.Exit();
                return;
            }

            // Ensure that the AddOnPath user setting was set
            if (!initial.IsAddOnPathSet())
            {
                Application.Exit();
                return;
            }

            Application.ApplicationExit += Application_ApplicationExit;
            System.Threading.Thread.CurrentThread.CurrentUICulture =
                System.Globalization.CultureInfo.CreateSpecificCulture(Properties.Settings.Default.Language);

            HighlightingManager.Manager.AddSyntaxModeFileProvider(new FileSyntaxModeProvider(Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + "Resources"));

            // Extract the Dota 2 pack01_dir VPK file and load all of the data
            AssetLoadingDialog assets = new AssetLoadingDialog();
            assets.ShowDialog(AssetLoadingDialog.InitialLoad);

            //Construct the main form and load the default project (if any).
            MainForm mainForm = new MainForm();
            if (!String.IsNullOrEmpty(Properties.Settings.Default.LoadedAddonDirectory))
            {
                mainForm.LoadProject(Properties.Settings.Default.LoadedAddonDirectory);
            }



            Application.Run(mainForm);

            Properties.Settings.Default.Save();
#endif
        }
Beispiel #19
0
        public void ShouldShowPieceNames()
        {
            var min = Flag.Rank;
            var max = Bomb.Rank;

            var game = new Game(new Board(1, max - min + 1, _ => false));

            for (var rank = min; rank <= max; rank++)
            {
                game.Board[new Position(0, rank - min)].Piece = InitialSetup.CreatePiece(rank, game.Players[1]);
            }

            var viewModel = new GameViewModel(game);

            viewModel.Board.Cells.Select(c => c.PieceShortName).Should().Equal(new[] { "F", "S", "2", "3", "4", "5", "6", "7", "8", "9", "10", "B" });
            viewModel.Board.Cells.Select(c => c.PieceLongName).Should().Equal(new[] { "Flag", "Spy", "Scout", "Miner", "Sergeant", "Lieutenant", "Captain", "Major", "Colonel", "General", "Marshal", "Bomb" });
        }
Beispiel #20
0
        /// <summary>
        /// Configures the middleware for the application.
        /// </summary>
        /// <param name="app"></param>
        /// <param name="env"></param>
        /// <param name="serviceProvider"></param>
        /// <param name="configuration"></param>
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider, IConfiguration configuration)
        {
            // The inital setup section helps me set up an initial user in the database.
            // Otherwise I would have to build a complete password reset/registration system.
            InitialSetup.EnsureSuperUser(configuration, serviceProvider).Wait();

            if (env.IsDevelopment())
            {
                _ = app.UseDeveloperExceptionPage();
            }

            // The production environment has SSL termination in nginx.
            // On development I do want to use SSL to make sure that everything works as expected.
            if (env.IsDevelopment())
            {
                _ = app.UseHttpsRedirection();
            }

            // This middleware makes sure that everything operates as expected behind a reverse proxy.
            _ = app.UseForwardedHeaders(new ForwardedHeadersOptions
            {
                ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
            });

            // On nginx I'm using a static mapping to host the content in wwwroot.
            // So I don't need the static files middleware. Blazor is the one evil exception why I need the static
            // files middleware anyway.
            _ = app
                .UseStaticFiles()
                .UseRouting()
                .UseAuthentication()
                .UseAuthorization()
                .UseEndpoints(endpoints =>
            {
                _ = endpoints.MapBlazorHub();
                _ = endpoints.MapRazorPages();
                _ = endpoints.MapControllers();
            });
        }
Beispiel #21
0
        public void TestScenarioC()
        {
            // Initial Sku defined
            var listSku = InitialSetup.InitializeSku();
            Dictionary <string, int> skuUnit = new Dictionary <string, int>();

            // Input Scenario
            var scenario = "3A,5B,1C%1D";

            AddScenarioToDictionary(skuUnit, scenario);

            Dictionary <string, int> dictConfigValue = new Dictionary <string, int>();

            dictConfigValue.Add("3A", 130);
            dictConfigValue.Add("2B", 45);
            dictConfigValue.Add("1C%1D", 30);

            // Act
            double totalPrice = Program.CalculatePricingAlgorithm(skuUnit, listSku, 0, dictConfigValue);

            // Assert
            Assert.AreEqual(280, totalPrice);
        }
Beispiel #22
0
        private void setDotaDirectoryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form initial = new InitialSetup(false);

            initial.ShowDialog();
        }
Beispiel #23
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Addons",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                DateCreated = table.Column <DateTimeOffset>(nullable: false),
                DateUpdated = table.Column <DateTimeOffset>(nullable: true),
                Name        = table.Column <string>(maxLength: 100, nullable: false),
                Price       = table.Column <decimal>(type: "decimal(9,2)", nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Addons", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "OrderEvents",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                OrderId      = table.Column <int>(nullable: false),
                DateOccurred = table.Column <DateTimeOffset>(nullable: false),
                EventId      = table.Column <int>(nullable: false),
                Payload      = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_OrderEvents", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "Orders",
                columns: table => new
            {
                Id          = table.Column <int>(nullable: false),
                DateCreated = table.Column <DateTimeOffset>(nullable: false),
                DateUpdated = table.Column <DateTimeOffset>(nullable: true),
                ProductId   = table.Column <int>(nullable: false),
                AddonId     = table.Column <int>(nullable: true),
                TotalPrice  = table.Column <decimal>(type: "decimal(9,2)", nullable: false),
                Status      = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Orders", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "OrderStatuses",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Name = table.Column <string>(maxLength: 50, nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_OrderStatuses", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "Products",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                DateCreated = table.Column <DateTimeOffset>(nullable: false),
                DateUpdated = table.Column <DateTimeOffset>(nullable: true),
                Name        = table.Column <string>(maxLength: 100, nullable: false),
                Price       = table.Column <decimal>(type: "decimal(9,2)", nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Products", x => x.Id);
            });

            InitialSetup.Apply(migrationBuilder);
        }
Beispiel #24
0
 internal static System.Data.SqlClient.SqlConnectionStringBuilder BuildConnectionStringBuilder(InitialSetup model)
 {
     System.Data.SqlClient.SqlConnectionStringBuilder strCSB = new System.Data.SqlClient.SqlConnectionStringBuilder();
     strCSB.DataSource     = model.DatabaseServer;
     strCSB.InitialCatalog = model.DatabaseName;
     if (!model.IntegratedSecuritySSPI)
     {
         strCSB.IntegratedSecurity = false;
         strCSB.UserID             = model.DatabaseUserId;
         if (!string.IsNullOrWhiteSpace(model.DatabaseUserPassword))
         {
             strCSB.Password = model.DatabaseUserPassword;
         }
     }
     else
     {
         strCSB.IntegratedSecurity = true;
     }
     if (!string.IsNullOrWhiteSpace(model.DatabaseApplicationName))
     {
         strCSB.ApplicationName = model.DatabaseApplicationName;
     }
     return(strCSB);
 }