static void StartGame(ConnectionModule connection, string playerName, bool connectionTesting) { Log(Environment.NewLine); // TODO async var startInformation = connection.Initialize(GetAddress(), playerName); startInformation.Wait(); Log($"Received game start information."); if (startInformation.Result.WhitePlayer) { Log($"{_aiName} starts the game."); } else { Log($"Opponent starts the game."); } Log(Environment.NewLine); Log("Starting logic..."); var ai = new Logic(startInformation.Result, connectionTesting); Log("Start game loop"); // Inject ai to connection module and play game var playTask = connection.Play(ai); playTask.Wait(); }
private ConnectionModule CreateConnectionModuleAtPosition(Vector2Int position) { ConnectionModule connectionModule = new ConnectionModule(position, _ConnectionModules); _ConnectionModules.Add(connectionModule); FieldTiles[position.x, position.y].TileType = FieldTile.eTileType.Connection; return(connectionModule); }
public void List_OnExecute_OrdersConnectionsByHostThenDatabase() { List <ConnectionModel> connections = new List <ConnectionModel>(); connections.Add(new ConnectionModel() { Host = "Z", Database = "A" }); connections.Add(new ConnectionModel() { Host = "Y", Database = "Z" }); connections.Add(new ConnectionModel() { Host = "Y", Database = "B" }); connections.Add(new ConnectionModel() { Host = "Z", Database = "B" }); connections.Add(new ConnectionModel() { Host = "A", Database = "A" }); connections.Add(new ConnectionModel() { Host = "A", Database = "B" }); _userStore.Connections.Returns(connections); // execute ConnectionModule module = new ConnectionModule(_userStore, _connectionValidator, null, _workflowStoreService, _workflowStoreFactory); module.Context = new NancyContext(); var result = module.List(); // assert ConnectionListViewModel model = result.NegotiationContext.DefaultModel as ConnectionListViewModel; Assert.IsNotNull(model); Assert.AreEqual(model.WorkflowStores[0].ConnectionModel.Host, "A"); Assert.AreEqual(model.WorkflowStores[0].ConnectionModel.Database, "A"); Assert.AreEqual(model.WorkflowStores[1].ConnectionModel.Host, "A"); Assert.AreEqual(model.WorkflowStores[1].ConnectionModel.Database, "B"); Assert.AreEqual(model.WorkflowStores[2].ConnectionModel.Host, "Y"); Assert.AreEqual(model.WorkflowStores[2].ConnectionModel.Database, "B"); Assert.AreEqual(model.WorkflowStores[3].ConnectionModel.Host, "Y"); Assert.AreEqual(model.WorkflowStores[3].ConnectionModel.Database, "Z"); Assert.AreEqual(model.WorkflowStores[4].ConnectionModel.Host, "Z"); Assert.AreEqual(model.WorkflowStores[4].ConnectionModel.Database, "A"); Assert.AreEqual(model.WorkflowStores[5].ConnectionModel.Host, "Z"); Assert.AreEqual(model.WorkflowStores[5].ConnectionModel.Database, "B"); }
public static void Configure() { Mapper.Initialize(cfg => { PhotoGO.BLL.Infrastructure.AutoMapperConfig.Configure(cfg); PhotoGO.WEB.Binding.AutoMapperConfig.Configure(cfg); }); NinjectModule serviceModule = new ServiceModule(); NinjectModule connectionModule = new ConnectionModule("DefaultConnection"); var kernel = new StandardKernel(connectionModule, serviceModule); DependencyResolver.SetResolver(new NinjectDependencyResolver(kernel)); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); BLL.Infrastructure.AutoMapperConfig.Initialize(); //for unit of work binding NinjectModule uowModule = new ConnectionModule("DefaultConnection"); //for quest and reserv services binding NinjectModule serviceModule = new ServiceModule(); var kernel = new StandardKernel(uowModule, serviceModule); Application.Run(kernel.Get <Form1>()); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); BLL.Infrastructure.AutoMapperConfig.Initialize(); //for quest and reserv services binding NinjectModule orderModule = new ServiceModule(); //for binding unit of work NinjectModule serviceModule = new ConnectionModule("DefaultConnection"); var kernel = new StandardKernel(orderModule, serviceModule); DependencyResolver.SetResolver(new NinjectDependencyResolver(kernel)); }
/// <summary> /// Creates the kernel that will manage your application. /// </summary> /// <returns>The created kernel.</returns> private static IKernel CreateKernel() { NinjectModule dataModule = new ConnectionModule("DefaultConnection"); var kernel = new StandardKernel(dataModule); try { kernel.Bind <Func <IKernel> >().ToMethod(ctx => () => new Bootstrapper().Kernel); kernel.Bind <IHttpModule>().To <HttpApplicationInitializationHttpModule>(); RegisterServices(kernel); return(kernel); } catch { kernel.Dispose(); throw; } }
/// <summary> /// Creates the kernel that will manage your application. /// </summary> /// <returns>The created kernel.</returns> private static IKernel CreateKernel() { NinjectModule serviceModule = new ConnectionModule("WorkBaseConnectionString"); var kernel = new StandardKernel(serviceModule); try { kernel.Bind <Func <IKernel> >().ToMethod(ctx => () => new Bootstrapper().Kernel); kernel.Bind <IHttpModule>().To <HttpApplicationInitializationHttpModule>(); RegisterServices(kernel); GlobalConfiguration.Configuration.DependencyResolver = new NinjectDependencyResolver(kernel); return(kernel); } catch { kernel.Dispose(); throw; } }
public void List_UserHasConnectionDeleteClaim_CurrentUserCannotDeleteConnectionOnModelIsFalse() { // setup List <ConnectionModel> connections = new List <ConnectionModel>(); _userStore.Connections.Returns(connections); ConnectionModule module = new ConnectionModule(_userStore, _connectionValidator, _encryptionProvider, _workflowStoreService, _workflowStoreFactory); module.Context = new NancyContext(); module.Context.CurrentUser = new UserIdentity() { Claims = new string[] { } }; // execute var result = module.List(); // assert ConnectionListViewModel model = result.NegotiationContext.DefaultModel as ConnectionListViewModel; Assert.IsFalse(model.CurrentUserCanDeleteConnection); }
static void Main() { var connection = new ConnectionModule(); var startInformation = connection.Initialize("127.0.0.1:30052", "example player"); // Wait for the server to respond startInformation.Wait(); // Server tells the client is either starting player (white), // or black. If black, info also contains white players first move var result = startInformation.Result; // Initialize your own ai var ai = new ExampleAiLogic(result.WhitePlayer, result); // Inject ai to connection module and play game var playTask = connection.Play(ai); playTask.Wait(); // Game finished connection.CloseConnection(); }
private bool TryCreateConnectionToModule(Module module, FieldTile tile, List <FieldTile> unavailable) { if (unavailable.Contains(tile)) { return(false); } else { unavailable.Add(tile); } ConnectionModule connection = tile.TileType == FieldTile.eTileType.Connection ? tile.GetConnectionModule(_ConnectionModules) : CreateConnectionModuleAtPosition(tile.Position); if (connection != null) { if (connection.IsConnected(module.Bounds)) { return(true); } else { List <FieldTile> tiles = tile.GetAdjacentTilesOfType(FieldTiles, FieldTile.eTileType.Empty, FieldTile.eTileType.Connection); tiles.Sort((x, y) => x.GetDistanceToCenterOfModule(module).CompareTo(y.GetDistanceToCenterOfModule(module))); foreach (FieldTile t in tiles) { if (TryCreateConnectionToModule(module, t, unavailable)) { return(true); } } } } return(false); }
static void Main(string[] args) { Console.SetWindowSize(180, 40); var handle = GetStdHandle(-11); int mode; GetConsoleMode(handle, out mode); SetConsoleMode(handle, mode | 0x4); Log($"Chess ai {_aiName} [{_currentVersion}]"); while (true) { Log("[1] Start game"); Log("[2] Edit player name and start game"); Log("[3] Start local game with two vergiBlues against each other"); Log("[4] Start local game with two vergiBlues against each other. Delay between moves"); Log("[5] Custom local game"); Log("[9] Connection testing game"); Log("[Any] Exit"); Console.Write(" > "); var input = Console.ReadKey(); if (input.KeyChar.ToString() == "1") { var connection = new ConnectionModule(); StartGame(connection, _aiName, false); connection.CloseConnection(); } else if (input.KeyChar.ToString() == "2") { Log(Environment.NewLine); Log("Give player name: "); Console.Write(" > "); var playerName = Console.ReadLine(); Log($"Chess ai {playerName} [{_currentVersion}]"); var connection = new ConnectionModule(); StartGame(connection, playerName, false); connection.CloseConnection(); } else if (input.KeyChar.ToString() == "3") { StartLocalGame(0, null); } else if (input.KeyChar.ToString() == "4") { StartLocalGame(1000, null); } else if (input.KeyChar.ToString() == "5") { CustomLocalGame(); } else if (input.KeyChar.ToString() == "9") { var connection = new ConnectionModule(); StartGame(connection, "Connection test AI", true); connection.CloseConnection(); } else { break; } Log(Environment.NewLine); } }