protected override IEnumerable<CardViewModel> PrioritiseCards(GameViewModel state, ActivityModel activity) { return state.Hand .OrderByDescending(c => c.Is(CardType.Treasure) == false) .ThenByDescending(c => c.Is(CardType.Action) == false) .ThenBy(c => c.Cost); }
protected override CardPileViewModel SelectPile(GameViewModel state) { return GetValidBuys(state) .Where(pile => pile.Is(CardType.Victory)) .OrderByDescending(pile => pile.Cost) .First(); }
protected override CardPileViewModel SelectPile(GameViewModel state, IGameClient client) { return GetValidBuys(state) .Where(pile => pile.Is(CardType.Victory)) .OrderByDescending(pile => VictoryCards.Basic.Contains(pile.Name)) .First(); }
protected override void HandleActivity(ActivityModel activity, GameViewModel state) { ActivityType activityType = (ActivityType)Enum.Parse(typeof(ActivityType), activity.Type); switch (activityType) { case ActivityType.PlayActions: case ActivityType.DoBuys: _client.AcceptMessage(DoTurn(state)); break; case ActivityType.SelectFixedNumberOfCards: { int cardsToDiscard = int.Parse(activity.Properties["NumberOfCardsToSelect"].ToString()); DiscardCards(cardsToDiscard, state); break; } case ActivityType.SelectFromRevealed: { SelectFromRevealed(activity, state); break; } case ActivityType.MakeChoice: { MakeChoice(activity, state); break; } } }
protected override IList<string> GetPriorities(GameViewModel state) { var priorites = base.GetPriorities(state); priorites.Insert(priorites.IndexOf("Silver"), "Militia"); return priorites; }
protected override CardPileViewModel SelectPile(GameViewModel state, IGameClient client) { return GetValidBuys(state) .Where(pile => Treasure.Basic.Contains(pile.Name)) .OrderByDescending(pile => pile.Cost) .First(); }
protected override IEnumerable<CardViewModel> PrioritiseCards(GameViewModel state, ActivityModel activity) { return state.Hand .OrderByDescending(c => c.Is(CardType.Curse)) .ThenByDescending(c => c.Is<Estate>()) .ThenBy(c => c.Cost); }
public void Respond(IGameClient client, ActivityModel activity, GameViewModel state) { if(!_enumerator.Current.CanRespond(activity, state)) _enumerator.MoveNext(); _enumerator.Current.Respond(client, activity, state); _enumerator.MoveNext(); }
protected virtual IList<string> GetPriorities(GameViewModel state) { var priorities = new List<string> {"Colony", "Platinum", "Province", "Gold", "Silver", "Copper"}; if(state.Bank.Single(p => p.Name == "Province").Count < 7) priorities.Insert(3, "Duchy"); return priorities; }
public void Respond(IGameClient client, ActivityModel activity, GameViewModel state) { var pile = SelectPile(state); TalkSmack(pile, client); var message = new BuyCardMessage(client.PlayerId, pile.Id); client.AcceptMessage(message); }
public override bool CanRespond(ActivityModel activity, GameViewModel state) { var potionPile = state.Bank.SingleOrDefault(p => p.Is<Potion>()); return base.CanRespond(activity, state) && potionPile != null && potionPile.CanBuy && state.Status.AvailableSpend.Money == potionPile.Cost; }
protected override CardPileViewModel SelectPile(GameViewModel state) { return GetValidBuys(state) .Where(pile => AISupportedActions.All.Contains(pile.Name)) .OrderByDescending(pile => pile.Cost) .ThenBy(pile => _random.Next(100)) .First(); }
protected override IGameActionMessage DoTurn(GameViewModel state) { var militia = state.Hand.FirstOrDefault(c => c.Name == "Militia"); if (state.Status.InBuyStep || militia == null) return base.DoTurn(state); else return new PlayCardMessage(_client.PlayerId, militia.Id); }
public void Respond(IGameClient client, ActivityModel activity, GameViewModel state) { var idsToTrash = state.Hand.Where(c => c.Is<Curse>() || c.Is<Copper>() || c.Is<Estate>()) .Select(c => c.Id) .Take(activity.ParseNumberOfCardsToSelect()) .ToArray(); client.AcceptMessage(new SelectCardsMessage(client.PlayerId, idsToTrash)); }
protected virtual void MakeChoice(ActivityModel activity, GameViewModel state) { IEnumerable<string> options = (IEnumerable<string>)activity.Properties["AllowedOptions"]; var choice = options.FirstOrDefault(x => x == "Yes") ?? options.First(); _client.AcceptMessage(new ChoiceMessage(_client.PlayerId, choice)); }
protected override void DiscardCards(int count, GameViewModel currentState) { var discardPreference = new List<string> { "Estate", "Duchy", "Province", "Curse", "Colony", "Copper", "Silver", "Gold", "Platinum" }; var orderedHand = currentState.Hand .OrderBy(c => discardPreference.IndexOf(c.Name)).ToList(); var cardIdsToDiscard = orderedHand.Take(count).Select(c => c.Id).ToArray(); var discardAction = new SelectCardsMessage(_client.PlayerId, cardIdsToDiscard.ToArray()); _client.AcceptMessage(discardAction); }
protected override IEnumerable<CardViewModel> PrioritiseCards(GameViewModel state, ActivityModel activity) { return state.Hand .Where(c => !activity.HasTypeRestriction() || c.Types.Contains(activity.ParseTypeRestriction())) .OrderByDescending(c => c.Is(CardType.Treasure) == false) .ThenByDescending(c => c.Is(CardType.Action) == false) .ThenBy(c => c.Cost); }
public ActionResult ViewGameList() { using (var gamerepo = new GameRepository()) { var model = new GameViewModel(); model.Games = gamerepo.ViewGames(); return View(model); } }
protected override IEnumerable<CardViewModel> PrioritiseCards(GameViewModel state, ActivityModel activity) { var actions = state.Hand .Where(c => c.Is(CardType.Action)) .Where(c => AISupportedActions.All.Contains(c.Name)) .OrderByDescending(c => c.Cost) .Take(activity.ParseNumberOfCardsToSelect()); return actions; }
public FleetsViewModel(GameViewModel rpOwner) { Owner = rpOwner; KanColleGame.Current.ObservablePropertyChanged.Where(r => r == "Fleets").Subscribe(_ => { Fleets = KanColleGame.Current.Fleets.Values.Select(r => new FleetViewModel(Owner, r)).ToArray(); SelectedFleet = Fleets.FirstOrDefault(); }); }
protected override CardPileViewModel SelectPile(GameViewModel state, IGameClient client) { var options = GetValidBuys(state).Where(c => _distribution.Contains(c.Name)); var exactValueOptions = options .Where(pile => pile.Cost.ToString() == state.Status.AvailableSpend.DisplayValue); return exactValueOptions.Any() ? _distribution.RandomItem(exactValueOptions, c => c.Name) : _distribution.RandomItem(options, c => c.Name); }
public void Respond(IGameClient client, ActivityModel activity, GameViewModel state) { var options = activity.ParseOptions(); Choice choice = options.First(); if (options.Contains(Choice.Yes)) choice = Choice.Yes; client.AcceptMessage(new ChoiceMessage(client.PlayerId, choice.ToString())); }
public GamePage() { InitializeComponent(); var gameViewModel = new GameViewModel(DisMenu, MenuPlayer); DataContext = gameViewModel; gameViewModel.OpenListPicker += (sender, e) => ListPickerPrizeLand.Open(); OrientationChanged += MainPage_OrientationChanged; _lastOrientation = Orientation; }
public void Respond(IGameClient client, ActivityModel activity, GameViewModel state) { var action = state.Hand .Where(c => c.Is(CardType.Action)) .Where(c => AISupportedActions.All.Contains(c.Name)) .OrderByDescending(c => AISupportedActions.PlusActions.Contains(c.Name)) .ThenByDescending(c => c.Cost) .First(); var message = new PlayCardMessage(client.PlayerId, action.Id); client.AcceptMessage(message); }
protected override void HandleActivity(ActivityModel activity, GameViewModel state) { if (activity.ParseType() == ActivityType.WaitingForOtherPlayers) return; var behaviour = Behaviours.FirstOrDefault(b => b.CanRespond(activity, state)); if(behaviour == null) throw new NoBehaviourException(activity); behaviour.Respond(_client, activity, state); }
public void Respond(IGameClient client, ActivityModel activity, GameViewModel state) { var decklist = client.GetDecklist(); if (state.Results.Winner == client.PlayerName) { foreach (var card in decklist.Where(c => _distribution.Contains(c.Name))) { _distribution.IncreaseLikelihood(card.Name); } } }
public void Respond(IGameClient client, ActivityModel activity, GameViewModel state) { int count = activity.ParseNumberOfCardsToSelect(); var ids = PrioritiseCards(state, activity) .Take(count) .Select(c => c.Id) .ToArray(); var message = new SelectCardsMessage(client.PlayerId, ids); client.AcceptMessage(message); }
protected override CardPileViewModel SelectPile(GameViewModel state, IGameClient client) { var options = GetValidBuys(state) .Where(pile => AISupportedActions.All.Contains(pile.Name)) .OrderByDescending(pile => pile.Cost) .ThenBy(pile => _random.Next(100)) .ToList(); var message = string.Format("I considered {0}.", string.Join(", ", options.Select(x => x.Name).ToArray())); client.SendChatMessage(message); return options.FirstOrDefault(); }
protected virtual void HandleActivity(ActivityModel activity, GameViewModel state) { switch (activity.Type) { case "SelectFixedNumberOfCards": { int cardsToDiscard = int.Parse(activity.Properties["NumberOfCardsToSelect"].ToString()); DiscardCards(cardsToDiscard, state); break; } case "SelectFromRevealed": { SelectFromRevealed(activity, state); break; } } }
protected virtual void Respond(GameViewModel state) { lock (_gate) { //This is to avoid double-handling events if (_lastGameStateVersionHandled >= state.Version) return; _lastGameStateVersionHandled = state.Version; var activity = state.PendingActivity; if (_lastActivityHandled != activity.Id) { _lastActivityHandled = activity.Id; HandleActivity(activity, state); } } }
public async Task <ActionResult> Edit(GameViewModel gameViewModel) { if (ModelState.IsValid) { try { var game = ModelMapper.MapGame(gameViewModel); await _gameRepository.CreateOrEditAsync(game); await db.SaveChangesAsync(); ViewBag.Success = "Os dados do jogo foram salvos com sucesso."; TransportViewData(); return(RedirectToAction("Index")); } catch (Exception ex) { ModelState.AddModelError(string.Empty, ExtractEntityMessage(ex)); } } return(View(gameViewModel)); }
public ActionResult AdjustBet(GameViewModel model) { try { EnsureAccessToken(); var txList = new List <BetCommandTransactionRequest> { new BetCommandTransactionRequest { Amount = model.OperationAmount, CurrencyCode = "CAD", RoundId = model.RoundId.ToString(), Description = model.Description, Id = Guid.NewGuid().ToString(), TimeStamp = DateTimeOffset.UtcNow, ReferenceId = model.TransactionId } }; var response = CallAdjustTransaction(model.Token, txList); if (response.ErrorCode != GameApiErrorCode.NoError) { throw new GameApiException(response.ErrorDescription); } return(RedirectToAction("Index", new { token = model.Token })); } catch (GameApiException ex) { return(View("Index", new GameViewModel { Message = ex.Message })); } }
private static GameViewModel GetGameViewModel() { var gameViewModel = new GameViewModel { GameId = 1, Key = "key", Price = (decimal)5.0, Name = "name", Discontinued = false, Description = "description", Publisher = new PublisherViewModel(), SelectedGenresIds = new List <int>(), SelectedPlatformTypesIds = new List <int>(), SelectedPublisherId = 1, UnitsInStock = 50, AddedDate = DateTime.UtcNow, PublicationDate = DateTime.UtcNow, Publishers = new List <PublisherViewModel>(), PlatformTypes = new List <PlatformTypeViewModel>(), Genres = new List <GenreViewModel>(), }; return(gameViewModel); }
private async Task <List <GameViewModel> > GetLiveTopGamesAsync() { var topGamesView = new List <GameViewModel>(); var topGames = await _twitchClient.GetTopGamesAsync(); if (topGames != null && topGames.Data.Any()) { await topGames.Data.ForEachAsync(10, async game => { var coverArt = game.BoxArtUrl.Replace("{width}x{height}", "285x380"); var gameViewModel = new GameViewModel(game.Name, coverArt); var id = Int32.Parse(game.Id); var streams = await _twitchClient.GetStreamsByIdAsync(id); if (streams.Data != null && streams.Data.Any()) { var streamsViewModel = new List <StreamViewModel>(); streamsViewModel.AddRange(streams.Data.Select(x => new StreamViewModel(x))); gameViewModel.Streams = streamsViewModel; } var igdbGames = await _igdbClient.GetGameByNameAsync(game.Name); if (igdbGames != null && igdbGames.Any()) { var firstMatch = igdbGames.First(); gameViewModel.Review = new ReviewViewModel(firstMatch); } topGamesView.Add(gameViewModel); }); } return(topGamesView); }
private IElement CreateListBoxItem(GameViewModel content) { var textBlock = new TextBlock(FontManager[Fonts.Normal]) { Text = content.GameName, Foreground = new SolidColorBrush(Colors.White), Margin = new Thickness(0, 10, 0, 10), }; var border = new Border() { Child = textBlock }; var listBoxItem = new ListBoxItem() { Content = border }; textBlock.Bind(TextBlock.ForegroundProperty, listBoxItem.GetObservable <bool, ListBoxItem>(ListBoxItem.IsSelectedProperty) .Select( isSelected => (Brush) (isSelected ? new SolidColorBrush(Colors.Black) : new SolidColorBrush(Colors.White)))); border.Bind(Border.BackgroundProperty, listBoxItem.GetObservable <bool, ListBoxItem>(ListBoxItem.IsSelectedProperty) .Select( isSelected => (Brush) (isSelected ? new SolidColorBrush(Colors.Gray) : new SolidColorBrush(Colors.Black)))); content.PropertyChanged += delegate { listBoxItem.IsSelected = content.IsSelected; }; listBoxItem.Bind(ListBoxItem.IsSelectedProperty, BindingFactory.CreateTwoWay(content, c => c.IsSelected)); return(listBoxItem); }
public void Init([NotNull] GameViewModel game, [NotNull] UnitViewModel viewModel) { Assert.IsNotNull(game, nameof(game)); Assert.IsNotNull(viewModel, nameof(viewModel)); _owner.SetupDisposables(); _unitText.text = viewModel.Type; _closeButton.onClick.AsObservable() .Subscribe(_ => OnCloseClick()) .AddTo(_owner.Disposables); viewModel.Sprite .Subscribe(s => _unitImage.sprite = s) .AddTo(_owner.Disposables); _upgradeView.Init(game, viewModel); foreach (var statView in _statViews) { statView.Init(game, viewModel); } Show(); }
public async Task <IActionResult> Show(int id) { var game = await _gameService.GetGameByIdAsync(id); var highscores = await _scoreService.GetHighscoresByGameIdAsync(id); if (game == null) { return(NotFound()); } var viewModel = new GameViewModel { Title = game.Title, Description = game.Description, ImageUrl = game.ImageUrl, ImageDescription = game.Title, Highscores = highscores.Select(x => new HighscoreViewModel { Player = new PlayerViewModel { Id = x.Player.Id, Alias = x.Player.Alias }, Game = new GameViewModel { Id = x.Game.Id, Title = x.Game.Title, Description = x.Game.Description }, Points = x.Points, Date = x.Date }) }; return(View(viewModel)); }
public void MoveCommandCanExecuteOnlyForLegalHumanMove() { var mockClockViewModel = new MockClockViewModel(); var mockGame = new MockGame(); var gameViewModel = new GameViewModel(mockClockViewModel, mockGame); Action <bool> assertMoveCanExecute = expected => Assert.AreEqual <bool>( expected, gameViewModel.MoveCommand.CanExecute(new Space(0, 0))); mockGame.IsValidMoveDelegate = move => false; assertMoveCanExecute(false); mockGame.IsValidMoveDelegate = move => true; assertMoveCanExecute(true); mockClockViewModel.IsPaused = true; assertMoveCanExecute(false); mockClockViewModel.IsPaused = false; assertMoveCanExecute(true); gameViewModel.PlayerOne = Player.Ai1; assertMoveCanExecute(false); }
public async Task <IActionResult> Game(GameViewModel gameVm) { var currentUser = await _userManager.GetUserAsync(HttpContext.User); gameVm.Id = Guid.NewGuid().ToString(); gameVm.UserId = currentUser.Id; gameVm.Name = gameVm.Name.Replace("@", "").Replace(";", "").Replace("->", " ").Replace(":", "_").Replace(",", " ").Replace(" ", " "); gameVm.GameModels = await _gameRepository.GetAll(); if (gameVm.GameModels.Select(g => g.Name).ToList().Contains(gameVm.Name)) { return(RedirectToAction("Game", new { id = gameVm.Id })); } if (await _gameRepository.Add(new GameModel { Id = Guid.Parse(gameVm.Id), UserId = Guid.Parse(gameVm.UserId), Name = gameVm.Name, Description = gameVm.Description, Dependencies = new List <GameModel>(), Events = new List <EventModel>(), Items = new List <ItemModel>(), MiniEvents = "", Private = true, SetEvents = "", StartingMoney = 0, Standalone = false })) { return(RedirectToAction("Game", new { id = gameVm.Id })); } return(RedirectToAction("Game", new { id = gameVm.Id })); }
public async Task <IActionResult> Index(GameViewModel gameViewModel) { var game = _mapper.Map <GameViewModel, GameEntityModel>(gameViewModel); var awayT = _teamRepository.GetQueryable().FirstOrDefault(a => a.Name == gameViewModel.AwayTeam.Name); var homeT = _teamRepository.GetQueryable().FirstOrDefault(a => a.Name == gameViewModel.HomeTeam.Name); if (awayT != null) { game.AwayTeamEntityModel = awayT; } else { game.AwayTeamEntityModel = new TeamEntityModel { Name = gameViewModel.AwayTeam.Name } }; if (homeT != null) { game.HomeTeamEntityModel = homeT; } else { game.HomeTeamEntityModel = new TeamEntityModel { Name = gameViewModel.HomeTeam.Name } }; _gameRepository.Add(game); _gameRepository.SaveChanges(); return(View()); } } }
private void App_Startup(object sender, StartupEventArgs e) { // modell létrehozása _model = new TetrisModel(new TetrisFileDataAccess()); _model.GameOver += new EventHandler <TetrisEventArgs>(Model_GameEnd); // késöbb megírni _model.NewGame(); // nézemodell létrehozása _viewModel = new GameViewModel(_model); _viewModel.NewGame += new EventHandler(ViewModel_NewGame); _viewModel.ExitGame += new EventHandler(ViewModel_ExitGame); _viewModel.LoadGame += new EventHandler(ViewModel_LoadGame); _viewModel.SaveGame += new EventHandler(ViewModel_SaveGame); _viewModel.PauseGame += new EventHandler(ViewModel_PauseGame); _viewModel.SmallGame += new EventHandler(ViewModel_SmallGame); _viewModel.MediumGame += new EventHandler(ViewModel_MediumGame); _viewModel.LargeGame += new EventHandler(ViewModel_LargeGame); //_viewModel.Down += new EventHandler(ViewModel_LargeGame); //_viewModel.Up += new EventHandler(ViewModel_LargeGame); //_viewModel.Right += new EventHandler(ViewModel_LargeGame); //_viewModel.Left += new EventHandler(ViewModel_LargeGame); // nézet létrehozása _view = new MainWindow(); _view.DataContext = _viewModel; _view.Closing += new System.ComponentModel.CancelEventHandler(View_Closing); // eseménykezelés a bezáráshoz _view.Show(); // időzítő létrehozása _timer = new DispatcherTimer(); _timer.Interval = TimeSpan.FromSeconds(1); _timer.Tick += new EventHandler(Timer_Tick); _timer.Start(); _timerActive = true; }
public ActionResult Delete(int?id) { try { var gameDTO = gameService.GetGame(id); GameViewModel game = new GameViewModel { Id = gameDTO.Id, FirstTeamName = gameDTO.FirstTeamName, SecondTeamName = gameDTO.SecondTeamName, FirstTeamResult = gameDTO.FirstTeamResult, SecondTeamResult = gameDTO.SecondTeamResult, FirstTeamId = gameDTO.FirstTeamId, SecondTeamId = gameDTO.SecondTeamId, StadiumId = gameDTO.StadiumId, StadiumName = gameDTO.StadiumName }; return(View(game)); } catch (ValidationException e) { return(Content("Not Found")); } }
public ActionResult Edit(GameViewModel game) { try { var gameDTO = new GameDTO { Id = game.Id, FirstTeamId = game.FirstTeamId, SecondTeamId = game.SecondTeamId, StadiumId = game.StadiumId, FirstTeamResult = game.FirstTeamResult, SecondTeamResult = game.SecondTeamResult }; gameService.UpdateGame(gameDTO); return(RedirectToAction("Index")); } catch (ValidationException ex) { ViewBag.Teams = new SelectList(teamService.GetTeams(), "Id", "Name"); ViewBag.Stadiums = new SelectList(stadiumService.GetStadiums(), "Id", "Name"); ModelState.AddModelError(ex.Property, ex.Message); } return(View(game)); }
public ActionResult Edit(GameViewModel model) { var editGame = _context.Games.FirstOrDefault(testc => testc.Id == model.Id); if (editGame != null) { editGame.NameGames = model.NameGames; editGame.GameIcon = model.GameIcon; editGame.Price = model.Price; editGame.BriefDescription = model.BriefDescription; editGame.FullDescription = model.FullDescription; editGame.Category = model.Category; editGame.Picture1 = model.Picture1; editGame.Picture2 = model.Picture2; editGame.Picture3 = model.Picture3; editGame.Picture4 = model.Picture4; _context.SaveChanges(); return(RedirectToAction("Index", "AdminGames")); } else { return(RedirectToAction("Index", "AdminGames")); } }
public IActionResult GameArena() { var gameConf = _unitOfWorkGameVariant.RepositoryGameVariant.GetAll(); var four = _unitOfWorkFour.RepositoryFour.GetAll(); var five = _unitOfWorkFive.RepositoryFive.GetAll(); var six = _unitOfWorkSix.RepositorySix.GetAll(); var seven = _unitOfWorkSeven.RepositorySeven.GetAll(); var eight = _unitOfWorkEight.RepositoryEight.GetAll(); var nine = _unitOfWorkNine.RepositoryNine.GetAll(); var ten = _unitOfWorkTen.RepositoryTen.GetAll(); var gameViewModel = new GameViewModel { GameVariants = gameConf, FourWords = four, FifthWords = five, SixthWords = six, SevenWords = seven, EightWords = eight, NineWords = nine, TenWords = ten }; return(View(gameViewModel)); }
public ActionResult Add(GameViewModel gameview) { if (ModelState.IsValid) { GameDTO gamedto = new GameDTO { CPU = gameview.CPU, GameDescription = gameview.GameDescription, CategoryId = gameview.CategoryId, GameName = gameview.GameName, VideoCard = gameview.VideoCard, RAM = gameview.RAM, OperationSystem = gameview.OperationSystem, Price = gameview.Price }; gameService.CreateGame(gamedto); } else { ModelState.AddModelError("", "incorrect data"); } return(RedirectToAction("Index")); }
public IActionResult Index(int Id) { try { Game g = _gameService.LoadGame(Id); WebPlayer human = g.Players.First() as WebPlayer; GameViewModel viewModel = new GameViewModel() { CurrentGame = g, CurrentPlayer = human }; return(View(viewModel)); } catch (FileNotFoundException exc) { //Game does not exist, send back to start. return(Redirect("/")); } catch { throw; } }
public ActionResult Search() { GameDal dal = new GameDal(); string searchName = ""; string searchConsole = ""; if (Request.Form["txtName"] != null) { searchName = Request.Form["txtName"].ToString(); } if (Request.Form["ddConsole"] != null) { searchConsole = Request.Form["ddConsole"].ToString(); } //Searching by passed criteria List <Game> objGames = (from x in dal.Games where x.name.Contains(searchName) where x.console.Contains(searchConsole) select x).ToList(); GameViewModel gvm = new GameViewModel(); gvm.games = objGames; return(View(gvm)); }
public void Edit(GameViewModel model) { using (var db = new GameStoreDbContext()) { var game = db .Games .FirstOrDefault(g => g.Id == model.Id); if (game == null) { return; } game.Description = model.Description; game.Image = model.Image; game.Price = model.Price; game.ReleaseDate = model.ReleaseDate; game.Size = model.Size; game.Title = model.Title; game.Trailer = model.Trailer; db.SaveChanges(); } }
public ActionResult Delete(int?id, GameViewModel gameViewModel) { try { var game = gameService.GetByID((int)id); if (game.CoverImagePath != "noimage.jpg") { string fullFilePath = Request.MapPath("~/Images/Game_Cover_Images/" + game.CoverImagePath); System.IO.File.Delete(fullFilePath); } gameService.Delete(game); gameService.Save(); TempData["Message"] = "Movie deleted successfuly!"; return(RedirectToAction("Index")); } catch { ModelState.AddModelError("", "Database error!"); return(View(gameViewModel)); } }
public IActionResult Drop(string GameState, int Selection) { Game g = Game.DeserializeGame(GameState); var p = g.NextPlayer as WebPlayer; p.DropCard(g, Selection); g.NextTurn(); if (g.GameOver) { return(View("GameOver", g.Winner)); } g.NextTurn(); if (g.GameOver) { return(View("GameOver", g.Winner)); } GameViewModel gvm = new GameViewModel() { Game = g }; return(View("Index", gvm)); }
public async Task <IActionResult> UpdateGame(int id) { if (id == 0) { return(NotFound()); } var gameDto = await _gameService.GetGameAsync(id); if (gameDto != null) { GameViewModel model = new GameViewModel(); model.Id = id; model.Team1 = gameDto.Team1; model.Team2 = gameDto.Team2; model.Date = gameDto.Date; model.Result = gameDto.Result; return(View(model)); } else { return(View()); } }
private static void FormatExternalLinksForEdit(ref GameViewModel vm) { foreach (ExternalLinkProvider provider in Enum.GetValues(typeof(ExternalLinkProvider))) { ExternalLinkBaseViewModel existingProvider = vm.ExternalLinks.FirstOrDefault(x => x.Provider == provider); ExternalLinkInfoAttribute uiInfo = provider.GetAttributeOfType <ExternalLinkInfoAttribute>(); if (uiInfo.Type != ExternalLinkType.ProfileOnly) { if (existingProvider == null) { ExternalLinkBaseViewModel placeHolder = new ExternalLinkBaseViewModel { EntityId = vm.Id, Type = uiInfo.Type, Provider = provider, Order = uiInfo.Order, Display = uiInfo.Display, IconClass = uiInfo.Class, ColorClass = uiInfo.ColorClass, IsStore = uiInfo.IsStore }; vm.ExternalLinks.Add(placeHolder); } else { existingProvider.Display = uiInfo.Display; existingProvider.IconClass = uiInfo.Class; existingProvider.Order = uiInfo.Order; } } } vm.ExternalLinks = vm.ExternalLinks.OrderByDescending(x => x.Type).ThenBy(x => x.Provider).ToList(); }
public GamePage() { InitializeComponent(); _drawerLayout.InitializeDrawerLayout(); vm = new GameViewModel(); _drawerLayout.DrawerOpened += sender => { vm.SetDrawerLayoutOpen(true); }; _drawerLayout.DrawerClosed += sender => { vm.SetDrawerLayoutOpen(false); }; vm.CloseDrawer += (sender, args) => { _drawerLayout.CloseDrawer(); }; DataContext = vm; TouchPanel.EnabledGestures = GestureType.Flick; ManipulationCompleted += manipulationCompleted; Loaded += delegate { NavigationService.RemoveBackEntry(); }; Unloaded += delegate { CardsAgainstHumility.DepartGame(); }; }
public MainWindow() { InitializeComponent(); DataContext = new GameViewModel(); popUpMessage = new PopUpMessage(); }
protected abstract CardPileViewModel SelectPile(GameViewModel state, IGameClient client);
protected IList <CardPileViewModel> GetValidBuys(GameViewModel state) { return(state.Bank.Where(p => p.CanBuy).ToList()); }
public MainWindow() { InitializeComponent(); DataContext = new GameViewModel(); }
public async Task <ActionResult> EditGame(GameViewModel model) { await this.gameService.EditAsync(model.Id, model.Title, model.Description, model.ImageURL, model.Price); return(this.Redirect("/Administration/Dashboard")); }
public async Task <ActionResult> CreateGame(GameViewModel model) { await this.gameService.CreateAsync(model.Title, model.Description, model.ImageURL, model.Price, model.RealaseDate); return(this.RedirectToAction("Index")); }