public static void LoadFeats() { List <Feat> set = XmlListLoader <Feat> .Load("Feats.xml"); featMap = new Dictionary <string, Feat>(); altFeatMap = new Dictionary <string, string>(); types = new SortedDictionary <String, String>(); foreach (Feat feat in set) { bool changed; string commaName = CMStringUtilities.DecommaText(feat.Name, out changed); if (changed) { feat.AltName = feat.Name; feat.Name = commaName; altFeatMap.Add(feat.AltName, feat.Name); } featMap[feat.Name] = feat; //add to types list foreach (string type in feat.Types) { types[type] = type; } if (feat.Types.Count == 0) { Debug.WriteLine(feat.Name); } feats = new ObservableCollection <Feat>(); foreach (Feat f in Feat.FeatMap.Values) { feats.Add(f); } } if (DBSettings.UseDB) { _FeatsDB = new DBLoader <Feat>("feats.db"); foreach (Feat f in _FeatsDB.Items) { feats.Add(f); if (!FeatMap.ContainsKey(f.Name)) { FeatMap[f.Name] = f; } } } _FeatsLoaded = true; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (targetType != typeof(string)) { return(DependencyProperty.UnsetValue); } if (value == null) { return("0"); } else { return(CMStringUtilities.PlusFormatNumber(Monster.AbilityBonus((int)value))); } }
private void FixSenses() { Type targeTypes = typeof(string); var objects = new object[2]; CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture; var xConverter = new SensesConverter(); objects[0] = _Monster.Senses; objects[1] = _Monster.Perception; var senses = (string)xConverter.Convert(objects, targeTypes, null, currentCulture); string sensesText = ""; if (senses.Length > 0) { sensesText += senses + "; "; } _Monster.Senses = sensesText + "Perception " + CMStringUtilities.PlusFormatNumber(_Monster.Perception); }
object[] IMultiValueConverter.ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { object[] objects = new object[targetTypes.Length]; string senses = ((string)value).Trim(); string sensesText = ""; if (senses.Length > 0) { sensesText += senses + "; "; } objects[0] = sensesText + "Perception " + CMStringUtilities.PlusFormatNumber(_Perception); objects[1] = _Perception; return(objects); }
List <Inline> CreateSpellsBlockItem(ObservableCollection <SpellBlockInfo> list) { List <Inline> lines = new List <Inline>(); bool multiblock = false; foreach (SpellBlockInfo blockinfo in list) { string titleText = ""; if (blockinfo.SpellLikeAbilities) { if (blockinfo.Class != null) { titleText += blockinfo.Class + " "; } titleText += "Spell-Like Abilities "; } else { if (blockinfo.Class != null) { titleText += blockinfo.Class + " "; } titleText += "Spells " + blockinfo.BlockType + " "; } if (multiblock) { lines.Add(new LineBreak()); } multiblock = true; lines.Add(new Bold(new Run(titleText))); lines.Add(new Run("(CL " + BlockCreator.PastTenseNumber(blockinfo.CasterLevel.ToString()))); if (blockinfo.SpellFailure != null) { lines.Add(new Run("; " + blockinfo.SpellFailure.Value + "% spell failure")); } if (blockinfo.Concentration != null) { lines.Add(new Run("; ")); lines.AddRange(CreateRulesLink("Concentration", "Concentration", "Magic", " ")); lines.Add(new Run(CMStringUtilities.PlusFormatNumber(blockinfo.Concentration.Value))); } if (blockinfo.MeleeTouch != null) { lines.Add(new Run("; " + CMStringUtilities.PlusFormatNumber(blockinfo.MeleeTouch.Value) + " melee touch")); } if (blockinfo.RangedTouch != null) { lines.Add(new Run("; " + CMStringUtilities.PlusFormatNumber(blockinfo.RangedTouch.Value) + " ranged touch")); } lines.Add(new Run(") ")); //start spells on their own line lines.Add(new LineBreak()); var text = ""; foreach (SpellLevelInfo levelinfo in blockinfo.Levels) { //indentation of spell list text = " "; if (levelinfo.Level != null) { text += BlockCreator.PastTenseNumber(levelinfo.Level.Value); } if (levelinfo.PerDay != null || levelinfo.AtWill || levelinfo.Constant) { if (text.Length > 0) { // space between spell level and number/day [3rd(3/day or 3rd (3/day)] text += " "; } if (!blockinfo.SpellLikeAbilities) { text += "("; } if (levelinfo.AtWill) { text += "At will"; } else if (levelinfo.Constant) { text += "Constant"; } else { text += levelinfo.PerDay + "/day"; } if (levelinfo.Cast != null) { text += "; " + levelinfo.Cast + " cast"; } if (!blockinfo.SpellLikeAbilities) { text += ")"; } } if (text.Length > 0) { text += "-"; } lines.Add(new Run(text)); bool firstLink = true; foreach (SpellInfo spellInfo in levelinfo.Spells) { if (!firstLink) { lines.Add(new Run(", ")); } firstLink = false; Hyperlink link = new Hyperlink(new Run(spellInfo.Name)); link.Tag = spellInfo.Name; link.Click += new RoutedEventHandler(SpellLinkClicked); if (spellInfo.Spell != null) { link.DataContext = spellInfo.Spell; ToolTip t = (ToolTip)App.Current.MainWindow.FindResource("ObjectToolTip"); if (t != null) { ToolTipService.SetShowDuration(link, 360000); link.ToolTip = t; link.ToolTipOpening += new ToolTipEventHandler(link_ToolTipOpening); } } lines.Add(link); if (spellInfo.Mythic) { lines.Add(new Run(" [M]")); } String afterBlock = ""; After addAfter = delegate() { if (afterBlock.Length != 0) { afterBlock += "; "; } }; if (spellInfo.Count != null) { afterBlock += spellInfo.Count; } if (spellInfo.DC != null) { addAfter(); afterBlock += "DC " + spellInfo.DC; } if (spellInfo.AlreadyCast || spellInfo.Cast != null) { addAfter(); if (spellInfo.AlreadyCast) { afterBlock += "already "; } else { afterBlock += spellInfo.Cast.Value + " "; } afterBlock += "cast"; } if (spellInfo.Only != null) { addAfter(); afterBlock += spellInfo.Only; } if (spellInfo.Other != null) { addAfter(); afterBlock += spellInfo.Other; } if (afterBlock.Length > 0) { lines.Add(new Run(" (" + afterBlock + ")")); } } if (lines.Count > 0) { //Put each spell level on seperate line lines.Add(new LineBreak()); } if (levelinfo.More != null) { lines.Add(new Run(", " + levelinfo.More + " more")); } } } if (lines.Count > 0) { lines.Add(new LineBreak()); } return(lines); }