예제 #1
0
        public ResourceViewModel(object value, PlayerViewModel model)
        {
            Value  = value;
            Reduce = new Command(() =>
            {
                if (IsChangeable && last != null && last.Equals(ResourceID))
                {
                    Used++;
                    model.MakeHistory("Resource" + ResourceID);
                    if (Max > 0 && Used > Max)
                    {
                        Used = Max;
                    }
                    model.Context.Player.SetUsedResources(ResourceID, Used);
                    model.UpdateUsed();

                    model.Save();
                }
                last = ResourceID;
            });
        }
예제 #2
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();
        }
예제 #3
0
 public SpellPrepareViewModel(PlayerViewModel model, SpellcastingFeature spellcasting) : base(model, spellcasting)
 {
     Title = spellcasting.DisplayName;
     if (Title == null || Title == "")
     {
         Title = SpellcastingID;
     }
     Spellcasting = Model.Context.Player.GetSpellcasting(SpellcastingID);
     OnPrepare    = new Command((par) =>
     {
         if (par is SpellViewModel svm && SpellcastingFeature != null && !svm.AddAlwaysPreparedToName)
         {
             if (!svm.Prepared)
             {
                 if (Count < Able)
                 {
                     svm.Prepared = true;
                     Model.MakeHistory();
                     Spellcasting.GetPreparedList(Model.Context.Player, Model.Context).Add(svm.Name + " " + ConfigManager.SourceSeperator + " " + svm.Source);
                     Model.Save();
                 }
             }
             else
             {
                 svm.Prepared = false;
                 Model.MakeHistory();
                 string r = svm.Name + " " + ConfigManager.SourceSeperator + " " + svm.Source;
                 Spellcasting.GetPreparedList(Model.Context.Player, Model.Context).RemoveAll(s => ConfigManager.SourceInvariantComparer.Equals(s, r));
                 Model.Save();
             }
             OnPropertyChanged("Count");
             OnPropertyChanged("Prepared");
             Model.ChangedPreparedSpells(SpellcastingID);
         }
     }, (par) => par is SpellViewModel svm && !svm.AddAlwaysPreparedToName);
     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 == 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));
         }
     });
     ResetPrepared = new Command(() =>
     {
         IsBusy = true;
         Model.MakeHistory();
         Spellcasting.GetPreparedList(Model.Context.Player, Model.Context).Clear();
         Model.Save();
         foreach (SpellViewModel s in spells)
         {
             s.Prepared = s.AddAlwaysPreparedToName;
         }
         UpdateSpells();
         OnPropertyChanged("Count");
         OnPropertyChanged("Prepared");
         Model.ChangedPreparedSpells(SpellcastingID);
         IsBusy = false;
     });
     AddSpells();
 }
 public JournalViewModel(PlayerViewModel model, JournalEntry entry)
 {
     Context = model;
     Journal = entry;
 }
 public JournalViewModel(PlayerViewModel model)
 {
     IsNew   = true;
     Context = model;
     Journal = new JournalEntry();
 }
예제 #6
0
 public InPlayDetailViewModel(PlayerViewModel model)
 {
     Model = model;
 }
예제 #7
0
 public OverviewViewModel(PlayerViewModel model) : base(model)
 {
 }