public override void Refresh(SpellcastingFeature feature) { Title = (feature.DisplayName ?? feature.SpellcastingID) + " - " + Choice?.Name ?? Choice?.UniqueID ?? "Additional"; SpellcastingFeature = feature; AddSpells(); OnPropertyChanged(null); }
public override void Refresh(SpellcastingFeature feature) { SpellcastingFeature = feature; Spellcasting = Model.Context.Player.GetSpellcasting(SpellcastingID); AddSpells(); OnPropertyChanged(null); }
public void Refresh(SpellcastingFeature feature, SpellChoiceFeature choice) { Choice = choice; SpellcastingFeature = feature; Title = (feature.DisplayName ?? feature.SpellcastingID) + " - " + Choice?.Name ?? Choice?.UniqueID ?? "Additional"; AddSpells(); OnPropertyChanged(null); }
private void spellcastingFeatureToolStripMenuItem_Click(object sender, EventArgs e) { SpellcastingFeature f = new SpellcastingFeature(); f = new FeatureForms.SpellcastingFeatureForm(f).edit(HistoryManager); list.Add(f); fill(); }
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); }
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(); }
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(); }
public SpellPrepareViewModel(PlayerModel model, SpellcastingFeature spellcasting) : base(model, spellcasting, "Prepare " + (spellcasting.DisplayName ?? spellcasting.SpellcastingID) + " Spells") { Image = ImageSource.FromResource("CB_5e.images.prepare.png"); 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(); if (svm.BadChoice) { Spells.Remove(svm); } if (svm.BadChoice) { spells.Remove(svm); } } OnPropertyChanged("Count"); OnPropertyChanged("Prepared"); (model as PlayerViewModel)?.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; } spells.RemoveAll(s => s.BadChoice); UpdateSpells(); OnPropertyChanged("Count"); OnPropertyChanged("Prepared"); (model as PlayerViewModel)?.ChangedPreparedSpells(SpellcastingID); IsBusy = false; }); AddSpells(); }
public SpellcastingCapsule(SpellcastingFeature scf) { Spellcastingfeature = scf; }