public void StartGame(bool player1AI, bool player2AI) { model = new BoardModel(); board.Setup(model); controller.Setup(model); controller.OnModelUpdate(OnModelUpdated); ClearPlayers(); ColorState player1Color = EnumsUtils.RandomColor(); AddPlayer(player1AI, player1Color); AddPlayer(player2AI, player1Color.Other()); gameUI.Setup(players[0], players[1]); controller.ResetBoard(); }
public void ActivateAcademy([FromBody] BaseID message) { var boxes = MongoRepository.GetCollection <Academy>(); var filter = Builders <Academy> .Filter.Eq("_id", new ObjectId(message.id)); var academy = boxes.Find <Academy>(filter).Project <Academy>("{ State : 1, EmailManager: 1}").SingleOrDefaultAsync().Result; if (academy.State == AcademyState.Draft) { var builder = Builders <Academy> .Update; var update = new List <UpdateDefinition <Academy> >(); update.Add(builder.Set("State", AcademyState.Active)); update.Add(builder.Push("Users", new AcademyUser() { Email = academy.EmailManager, Role = Role.BoxAdmin })); var r = boxes.UpdateOneAsync(filter, builder.Combine(update)).Result; var user = UserManager.FindByEmailAsync(academy.EmailManager).Result; if (user == null) { var appUser = new ApplicationUser { UserName = academy.EmailManager, Email = academy.EmailManager }; appUser.AddRole(EnumsUtils.GetName(Role.BoxAdmin)); var result = UserManager.CreateAsync(appUser, "Revolute2015!").Result; } } else { throw new APIException("You can only activate a Draft academy"); } }