private void CreateBotExpert(GameRoom gameRoom) { var userBotNewbies = new User(); var userBotExpert = new User(); using (var context = new DataContext()) { userBotNewbies = context.Users.FirstOrDefault(x => x.BotExpert == (int)JobType.Newbies); userBotExpert = context.Users.FirstOrDefault(x => x.BotExpert == (int)JobType.ExpertSpecialist); } if (userBotNewbies != null) { var userGameBotLevel1 = new UserGameRoom { GameRoomId = gameRoom.GameRoomId, PlayerName = "Junior (Risk Newbies)", JobType = (int)JobType.Newbies, TurnValue = 1, MoneyValue = gameRoom.MoneyValue, ProjectValue = gameRoom.ProjectValue, TeamValue = gameRoom.TeamValue, GameFinished = null, JoinDate = DateTime.UtcNow, UserId = userBotNewbies.UserId, Active = true, IsBot = true, ImageUrl = "/Content/sufee/images/newbies.png" }; _service.GameRoom().SaveUserGameRoomAsync(userGameBotLevel1); } if (userBotExpert != null) { var userGameBotLevel3 = new UserGameRoom { GameRoomId = gameRoom.GameRoomId, PlayerName = "Expert User (Risk Specialist)", JobType = (int)JobType.ExpertSpecialist, TurnValue = 1, MoneyValue = gameRoom.MoneyValue, ProjectValue = gameRoom.ProjectValue, TeamValue = gameRoom.TeamValue, GameFinished = null, JoinDate = DateTime.UtcNow, UserId = userBotExpert.UserId, Active = true, IsBot = true, ImageUrl = "/Content/sufee/images/expert.png" }; _service.GameRoom().SaveUserGameRoomAsync(userGameBotLevel3); } }
public bool registerUserRoom(UserGameRoom ugr) { try { user = new User() { Username = ugr.user.Username, Id = ugr.user.Id, Role = ugr.user.Role }; gameRoom = new GameRoom() {Id = ugr.gameRoom.Id, Date = ugr.gameRoom.Date, Name = ugr.gameRoom.Name, PainterId = ugr.gameRoom.PainterId, Users = ugr.gameRoom.Users }; return true; } catch (Exception e) { return false; } }
public void SaveUserGameRoomAsync(UserGameRoom userGameRoom) { _userGameRoom.AddAsync(userGameRoom); }
public void AddUserGameRoom(UserGameRoom userGameRoom) { _userGameRoom.Add(userGameRoom); }