コード例 #1
0
        public SpellbookViewModel CreateSpellbook(SpellbookViewModel viewModel)
        {
            var entity = Mapper.Map <SpellbookViewModel, Spellbook>(viewModel);

            _repository.Add(entity);
            _repository.Commit();
            entity = _repository.GetSingle <Spellbook>(a => a.Id == entity.Id);
            return(Mapper.Map <Spellbook, SpellbookViewModel>(entity));
        }
コード例 #2
0
        public ActionResult RemoveSpell(int id, int spellId, SpellbookViewModel viewModel)
        {
            if (_spellbookRepo.RemoveSpellFromSpellbook(id, spellId))
            {
                return(RedirectToAction("Select", "Spellbook", routeValues: new { id = id }));
            }

            return(View(viewModel));
        }
コード例 #3
0
        public ActionResult Edit(int id)
        {
            Spellbook spellbook = _spellbookRepo.Get(id);

            var viewModel = new SpellbookViewModel();

            viewModel.Name = spellbook.Name;

            return(View(viewModel));
        }
コード例 #4
0
        public override void UpdateSpellcasting()
        {
            List <SpellcastingFeature> spellcasts = new List <SpellcastingFeature>(from f in Context.Player.GetFeatures() where f is SpellcastingFeature && ((SpellcastingFeature)f).SpellcastingID != "MULTICLASS" orderby Context.Player.GetClassLevel(((SpellcastingFeature)f).SpellcastingID) descending, ((SpellcastingFeature)f).DisplayName, ((SpellcastingFeature)f).SpellcastingID select f as SpellcastingFeature);
            //if (spellcasts.Count == 0) Spellcasting.ReplaceRange(new List<SpellbookViewModel>() { new SpellbookViewModel(this, null) });
            List <SpellbookViewModel> views    = new List <SpellbookViewModel>();
            List <SpellbookViewModel> oldviews = new List <SpellbookViewModel>(Spellcasting);

            foreach (SpellcastingFeature sf in spellcasts)
            {
                List <SpellChoiceFeature> spellfeatures = new List <SpellChoiceFeature>(from f in Context.Player.GetFeatures() where f is SpellChoiceFeature select f as SpellChoiceFeature);
                foreach (var f in spellfeatures)
                {
                    if (f.SpellcastingID == sf.SpellcastingID)
                    {
                        if (Spellcasting.FirstOrDefault(view => view is SpellChoiceViewModel scv && view.SpellcastingID == sf.SpellcastingID && scv.UniqueID == f.UniqueID) is SpellChoiceViewModel v)
                        {
                            v.Refresh(sf, f);
                            views.Add(v);
                        }
                        else
                        {
                            views.Add(new SpellChoiceViewModel(this, sf, f));
                        }
                    }
                }
                List <ModifiedSpell> bonusprepared = null;
                if (sf.Preparation != PreparationMode.LearnSpells)
                {
                    SpellbookViewModel v2 = Spellcasting.FirstOrDefault(view => view is SpellPrepareViewModel && view.SpellcastingID == sf.SpellcastingID);
                    if (v2 != null)
                    {
                        v2.Refresh(sf);
                        if (v2 is SpellPrepareViewModel spvm && spvm.Able > 0)
                        {
                            views.Add(spvm);
                        }
                    }
                    else
                    {
                        v2 = new SpellPrepareViewModel(this, sf);
                        if (v2 is SpellPrepareViewModel spvm && spvm.Able > 0)
                        {
                            views.Add(spvm);
                        }
                    }
                }
                else
                {
                    bonusprepared = Context.Player.GetSpellcasting(sf.SpellcastingID).GetPrepared(Context.Player, Context).ToList();
                    if (bonusprepared.Count > 0 && Spellcasting.FirstOrDefault(view => view is SpellChoiceViewModel scv && view.SpellcastingID == sf.SpellcastingID && scv.Choice == null) is SpellChoiceViewModel v)
                    {
                        v.Refresh(sf, null);
                        v.SetSpells(bonusprepared);
                        views.Add(v);
                    }
コード例 #5
0
        public ActionResult Delete(int id)
        {
            Spellbook spellbook = _spellbookRepo.Get(id);

            var viewModel = new SpellbookViewModel();

            viewModel.Id     = spellbook.Id;
            viewModel.Name   = spellbook.Name;
            viewModel.Spells = spellbook.Spells;

            return(View(viewModel));
        }
コード例 #6
0
        public override void UpdateSpellcasting()
        {
            List <SpellcastingFeature> spellcasts = new List <SpellcastingFeature>(from f in Context.Player.GetFeatures() where f is SpellcastingFeature && ((SpellcastingFeature)f).SpellcastingID != "MULTICLASS" orderby Context.Player.GetClassLevel(((SpellcastingFeature)f).SpellcastingID) descending, ((SpellcastingFeature)f).DisplayName, ((SpellcastingFeature)f).SpellcastingID select f as SpellcastingFeature);
            //if (spellcasts.Count == 0) Spellcasting.ReplaceRange(new List<SpellbookViewModel>() { new SpellbookViewModel(this, null) });
            List <SpellbookViewModel> views    = new List <SpellbookViewModel>();
            List <SpellbookViewModel> oldviews = new List <SpellbookViewModel>(Spellcasting);

            foreach (SpellcastingFeature sf in spellcasts)
            {
                SpellbookViewModel v = Spellcasting.FirstOrDefault(view => view is SpellbookSpellsViewModel && view.SpellcastingID == sf.SpellcastingID);
                if (v != null)
                {
                    v.Refresh(sf);
                    views.Add(v);
                }
                else
                {
                    views.Add(new SpellbookSpellsViewModel(this, sf));
                }
                if (sf.Preparation != PreparationMode.LearnSpells)
                {
                    SpellbookViewModel v2 = Spellcasting.FirstOrDefault(view => view is SpellPrepareViewModel && view.SpellcastingID == sf.SpellcastingID);
                    if (v2 != null)
                    {
                        v2.Refresh(sf);
                        if (v2 is SpellPrepareViewModel spvm && spvm.Able > 0)
                        {
                            views.Add(spvm);
                        }
                    }
                    else
                    {
                        v2 = new SpellPrepareViewModel(this, sf);
                        if (v2 is SpellPrepareViewModel spvm && spvm.Able > 0)
                        {
                            views.Add(spvm);
                        }
                    }
                }
            }
            if (!views.SequenceEqual(Spellcasting))
            {
                Spellcasting.ReplaceRange(views);
                UpdatePages();
            }
            if (views.Count == 0)
            {
                UpdatePages();
            }
        }
コード例 #7
0
        public IActionResult GetSpellbookById(int id)
        {
            var viewModels = new SpellbookViewModel();

            try
            {
                viewModels = _spellbookLogicHandler.GetSpellbookById(id);
            }
            catch (Exception ex)
            {
                _responseFormatter.SetError(ex);
                return(new BadRequestObjectResult(_responseFormatter.GetResponse()));
            }
            _responseFormatter.Add("spellbook", viewModels);
            return(new OkObjectResult(_responseFormatter.GetResponse()));
        }
コード例 #8
0
        public ActionResult Edit(int id, SpellbookViewModel viewModel)
        {
            var spellbook = new Spellbook()
            {
                Id   = id,
                Name = viewModel.Name
            };

            if (_spellbookRepo.Update(spellbook))
            {
                return(RedirectToAction("Select", "Spellbook",
                                        routeValues: new { id = spellbook.Id }));
            }
            else
            {
                ModelState.AddModelError("", "Unable to update Spellbook");
                return(View(viewModel));
            }
        }
コード例 #9
0
        public ActionResult Create(SpellbookViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var spellbook = new Spellbook()
                {
                    Name = viewModel.Name
                };

                var success = _spellbookRepo.Add(spellbook);
                if (success.HasValue)
                {
                    return(RedirectToAction("Index", "Spellbook"));
                }
                else
                {
                    ModelState.AddModelError("", "Unable to add spellbook.");
                }
            }
            return(View(viewModel));
        }
コード例 #10
0
        /// <summary>
        /// Shows create spellbook dialog
        /// </summary>
        public SpellbookModel ShowCreateSpellbookDialog(string title, SpellbookModel spellbookModel)
        {
            ModalDialog modalDialog = new ModalDialog();

            if (_parentWindow != null)
            {
                modalDialog.Owner = _parentWindow;
            }

            SpellbookModel     spellbookModelCopy = new SpellbookModel(spellbookModel);
            SpellbookViewModel spellbookViewModel = new SpellbookViewModel(spellbookModelCopy);

            spellbookViewModel.InitializeOptions();
            CreateSpellbookView createSpellbookView = new CreateSpellbookView(spellbookViewModel);

            modalDialog.WindowTitle  = title;
            modalDialog.Body         = createSpellbookView;
            modalDialog.Confirmation = createSpellbookView.ViewModel;

            bool?result = ShowDialog(modalDialog);

            return(result == true ? spellbookModelCopy : null);
        }
コード例 #11
0
 public void ClassifypellsByLevel(SpellbookViewModel spellbook)
 {
 }
コード例 #12
0
        public ActionResult Create()
        {
            var viewModel = new SpellbookViewModel();

            return(View(viewModel));
        }
コード例 #13
0
 public CreateSpellbookView(SpellbookViewModel viewModel)
 {
     InitializeComponent();
     DataContext = viewModel;
 }
コード例 #14
0
 public PlayerPreparePage(SpellbookViewModel model)
 {
     BindingContext   = model;
     model.Navigation = Navigation;
     InitializeComponent();
 }