public MainWindow()
        {
            InitializeComponent();
            Assembly assembly = Assembly.GetExecutingAssembly();

            db = SpellsManager.Load(assembly.GetManifestResourceStream("SpellViewer.PHB Spells 3.4.6.xml"));

            this.Title = "Spell Viewer (Using: PHB Spells 3.4.6.xml)";

            /*
            Abjuration: spells of protection, blocking, and banishing. Specialists are called abjurers.
            Conjuration: spells that bring creatures or materials. Specialists are called conjurers.
            Divination: spells that reveal information. Specialists are called diviners.
            Enchantment: spells that magically imbue the target or give the caster power over the target. Specialists are called enchanters.
            Evocation: spells that manipulate energy or create something from nothing. Specialists are called evokers.
            Illusion: spells that alter perception or create false images. Specialists are called illusionists.
            Necromancy: spells that manipulate life or life force. Specialists are called necromancers.
            Transmutation: spells that transform the target. Specialists are called transmuters.
            */

            Schools.Add("A", "Abjuration");
            Schools.Add("C", "Conjuration");
            Schools.Add("D", "Divination");
            Schools.Add("EN", "Enchantment");
            Schools.Add("EV", "Evocation");
            Schools.Add("I", "Illusion");
            Schools.Add("N", "Necromancy");
            Schools.Add("T", "Transmutation");

            // Debug
            //DisplaySpell(db.spells[0]);

            this.Loaded += MainWindow_Loaded;
        }
Beispiel #2
0
        public static SpellsManager Load(Stream stream)
        {
            SpellsManager context = new SpellsManager();
            /*XmlSerializer serializer = new XmlSerializer(typeof(SpellsManager));

            using (StreamReader reader = new StreamReader(path))
            {
                context = (SpellsManager)serializer.Deserialize(reader);
            }*/

            using (StreamReader reader = new StreamReader(stream))
            {
                XDocument doc = XDocument.Load(reader);
                context.spells = doc.Element("spells").Elements("spell").Select(f => new spell()
                {
                    name = f.Element("name").Value,
                    level = f.Element("level").Value,
                    school = f.Element("school").Value,
                    ritual = f.Element("ritual").Value,
                    time = f.Element("time").Value,
                    range = f.Element("range").Value,
                    components = f.Element("components").Value,
                    duration = f.Element("duration").Value,
                    classes = f.Element("classes").Value,
                    text = f.Elements("text").Select(t=> { return (t.FirstNode is XNode ? t.FirstNode.ToString() : ""); } ),
                    roll = f.Elements("roll").Select(t => { return (t.FirstNode is XNode ? t.FirstNode.ToString() : ""); } ),
                }).ToArray();
            }
            return context;
        }