public ActionResult Map(int id) { ApplicationUser user = userRepository.GetUser(User.Identity.GetUserId()); Game game = gameRepository.GetGame(id); if ((!game.IsBegan || game == null)) { return(RedirectToAction("GameList", "Home")); } UserGameProperty userGameProperty = userGamePropertyRepository.GetUserGameProperty(user, game); if (!userGameProperty.Active || userGameProperty == null) { return(RedirectToAction("GameList", "Home")); } CyclicProduct.CalculateGame(id); MapViewModel viewModel = new MapViewModel { Game = game, Property = userGameProperty, Islands = islandRepository.GetIslandsToMap(game), AllPlayers = userGamePropertyRepository.GetAllUserGameProperties(game) }; return(View(viewModel)); }
public static void CalculateGame(int id) { GameRepository gameRepository = Context.gameRepository; UserGamePropertyRepository userGamePropertyRepository = Context.userGamePropertyRepository; Game game = gameRepository.GetGame(id); List <UserGameProperty> properties = userGamePropertyRepository.GetAllUserGameProperties(game); //obliczanie ile minut upłyneło od ostatniego update int numberOfCycles = game.CalculateNumberOfCycles(); for (int i = 0; i < numberOfCycles; i++) { foreach (UserGameProperty property in properties) { property.CalculateGameForPlayer(); } } gameRepository.Save(); }