コード例 #1
0
        public IEnumerable <Spell> GetAdditionalClassSpells(Player player, OGLContext context, int level = 0)
        {
            List <Spell> res = new List <Spell>();

            CombineSpellbookAdditional(player, context, level);
            CombineSpellChoices(player, context, level);
            string sourcehint = null;

            foreach (Feature f in player.GetFeatures(level))
            {
                if (f is SpellChoiceFeature && ((SpellChoiceFeature)f).SpellcastingID == SpellcastingID)
                {
                    sourcehint = f.Source;
                    foreach (SpellChoice s in Spellchoices)
                    {
                        SpellChoiceFeature scf = (SpellChoiceFeature)f;
                        if (s.UniqueID == scf.UniqueID && scf.AddTo == PreparationMode.ClassList)
                        {
                            res.AddRange(from spell in s.Choices select new ModifiedSpell(context.GetSpell(spell, scf.Source), scf.KeywordsToAdd));
                        }
                    }
                }
            }
            res.AddRange(from s in SpellbookAdditional select context.GetSpell(s, sourcehint));
            res.Sort();
            return(res);
        }
コード例 #2
0
        public IEnumerable <Spell> GetSpellbook(Player player, OGLContext context, int level = 0)
        {
            List <Spell> res = new List <Spell>();

            CombineSpellChoices(player, context, level);
            CombineSpellbookAdditional(player, context, level);
            string sourcehint = null;

            foreach (Feature f in player.GetFeatures(level))
            {
                if (f is SpellChoiceFeature && ((SpellChoiceFeature)f).SpellcastingID == SpellcastingID)
                {
                    sourcehint = f.Source;
                    foreach (SpellChoice s in Spellchoices)
                    {
                        SpellChoiceFeature scf = (SpellChoiceFeature)f;
                        if (s.UniqueID == scf.UniqueID && scf.AddTo == PreparationMode.Spellbook)
                        {
                            res.AddRange(from spell in s.Choices select new ModifiedSpell(context.GetSpell(spell, scf.Source), scf.KeywordsToAdd, false, false));
                        }
                    }
                }
                else if (f is BonusSpellPrepareFeature bspf && bspf.SpellcastingID == SpellcastingID && bspf.AddTo == PreparationMode.Spellbook)
                {
                    foreach (string s in bspf.Spells)
                    {
                        res.Add(new ModifiedSpell(context.GetSpell(s, bspf.Source), bspf.KeywordsToAdd, true, false));
                    }
                    res.AddRange(Utils.FilterSpell(player.Context, bspf.Condition, bspf.SpellcastingID).Select(s => new ModifiedSpell(s, bspf.KeywordsToAdd, false, false)));
                }
            }
            res.AddRange(from s in SpellbookAdditional select context.GetSpell(s, sourcehint));
            res.Sort();
            return(res);
        }
コード例 #3
0
 public void Refresh(SpellcastingFeature feature, SpellChoiceFeature choice)
 {
     Choice = choice;
     SpellcastingFeature = feature;
     Title = (feature.DisplayName ?? feature.SpellcastingID) + " - " + Choice?.Name ?? Choice?.UniqueID ?? "Additional";
     AddSpells();
     OnPropertyChanged(null);
 }
コード例 #4
0
        private void toolStripMenuItem7_Click(object sender, EventArgs e)
        {
            SpellChoiceFeature f = new SpellChoiceFeature();

            f = new FeatureForms.SpellChoiceFeatureForm(f).edit(HistoryManager);
            list.Add(f);
            fill();
        }
コード例 #5
0
 public SpellChoiceCapsule(SpellChoiceFeature scf, int calculatedamount = 0, List <Spell> calculatedchoices = null)
 {
     Spellchoicefeature = scf;
     CalculatedAmount   = calculatedamount;
     CalculatedChoices  = calculatedchoices;
     if (CalculatedChoices == null)
     {
         CalculatedChoices = new List <Spell>();
     }
 }
コード例 #6
0
        public IEnumerable <ModifiedSpell> GetLearned(Player player, OGLContext context, int level = 0)
        {
            List <ModifiedSpell> res = new List <ModifiedSpell>();

            CombineSpellChoices(player, context, level);
            foreach (Feature f in player.GetFeatures(level))
            {
                if (f is SpellChoiceFeature && ((SpellChoiceFeature)f).SpellcastingID == SpellcastingID)
                {
                    foreach (SpellChoice s in Spellchoices)
                    {
                        SpellChoiceFeature scf = (SpellChoiceFeature)f;
                        if (s.UniqueID == scf.UniqueID && scf.AddTo == PreparationMode.LearnSpells)
                        {
                            res.AddRange(from spell in s.Choices select new ModifiedSpell(context.GetSpell(spell, f.Source), scf.KeywordsToAdd, false, false));
                        }
                    }
                }
            }
            res.Sort();
            return(res);
        }
コード例 #7
0
 public SpellChoiceViewModel(PlayerModel model, SpellcastingFeature spellcasting, SpellChoiceFeature choice) : base(model, spellcasting, (spellcasting.DisplayName ?? spellcasting.SpellcastingID) + " - " + choice?.Name ?? choice?.UniqueID ?? "Additional")
 {
     Choice    = choice;
     OnPrepare = new Command((par) =>
     {
         if (par is SpellViewModel svm && SpellcastingFeature != null && Choice != null)
         {
             if (!svm.Prepared)
             {
                 if (Count < Able)
                 {
                     svm.Prepared = true;
                     Model.MakeHistory();
                     Model.Context.Player.GetSpellChoice(SpellcastingID, UniqueID).Choices.Add(svm.Name + " " + ConfigManager.SourceSeperator + " " + svm.Source);
                     Model.Save();
                 }
             }
             else
             {
                 svm.Prepared = false;
                 Model.MakeHistory();
                 string r = svm.Name + " " + ConfigManager.SourceSeperator + " " + svm.Source;
                 Model.Context.Player.GetSpellChoice(SpellcastingID, UniqueID).Choices.RemoveAll(s => ConfigManager.SourceInvariantComparer.Equals(s, r));
                 Model.Save();
                 if (svm.BadChoice)
                 {
                     Spells.Remove(svm);
                 }
                 if (svm.BadChoice)
                 {
                     spells.Remove(svm);
                 }
             }
             OnPropertyChanged("Count");
             OnPropertyChanged("Prepared");
             ChangedSelectedSpells(SpellcastingID);
         }
     }, (par) => par is SpellViewModel svm && choice != null);
     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();
         Model.Context.Player.GetSpellChoice(SpellcastingID, UniqueID).Choices.Clear();
         Model.Save();
         foreach (SpellViewModel s in spells)
         {
             s.Prepared = false;
         }
         spells.RemoveAll(s => s.BadChoice);
         UpdateSpells();
         OnPropertyChanged("Count");
         OnPropertyChanged("Selected");
         ChangedSelectedSpells(SpellcastingID);
         IsBusy = false;
     });
     AddSpells();
 }