コード例 #1
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);
        }
コード例 #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
        private void BuildAttacks()
        {
            List <Possession> equip = new List <Possession>();

            foreach (Possession pos in Program.Context.Player.GetItemsAndPossessions())
            {
                if (pos.Count > 0 && pos.BaseItem != null && pos.BaseItem != "")
                {
                    Item i = Program.Context.GetItem(pos.BaseItem, null);
                    if (pos.Equipped != EquipSlot.None || i is Weapon || i is Armor || i is Shield)
                    {
                        equip.Add(pos);
                    }
                }
            }
            equip.Sort(delegate(Possession t1, Possession t2)
            {
                if (t1.Hightlight && !t2.Hightlight)
                {
                    return(-1);
                }
                else if (t2.Hightlight && !t1.Hightlight)
                {
                    return(1);
                }
                else
                {
                    if (!string.Equals(t1.Equipped, EquipSlot.None, StringComparison.OrdinalIgnoreCase) && string.Equals(t2.Equipped, EquipSlot.None, StringComparison.OrdinalIgnoreCase))
                    {
                        return(-1);
                    }
                    else if (!string.Equals(t2.Equipped, EquipSlot.None, StringComparison.OrdinalIgnoreCase) && string.Equals(t1.Equipped, EquipSlot.None, StringComparison.OrdinalIgnoreCase))
                    {
                        return(1);
                    }
                    else
                    {
                        return(t1.ToString().CompareTo(t2.ToString()));
                    }
                }
            });

            List <KeyValuePair <string, AttackInfo> > attackinfos = new List <KeyValuePair <string, AttackInfo> >();
            List <SpellcastingFeature> spellcasts = new List <SpellcastingFeature>(from f in Program.Context.Player.GetFeatures() where f is SpellcastingFeature && ((SpellcastingFeature)f).SpellcastingID != "MULTICLASS" select(SpellcastingFeature) f);
            List <KeyValuePair <string, AttackInfo> > addattackinfos = new List <KeyValuePair <string, AttackInfo> >();

            foreach (SpellcastingFeature scf in spellcasts)
            {
                Spellcasting sc = Program.Context.Player.GetSpellcasting(scf.SpellcastingID);
                foreach (Spell s in sc.GetLearned(Program.Context.Player, Program.Context))
                {
                    if (sc.Highlight != null && sc.Highlight != "" && s.Name.ToLowerInvariant() == sc.Highlight.ToLowerInvariant())
                    {
                        AttackInfo ai = Program.Context.Player.GetAttack(s, scf.SpellcastingAbility);
                        if (ai != null && ai.Damage != null && ai.Damage != "")
                        {
                            attackinfos.Add(new KeyValuePair <string, AttackInfo>(s.Name, ai));
                        }
                    }
                    else
                    {
                        AttackInfo ai = Program.Context.Player.GetAttack(s, scf.SpellcastingAbility);
                        if (ai != null && ai.Damage != null && ai.Damage != "")
                        {
                            addattackinfos.Add(new KeyValuePair <string, AttackInfo>(s.Name, ai));
                        }
                    }
                }
                //No prepared Cantrips, so whatever
                //foreach (Spell s in sc.GetPrepared(Program.Context.Player, Program.Context))
                //{
                //    if (sc.Highlight != null && sc.Highlight != "" && s.Name.ToLowerInvariant() == sc.Highlight.ToLowerInvariant())
                //    {
                //        AttackInfo ai = Program.Context.Player.GetAttack(s, scf.SpellcastingAbility);
                //        if (ai != null && ai.Damage != null && ai.Damage != "") attackinfos.Add(new KeyValuePair<string, AttackInfo>(s.Name, ai));
                //    }
                //    else
                //    {
                //        AttackInfo ai = Program.Context.Player.GetAttack(s, scf.SpellcastingAbility);
                //        if (ai != null && ai.Damage != null && ai.Damage != "") addattackinfos.Add(new KeyValuePair<string, AttackInfo>(s.Name, ai));
                //    }
                //}
                //foreach (Spell s in sc.GetAdditionalClassSpells(Program.Context.Player, Program.Context))
                //{
                //    if (sc.Highlight != null && sc.Highlight != "" && s.Name.ToLowerInvariant() == sc.Highlight.ToLowerInvariant())
                //    {
                //        AttackInfo ai = Program.Context.Player.GetAttack(s, scf.SpellcastingAbility);
                //        if (ai != null && ai.Damage != null && ai.Damage != "") attackinfos.Add(new KeyValuePair<string, AttackInfo>(s.Name, ai));
                //    }
                //    else
                //    {
                //        AttackInfo ai = Program.Context.Player.GetAttack(s, scf.SpellcastingAbility);
                //        if (ai != null && ai.Damage != null && ai.Damage != "") addattackinfos.Add(new KeyValuePair<string, AttackInfo>(s.Name, ai));
                //    }
                //}
            }
            foreach (Possession pos in equip)
            {
                IEnumerable <AttackInfo> ais = Program.Context.Player.GetAttack(pos);
                if (ais != null)
                {
                    attackinfos.AddRange(ais.Select(ai => new KeyValuePair <string, AttackInfo>(pos.ToString() + (ai.AttackOptions.Count > 0 ? " (" + string.Join(", ", ai.AttackOptions) + " )" : ""), ai)));
                }
            }
            foreach (ModifiedSpell s in Program.Context.Player.GetBonusSpells(false))
            {
                if (Utils.Matches(Program.Context, s, "Attack or Save", null))
                {
                    AttackInfo ai = Program.Context.Player.GetAttack(s, s.differentAbility);
                    if (ai != null && ai.Damage != null && ai.Damage != "")
                    {
                        attackinfos.Add(new KeyValuePair <string, AttackInfo>(s.Name, ai));
                    }
                }
            }
            attackinfos.AddRange(addattackinfos);
            //attackinfos.OrderBy((a, b) =>
            //{
            //    int oa = Program.Context.Player.AttackOrder.FindIndex(s => StringComparer.OrdinalIgnoreCase.Equals(a.Key, s));
            //    int ob = Program.Context.Player.AttackOrder.FindIndex(s => StringComparer.OrdinalIgnoreCase.Equals(b.Key, s));
            //    if (oa < 0) oa = int.MaxValue;
            //    if (ob < 0) ob = int.MaxValue;
            //    return oa.CompareTo(ob);
            //});

            AttackOrder.Items.Clear();
            foreach (var a in attackinfos.OrderBy(a => { int i = Program.Context.Player.AttackOrder.FindIndex(s => StringComparer.OrdinalIgnoreCase.Equals(a.Key, s)); return(i < 0 ? int.MaxValue : i); }))
            {
                AttackOrder.Items.Add(a);
            }
        }