Exemple #1
0
        public void AddSpells()
        {
            spells.Clear();
            Spells.ReplaceRange(spells);
            if (SpellcastingFeature.Preparation == PreparationMode.ClassList)
            {
                spells.AddRange(from s in Spellcasting.GetPrepared(Model.Context.Player, Model.Context)
                                select new SpellViewModel(s)
                {
                    Prepared = true,
                    Prepare  = OnPrepare,
                    ShowInfo = ShowInfo
                });
                spells.AddRange(from s in Spellcasting.GetAdditionalClassSpells(Model.Context.Player, Model.Context)
                                where !spells.Exists(t => t.Name == s.Name && s.Source == t.Spell.Source)
                                select new SpellViewModel(s)
                {
                    Prepared = false,
                    Prepare  = OnPrepare,
                    ShowInfo = ShowInfo
                });
                spells.AddRange(from s in Utils.FilterSpell(Model.Context, SpellcastingFeature.PrepareableSpells, SpellcastingID, Model.Context.Player.GetClassLevel(SpellcastingID))
                                where !spells.Exists(t => t.Name == s.Name && s.Source == t.Spell.Source)
                                select new SpellViewModel(s)
                {
                    Prepared = false,
                    Prepare  = OnPrepare,
                    ShowInfo = ShowInfo
                });
            }
            else if (SpellcastingFeature.Preparation == PreparationMode.Spellbook)
            {
                spells.AddRange(from s in Spellcasting.GetPrepared(Model.Context.Player, Model.Context)
                                select new SpellViewModel(s)
                {
                    Prepared = true,
                    Prepare  = OnPrepare,
                    ShowInfo = ShowInfo
                });
                spells.AddRange(from s in Spellcasting.GetAdditionalClassSpells(Model.Context.Player, Model.Context)
                                where !spells.Exists(t => t.Name == s.Name && s.Source == t.Spell.Source)
                                select new SpellViewModel(s)
                {
                    Prepared = true,
                    Prepare  = OnPrepare,
                    ShowInfo = ShowInfo
                });

                spells.AddRange(from s in Spellcasting.GetSpellbook(Model.Context.Player, Model.Context)
                                where !spells.Exists(t => t.Name == s.Name && s.Source == t.Spell.Source)
                                select new SpellViewModel(s)
                {
                    Prepared = false,
                    Prepare  = OnPrepare,
                    ShowInfo = ShowInfo
                });
            }
            spells.Sort();
            UpdateSpells();
        }
        public void AddSpells()
        {
            spells.Clear();
            Spells.ReplaceRange(spells);
            if (SpellcastingFeature.Preparation == PreparationMode.ClassList)
            {
                List <Spell> filtered   = Utils.FilterSpell(Model.Context, SpellcastingFeature.PrepareableSpells, SpellcastingID, Model.Context.Player.GetClassLevel(SpellcastingID));
                List <Spell> additional = Spellcasting.GetAdditionalClassSpells(Model.Context.Player, Model.Context).ToList();
                spells.AddRange(from s in Spellcasting.GetPrepared(Model.Context.Player, Model.Context)
                                select new SpellViewModel(s)
                {
                    Prepared  = true,
                    Prepare   = OnPrepare,
                    ShowInfo  = ShowInfo,
                    BadChoice = !s.AddAlwaysPreparedToName && !filtered.Exists(t => t.Name == s.Name && s.Source == t.Source) && !additional.Exists(t => t.Name == s.Name && s.Source == t.Source)
                });
                spells.AddRange(from s in additional
                                where !spells.Exists(t => t.Name == s.Name && s.Source == t.Spell.Source)
                                select new SpellViewModel(s)
                {
                    Prepared = false,
                    Prepare  = OnPrepare,
                    ShowInfo = ShowInfo
                });
                spells.AddRange(from s in filtered
                                where !spells.Exists(t => t.Name == s.Name)
                                select new SpellViewModel(s)
                {
                    Prepared = false,
                    Prepare  = OnPrepare,
                    ShowInfo = ShowInfo
                });
            }
            else if (SpellcastingFeature.Preparation == PreparationMode.Spellbook)
            {
                List <Spell> spellbook = Spellcasting.GetSpellbook(Model.Context.Player, Model.Context).ToList();
                spells.AddRange(from s in Spellcasting.GetPrepared(Model.Context.Player, Model.Context)
                                select new SpellViewModel(s)
                {
                    Prepared  = true,
                    Prepare   = OnPrepare,
                    ShowInfo  = ShowInfo,
                    BadChoice = !spellbook.Exists(t => t.Name == s.Name && s.Source == t.Source)
                });

                spells.AddRange(from s in spellbook
                                where !spells.Exists(t => t.Name == s.Name)
                                select new SpellViewModel(s)
                {
                    Prepared = false,
                    Prepare  = OnPrepare,
                    ShowInfo = ShowInfo
                });
            }
            spells.Sort();
            UpdateSpells();
        }
Exemple #3
0
        public override void Refresh(SpellcastingFeature feature)
        {
            SpellcastingFeature = feature;
            Spellcasting        = Model.Context.Player.GetSpellcasting(SpellcastingID);
            UpdateSlots();
            spells.Clear();
            spells.AddRange(from s in Spellcasting.GetLearned(Model.Context.Player, Model.Context) select new SpellViewModel(s)
            {
                Highlight = OnHighlight,
                ShowInfo  = ShowInfo,
                AddAlwaysPreparedToName = false
            });
            spells.AddRange(from s in Spellcasting.GetPrepared(Model.Context.Player, Model.Context) select new SpellViewModel(s)
            {
                Highlight = OnHighlight,
                ShowInfo  = ShowInfo,
                AddAlwaysPreparedToName = false
            });
            spells.Sort();
            if (SpellcastingFeature.Preparation == OGL.Base.PreparationMode.ClassList)
            {
                spells.AddRange(from s in Spellcasting.GetCLassListRituals(SpellcastingFeature.PrepareableSpells ?? "false", Model.Context.Player, Model.Context) select new SpellViewModel(s)
                {
                    Highlight = OnHighlight,
                    ShowInfo  = ShowInfo,
                    AddAlwaysPreparedToName = false
                });
            }
            else if (SpellcastingFeature.Preparation == OGL.Base.PreparationMode.Spellbook)
            {
                spells.AddRange(from s in Spellcasting.GetSpellbookRituals(Model.Context.Player, Model.Context) select new SpellViewModel(s)
                {
                    Highlight = OnHighlight,
                    ShowInfo  = ShowInfo,
                    AddAlwaysPreparedToName = false
                });
            }

            UpdateSpells();
            OnPropertyChanged(null);
        }
Exemple #4
0
        public SpellbookSpellsViewModel(PlayerViewModel model, SpellcastingFeature spellcastingFeature) : base(model, spellcastingFeature)
        {
            Title = spellcastingFeature.DisplayName;
            if (Title == null || Title == "")
            {
                Title = SpellcastingID;
            }
            Spellcasting = Model.Context.Player.GetSpellcasting(SpellcastingID);
            OnHighlight  = new Command((par) =>
            {
                Model.MakeHistory("Highlight");
                Spellcasting.Highlight = (par as SpellViewModel)?.Name;
                foreach (SpellViewModel s in Spells)
                {
                    s.IsHightlighted = false;
                }
                if (par is SpellViewModel svm)
                {
                    svm.IsHightlighted = true;
                }
                OnPropertyChanged("Highlight");
                Model.Save();
            });
            RemoveHighlight = new Command(() =>
            {
                Model.MakeHistory("Highlight");
                Spellcasting.Highlight = null;
                foreach (SpellViewModel s in Spells)
                {
                    s.IsHightlighted = false;
                }
                OnPropertyChanged("Highlight");
                Model.Save();
            });
            OnReduce = new Command((par) =>
            {
                if (par is SpellSlotInfo s && s.Used < s.Slots)
                {
                    if (last == s.Level)
                    {
                        s.Used++;
                        Model.MakeHistory(s.SpellcastingID + "Slots" + s.Level);
                        Model.Context.Player.SetSpellSlot(s.SpellcastingID, s.Level, s.Used);
                        Model.Save();
                        (s as SpellSlotViewModel)?.UpdateUsed();
                        if (selected == s)
                        {
                            used = s.Used;
                            OnPropertyChanged("Used");
                        }
                        Model.UpdateSlots(this);
                    }
                    last = s.Level;
                }
            });
            OnReset = new Command((par) =>
            {
                if (par is SpellSlotInfo s)
                {
                    s.Used = 0;
                    Model.MakeHistory(s.SpellcastingID + "Slots" + s.Level);
                    Model.Context.Player.SetSpellSlot(s.SpellcastingID, s.Level, s.Used);
                    Model.Save();
                    (s as SpellSlotViewModel)?.UpdateUsed();
                    if (selected == s)
                    {
                        used = s.Used;
                        OnPropertyChanged("Used");
                    }
                    Model.UpdateSlots(this);
                }
            });
            ResetAll = new Command(() =>
            {
                IsBusy = true;
                Model.MakeHistory();
                Model.Context.Player.ResetSpellSlots(SpellcastingID);
                Model.Save();
                UpdateSlots();
                used = 0;
                OnPropertyChanged("Used");
                Model.UpdateSlots(this);
                IsBusy = false;
            });
            ShowInfo = new Command(async(par) =>
            {
                if (par is SpellViewModel svm)
                {
                    if (svm.Spell is ModifiedSpell ms)
                    {
                        ms.Info = Model.Context.Player.GetAttack(ms, ms.differentAbility == OGL.Base.Ability.None ? SpellcastingFeature.SpellcastingAbility : ms.differentAbility);
                        ms.Modifikations.AddRange(from f in Model.Context.Player.GetFeatures() where f is SpellModifyFeature && Utils.Matches(Model.Context, ms, ((SpellModifyFeature)f).Spells, null) select f);
                        ms.Modifikations = ms.Modifikations.Distinct().ToList();
                    }
                    await Navigation.PushAsync(InfoPage.Show(svm.Spell));
                }
            });
            spells = new List <SpellViewModel>();
            spells.AddRange(from s in Spellcasting.GetLearned(Model.Context.Player, Model.Context) select new SpellViewModel(s)
            {
                Highlight = OnHighlight,
                ShowInfo  = ShowInfo,
                AddAlwaysPreparedToName = false
            });
            spells.AddRange(from s in Spellcasting.GetPrepared(Model.Context.Player, Model.Context) select new SpellViewModel(s)
            {
                Highlight = OnHighlight,
                ShowInfo  = ShowInfo,
                AddAlwaysPreparedToName = false
            });
            spells.Sort();
            if (SpellcastingFeature.Preparation == OGL.Base.PreparationMode.ClassList)
            {
                spells.AddRange(from s in Spellcasting.GetCLassListRituals(SpellcastingFeature.PrepareableSpells ?? "false", Model.Context.Player, Model.Context) select new SpellViewModel(s)
                {
                    Highlight = OnHighlight,
                    ShowInfo  = ShowInfo,
                    AddAlwaysPreparedToName = false
                });
            }
            else if (SpellcastingFeature.Preparation == OGL.Base.PreparationMode.Spellbook)
            {
                spells.AddRange(from s in Spellcasting.GetSpellbookRituals(Model.Context.Player, Model.Context) select new SpellViewModel(s)
                {
                    Highlight = OnHighlight,
                    ShowInfo  = ShowInfo,
                    AddAlwaysPreparedToName = false
                });
            }

            UpdateSlots();
            UpdateSpells();
        }