public void AddPlayerTest() { var level = new Model.Data.Levels.Level(); var rules = new Dictionary <int, int> { { 1, 10 }, { 5, 15 }, { 20, 13 }, { 30, 18 } }; var configModel = new Model.Configuration.ConfigModel(rules, 50); var hostEnvMock = new Mock <IHostEnvironment>(); hostEnvMock .Setup(m => m.ContentRootPath) .Returns(AppDomain.CurrentDomain.BaseDirectory); var optionsMock = Options.Create(new SnakesAndLaddersConfig() { ConfigFileName = "levelConfig.json" }); var loader = new JsonConfigLoader(hostEnvMock.Object, optionsMock); var game = new Model.Game.SnakesAndLadders(level, new Model.Data.Dice.Dice(), loader, optionsMock); Assert.NotNull(game.AddPlayer(new Model.Data.DTO.Input.AddPlayerInput { PlayerID = "1", PlayerName = "Ron" })); Thread.Sleep(1000); Assert.True(game.GetStatus(new Model.Data.DTO.Input.GetStatusInput { PlayerID = "1" }).HasHighestScore); //single player must have highest score Assert.NotNull(game.AddPlayer(new Model.Data.DTO.Input.AddPlayerInput { PlayerID = "1", PlayerName = "Ron" })); //player can play twice Thread.Sleep(1000); Assert.NotEqual( game.GetStatus(new Model.Data.DTO.Input.GetStatusInput { PlayerID = "1" }).Status, Model.Data.Players.PlayerStatus.Unknown.ToString()); Assert.Equal( game.GetStatus(new Model.Data.DTO.Input.GetStatusInput { PlayerID = "5" }).Status, Model.Data.Players.PlayerStatus.Unknown.ToString()); //unknown player }
public void ExtractAlliedHeroMugshotsByScreenShot() { var loadMugshotLocations = JsonConfigLoader.GetMugshotLocations(); var extractHeroMugshotsByScreenShot = HeroMugshotBitmapExtractor.ExtractHeroMugshotsByScreenShot( (Bitmap)Bitmap.FromFile( FakeScreenShotPath), loadMugshotLocations.AlliedLocationPoints, loadMugshotLocations.PortraitWidth, loadMugshotLocations.PortraitHeight); Assert.True(extractHeroMugshotsByScreenShot.Any()); }
// TODO private static void DefaultMain() { var loader = new JsonConfigLoader(); var config = new DatabasesConfig { Accounts = new DatabaseSettings { FileName = "accounts.db", Password = "******" }, Characters = new DatabaseSettings { FileName = "characters.db", Password = null }, World = new DatabaseSettings { FileName = "world.db", Password = null } }; var accounts = new AccountsDatabase(config.Accounts); try { config = loader.Load <DatabasesConfig>("database"); ConnectToMasterRouterAsync(IPAddress.Loopback, 12000).RunAsync(); Console.ReadLine(); } catch (DirectoryNotFoundException ex) { Console.Error.WriteLine("Config directory not found, attempting to create default file..."); Directory.CreateDirectory(loader.RootDirectory); loader.CreateDefault("database", config); } catch (FileNotFoundException ex) { Console.Error.WriteLine("Config file not found, attempting to create default file..."); loader.CreateDefault("database", config); } finally { accounts.Dispose(); } }
private void ApplicationStartup(object sender, StartupEventArgs e) { Log.Information("Started Catapult."); if (!Directory.Exists(CatapultPaths.DataPath)) { Directory.CreateDirectory(CatapultPaths.DataPath); } var loader = new JsonConfigLoader(); var configuration = loader.LoadUserConfig(CatapultPaths.ConfigPath); loader.SaveUserConfig(configuration, CatapultPaths.ConfigPath); Task.Factory.StartNew(() => { SearchResources.SetConfig(configuration); SearchResources.GetFiles(); }); _taskbarIcon = (TaskbarIcon)FindResource("MyNotifyIcon"); InitializeTaskBarIcon(_taskbarIcon); _hotKeyManager = new HotKeyManager(); RegisterHotKey(Key.Space, configuration.UseControlKey ? ModifierKeys.Control : ModifierKeys.Alt); _mainWindow = new MainWindow(); _mainWindow.IsVisibleChanged += _mainWindow_IsVisibleChanged; if (Program.UseSingleLaunchMode) { ToggleMainWindow(); } SquirrelIntegration.Instance.StartPeriodicUpdateCheck(); }
public void IdentifyAllEnemyHeroesByScreenShot() { HeroMugshotIdentifier heroMugshotIdentifier = new HeroMugshotIdentifier(); var loadMugshotLocations = JsonConfigLoader.GetMugshotLocations(); var extractHeroMugshotsByScreenShot = HeroMugshotBitmapExtractor.ExtractHeroMugshotsByScreenShot( (Bitmap)Bitmap.FromFile( FakeScreenShotPath), loadMugshotLocations.EnemyLocationPoints, loadMugshotLocations.PortraitWidth, loadMugshotLocations.PortraitHeight); List <int> correctMugshotsHeroIdsOnFakeScreenshot = new List <int>() { 17, 18, 19, 1, 17, 12 }; int index = 0; foreach (var mugshot in extractHeroMugshotsByScreenShot) { var heroIdByMugshot = heroMugshotIdentifier.GetHeroIdByMugshot( mugshot, JsonConfigLoader.GetHeroIdMugshotBitmaps()); Assert.True(correctMugshotsHeroIdsOnFakeScreenshot[index] == heroIdByMugshot); index++; } }
public void HeroesConfig() { var heroes = JsonConfigLoader.GetHeroConfig(); Assert.True(heroes.Any()); }
public void LoadMugshotsConfig() { var mugshotLocations = JsonConfigLoader.GetMugshotLocations(); Assert.True(mugshotLocations.EnemyLocationPoints.Any()); }