Monster AdvanceMonster(Monster item) { Monster monster = item; if (monster != null && _AdvancerVisible) { monster = (Monster)item.Clone(); if (_hdChange != 1) { int dice = _hdCount * (_hdChange - 1); Stat stat = (Stat)_bonusStat; bool size = _sizeChange50HD; int res = monster.AddRacialHD(dice, stat, size); if (res != 0) { monster.Name = monster.Name + " " + CMStringUtilities.PlusFormatNumber(res) + " HD"; } } if (_selectedTemplate == 1) { if (monster.MakeHalfDragon(_dragonColor)) { monster.Name = "Half-Dragon " + monster.Name; } } if (_selectedTemplate == 2) { HashSet <Stat> bonusStats = new HashSet <Stat>(); if (AdvancerBoxChecked(Resource.Id.strBox)) { bonusStats.Add(Stat.Strength); } if (AdvancerBoxChecked(Resource.Id.dexBox)) { bonusStats.Add(Stat.Dexterity); } if (AdvancerBoxChecked(Resource.Id.conBox)) { bonusStats.Add(Stat.Constitution); } if (AdvancerBoxChecked(Resource.Id.intBox)) { bonusStats.Add(Stat.Intelligence); } if (AdvancerBoxChecked(Resource.Id.wisBox)) { bonusStats.Add(Stat.Wisdom); } if (AdvancerBoxChecked(Resource.Id.chaBox)) { bonusStats.Add(Stat.Charisma); } if (monster.MakeHalfFiend(bonusStats)) { monster.Name = "Half-Fiend " + monster.Name; } } if (_selectedTemplate == 3) { HashSet <Stat> bonusStats = new HashSet <Stat>(); if (AdvancerBoxChecked(Resource.Id.strBox)) { bonusStats.Add(Stat.Strength); } if (AdvancerBoxChecked(Resource.Id.dexBox)) { bonusStats.Add(Stat.Dexterity); } if (AdvancerBoxChecked(Resource.Id.conBox)) { bonusStats.Add(Stat.Constitution); } if (AdvancerBoxChecked(Resource.Id.intBox)) { bonusStats.Add(Stat.Intelligence); } if (AdvancerBoxChecked(Resource.Id.wisBox)) { bonusStats.Add(Stat.Wisdom); } if (AdvancerBoxChecked(Resource.Id.chaBox)) { bonusStats.Add(Stat.Charisma); } if (monster.MakeHalfCelestial(bonusStats)) { monster.Name = "Half-Celestial " + monster.Name; } } if (_selectedTemplate == 4) { bool bloody = AdvancerBoxChecked(Resource.Id.bloodyBox); bool burning = AdvancerBoxChecked(Resource.Id.burningBox); bool champion = AdvancerBoxChecked(Resource.Id.championBox); if (monster.MakeSkeleton(bloody, burning, champion)) { if (champion) { monster.Name = "Skeletal Champion " + monster.Name; } else { monster.Name += " Skeleton"; } if (burning) { monster.Name = "Burning " + monster.Name; } if (bloody) { monster.Name = "Bloody " + monster.Name; } } } if (_selectedTemplate == 5) { if (monster.MakeVampire()) { monster.Name = "Vampire " + monster.Name; } } if (_selectedTemplate == 6) { Monster.ZombieType zt = (Monster.ZombieType)_zombieType; if (monster.MakeZombie(zt)) { monster.Name = "Zombie " + monster.Name; if (zt == Monster.ZombieType.Fast) { monster.Name = "Fast " + monster.Name; } else if (zt == Monster.ZombieType.Plague) { monster.Name = "Plague " + monster.Name; } } } CheckBox cb = _AdvancerLayout.FindViewById <CheckBox>(Resource.Id.advancedBox); if (cb.Checked) { for (int i = 0; i < _advMuliplier; i++) { monster.MakeAdvanced(); } int advlevels = _advMuliplier; monster.Name += " (Adv " + advlevels.PlusFormat() + ")"; } int count = _sizeMultiplier; if (_sizeChange > 0) { int added = 0; for (int i = 0; i < count; i++) { if (monster.MakeGiant()) { added++; } } if (added == 1) { monster.Name = "Giant " + monster.Name; } if (added > 1) { monster.Name = "Giant x" + added + " " + monster.Name; } } else if (_sizeChange < 0) { int added = 0; for (int i = 0; i < count; i++) { if (monster.MakeYoung()) { added++; } } if (added == 1) { monster.Name = "Young " + monster.Name; } if (added > 1) { monster.Name = "Young x" + added + " " + monster.Name; } } if (_outsiderChange == 1) { if (monster.MakeCelestial()) { monster.Name = "Celestial " + monster.Name; } } else if (_outsiderChange == 2) { if (monster.MakeEntropic()) { monster.Name = "Entopic " + monster.Name; } } else if (_outsiderChange == 3) { if (monster.MakeFiendish()) { monster.Name = "Fiendish " + monster.Name; } } else if (_outsiderChange == 4) { if (monster.MakeResolute()) { monster.Name = "Resolute " + monster.Name; } } cb = _AdvancerLayout.FindViewById <CheckBox>(Resource.Id.augmentSummoningBox); if (cb.Checked) { monster.AugmentSummoning(); monster.Name = "Augmented " + monster.Name; } } return(monster); }
public Monster AdvanceMonster(Monster oldMonster) { if (oldMonster == null) { return(null); } Monster monster = (Monster)oldMonster.Clone(); switch (template) { case AdvancerTemplate.HalfDragon: if (monster.MakeHalfDragon(_DragonColor)) { monster.Name = "Half-Dragon " + monster.Name; } break; case AdvancerTemplate.Skeleton: if (monster.MakeSkeleton(_SelectedSkeletonTypes[0], _SelectedSkeletonTypes[1], _SelectedSkeletonTypes[2])) { monster.Name = "Skeletal " + monster.Name; for (int i = 2; i >= 0; i--) { if (_SelectedSkeletonTypes[i]) { monster.Name = SkeletonText(i) + " " + monster.Name; } } } break; case AdvancerTemplate.Zombie: if (monster.MakeZombie(_ZombieType)) { monster.Name = ZombieText(_ZombieType, true) + " " + monster.Name; } break; case AdvancerTemplate.Vampire: if (monster.MakeVampire()) { monster.Name = "Vampire " + monster.Name; } break; case AdvancerTemplate.HalfCelestial: if (SelectedStats.Count == 3 && monster.MakeHalfCelestial(SelectedStats)) { monster.Name = "Half-Celestial " + monster.Name; } break; case AdvancerTemplate.HalfFiend: if (SelectedStats.Count == 3 && monster.MakeHalfFiend(SelectedStats)) { monster.Name = "Half-Fiend " + monster.Name; } break; } if (racialHDChange != 0) { int dice = racialHDChange; Stat stat = racialBonusStat; bool size = racialSizeChange; int res = monster.AddRacialHD(dice, stat, size); if (res != 0) { monster.Name = monster.Name + " " + CMStringUtilities.PlusFormatNumber(res) + " HD"; } } if (advancedLevel > 0) { int count = advancedLevel; int added = 0; for (int i = 0; i < count; i++) { if (monster.MakeAdvanced()) { added++; } } if (added > 0) { monster.Name += " (Adv " + added.PlusFormat() + ")"; } } if (simpleSize != 0) { if (simpleSize > 0) { int count = simpleSize; int added = 0; for (int i = 0; i < count; i++) { if (monster.MakeGiant()) { added++; } } if (added == 1) { monster.Name = "Giant " + monster.Name; } if (added > 1) { monster.Name = "Giant x" + added + " " + monster.Name; } } else { int count = -simpleSize; int added = 0; for (int i = 0; i < count; i++) { if (monster.MakeYoung()) { added++; } } if (added == 1) { monster.Name = "Young " + monster.Name; } if (added > 1) { monster.Name = "Young x" + added + " " + monster.Name; } } } if (simpleOutsiderType != null) { switch (simpleOutsiderType) { case Monster.HalfOutsiderType.Celestial: if (monster.MakeCelestial()) { monster.Name = "Celestial " + monster.Name; } break; case Monster.HalfOutsiderType.Entropic: if (monster.MakeEntropic()) { monster.Name = "Entopic " + monster.Name; } break; case Monster.HalfOutsiderType.Fiendish: if (monster.MakeFiendish()) { monster.Name = "Fiendish " + monster.Name; } break; case Monster.HalfOutsiderType.Resolute: if (monster.MakeResolute()) { monster.Name = "Resolute " + monster.Name; } break; } } if (augmentSummoning) { monster.AugmentSummoning(); monster.Name = "Augmented " + monster.Name; } return(monster); }
private void spellFixButton_Click(object sender, RoutedEventArgs e) { List <string> source = new List <string>() { "AP 41", "AP 42", "AP 43", "AP 44", "AP 45", "AP 46", "Inner Sea World Guide", "Undead Revisited", "Academy Of Secrets", "Tomb Of The Iron Medusa", "Cult Of The Ebon Destroyers", "Lost Cities Of Golarion" }; XDocument doc1 = XDocument.Load("bestiary.xml"); XDocument doc2 = XDocument.Load("monster_bestiary_full.xml"); var vals = from c in doc2.Descendants("item") select new { Name = c.Element("Name").Value, SpellsKnown = c.ElementValue("SpellsKnown"), SpellsPrepared = c.ElementValue("SpellsPrepared"), SpellLikeAbilities = c.ElementValue("SpellLikeAbilities"), Source = c.ElementValue("Source"), Element = c }; int notfoundcount = 0; int namecommacount = 0; int namecommacount2 = 0; int foundparen = 0; int added = 0; foreach (var item in vals) { bool found = false; IEnumerable <XElement> val2 = from c in doc1.Descendants("Monster") where String.Compare(c.Element("Name").Value, item.Name, true) == 0 select c; foreach (var node in val2) { found = true; if (item.SpellsKnown != null && item.SpellsKnown.Length > 0) { node.SetElementValue("SpellsKnown", item.SpellsKnown); } if (item.SpellsPrepared != null && item.SpellsPrepared.Length > 0) { node.SetElementValue("SpellsPrepared", item.SpellsPrepared); } if (item.SpellLikeAbilities != null && item.SpellLikeAbilities.Length > 0) { node.SetElementValue("SpellLikeAbilities", item.SpellLikeAbilities); } } if (!found) { string name = item.Name; name = Regex.Replace(name, "\\(Giant\\)", ""); bool giant = name != item.Name; name = Regex.Replace(name, " \\(.+\\)", ""); string preswarm = name; name = Regex.Replace(name, ", Swarm", ""); bool swarm = (preswarm != name); name = Regex.Replace(name, ", Common", ""); name = CMStringUtilities.DecommaText(name); if (giant) { name = "Giant " + name.Trim(); } if (swarm) { name = name.Trim() + " Swarm"; } name = name.Trim(); val2 = from c in doc1.Descendants("Monster") where String.Compare(c.Element("Name").Value, name, true) == 0 select c; foreach (var node in val2) { found = true; namecommacount++; if (item.SpellsKnown != null && item.SpellsKnown.Length > 0) { node.SetElementValue("SpellsKnown", item.SpellsKnown); } if (item.SpellsPrepared != null && item.SpellsPrepared.Length > 0) { node.SetElementValue("SpellsPrepared", item.SpellsPrepared); } if (item.SpellLikeAbilities != null && item.SpellLikeAbilities.Length > 0) { node.SetElementValue("SpellLikeAbilities", item.SpellLikeAbilities); } } } if (!found) { string name = item.Name; name = Regex.Replace(name, "\\(Giant\\)", ""); bool giant = name != item.Name; name = Regex.Replace(name, "(?<start>.+?), (?<end>.+)", delegate(Match m) { return(CMStringUtilities.DecommaText(m.Groups["end"].Value)); }); if (giant) { name = "Giant " + name.Trim(); } val2 = from c in doc1.Descendants("Monster") where String.Compare(c.Element("Name").Value, name, true) == 0 select c; foreach (var node in val2) { found = true; namecommacount2++; if (item.SpellsKnown != null && item.SpellsKnown.Length > 0) { node.SetElementValue("SpellsKnown", item.SpellsKnown); } if (item.SpellsPrepared != null && item.SpellsPrepared.Length > 0) { node.SetElementValue("SpellsPrepared", item.SpellsPrepared); } if (item.SpellLikeAbilities != null && item.SpellLikeAbilities.Length > 0) { node.SetElementValue("SpellLikeAbilities", item.SpellLikeAbilities); } } } if (!found) { string name = item.Name; name = Regex.Replace(name, ".+\\((?<name>.+)\\).*", delegate(Match m) { return(m.Groups["name"].Value); }); val2 = from c in doc1.Descendants("Monster") where String.Compare(c.Element("Name").Value, name, true) == 0 select c; foreach (var node in val2) { found = true; foundparen++; if (item.SpellsKnown != null && item.SpellsKnown.Length > 0) { node.SetElementValue("SpellsKnown", item.SpellsKnown); } if (item.SpellsPrepared != null && item.SpellsPrepared.Length > 0) { node.SetElementValue("SpellsPrepared", item.SpellsPrepared); } if (item.SpellLikeAbilities != null && item.SpellLikeAbilities.Length > 0) { node.SetElementValue("SpellLikeAbilities", item.SpellLikeAbilities); } } } if (!found) { if (item.Source == "d20pfsrd") { XElement x = new XElement(item.Element); x.SetElementValue("Source", "PFRPG Bestiary"); x.Name = "Monster"; doc1.Root.Add(x); added++; } else if (source.FindIndex(a => a == item.Source) != -1) { XElement x = new XElement(item.Element); x.Name = "Monster"; doc1.Root.Add(x); added++; } else { System.Console.WriteLine(item.Name + " - " + item.Source); notfoundcount++; } } } System.Console.WriteLine("Not Found: " + notfoundcount); System.Console.WriteLine("Found Decomma: " + namecommacount); System.Console.WriteLine("Found Remove Prefix: " + namecommacount2); System.Console.WriteLine("Found Paren: " + foundparen); System.Console.WriteLine("Added: " + added); doc1.Save("bestiary2.xml"); }