Exemplo n.º 1
0
        public void Parse(List<Effect> outList)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(mFilename);

            XmlNodeList nodes = doc.SelectNodes(ROOT_NODE);

            foreach (XmlNode node in nodes)
            {
                Effect effect = new Effect();

                foreach (XmlNode c in node.ChildNodes)
                {
                    switch (c.Name)
                    {
                        case P_NAME:
                            {
                                effect.Name = c.InnerText;
                                break;
                            }
                        case P_ID:
                            {
                                effect.Id = Convert.ToUInt32(c.InnerText);
                                break;
                            }
                        case P_TARGETRANGE:
                            {
                                effect.Range = ParseEnum<Effect.TargetRange>(c.InnerText);
                                break;
                            }
                        case P_TARGETTYPES:
                            {
                                effect.SetTargetTypes(Convert.ToUInt32(c.InnerText));
                                break;
                            }
                        case P_MODIFIERS:
                            {
                                foreach(XmlNode n in c.ChildNodes)
                                {
                                    Effect.Modifier mod = new Effect.Modifier();
                                    mod.Type = ParseEnum<Effect.ModifierType>(n.SelectSingleNode(P_TYPE).InnerText);
                                    mod.Value = Convert.ToInt32(n.SelectSingleNode(P_VALUE).InnerText);
                                    effect.AddModifier(mod);
                                }
                                break;
                            }
                        default:
                            {
                                Console.WriteLine("Unhandled node type: " + c.Name);
                                break;
                            }
                    }
                }

                outList.Add(effect);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Takes an effect reference and populates it with the current form data
        /// </summary>
        /// <param name="effect">Reference to effect</param>
        private void _FillOutDataToEffect(Effect effect)
        {
            effect.Id = EffectManager.GetInstance().GetNextValidId();
            effect.Name = EffectName_text.Text;
            effect.Range = (Effect.TargetRange)TargetRange_chooser.SelectedIndex;

            // Target Types
            effect.SetTargetTypes(0);
            if (true == TargetPlayer_checkBox.Checked) { effect.AddTargetType(GameEntity.EntityType.TYPE_PLAYER); }
            if (true == TargetCreature_checkBox.Checked) { effect.AddTargetType(GameEntity.EntityType.TYPE_CREATURE); }
            if (true == TargetRelic_checkBox.Checked) { effect.AddTargetType(GameEntity.EntityType.TYPE_RELIC); }
            if (true == TargetSpell_checkBox.Checked) { effect.AddTargetType(GameEntity.EntityType.TYPE_SPELL); }
            if (true == TargetDefSpell_checkBox.Checked) { effect.AddTargetType(GameEntity.EntityType.TYPE_DEFSPELL); }
            if (true == TargetHand_checkBox.Checked) { effect.AddTargetType(GameEntity.EntityType.TYPE_HAND); }
            if (true == TargetLibrary_checkBox.Checked) { effect.AddTargetType(GameEntity.EntityType.TYPE_LIBRARY); }
            if (true == TargetGraveyard_checkBox.Checked) { effect.AddTargetType(GameEntity.EntityType.TYPE_GRAVEYARD); }

            // Modifiers
            effect.RemoveAllModifiers();
            foreach(Effect.Modifier mod in Modifiers_listbox.Items)
            {
                effect.AddModifier((Effect.Modifier)mod);
            }
        }