コード例 #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();
        }