Ejemplo n.º 1
0
        private void _FillOutDataToCard(Card card)
        {
            card.Id   = CardManager.GetInstance().GetNextValidId();
            card.Name = CardName_text.Text;
            card.Cost = Convert.ToUInt32(CardCost_text.Text);
            card.Type = (Card.CardType)CardType_chooser.SelectedIndex;
            card.SubType = (Card.CardSubType)CardSubtype_chooser.SelectedIndex;
            card.Attack = Convert.ToInt32(CardAttack_text.Text);
            card.Defense = Convert.ToInt32(CardDefense_text.Text);
            card.Hitpoints = Convert.ToInt32(CardHitpoints_text.Text);

            // Factions
            card.SetFactions(0);
            if (true == FactionHuman_checkbox.Checked) { card.AddFaction(GameEntity.Faction.FACTION_HUMAN); }
            if (true == FactionVampire_checkbox.Checked) { card.AddFaction(GameEntity.Faction.FACTION_VAMPIRE); }
            if (true == FactionScoundrel_checkbox.Checked) { card.AddFaction(GameEntity.Faction.FACTION_SCOUNDREL); }
            if (true == FactionBarbarian_checkbox.Checked) { card.AddFaction(GameEntity.Faction.FACTION_BARBARIAN); }
            if (true == FactionDragon_checkbox.Checked) { card.AddFaction(GameEntity.Faction.FACTION_DRAGON); }
            if (true == FactionOrc_checkbox.Checked) { card.AddFaction(GameEntity.Faction.FACTION_ORC); }

            // Card Effects
            card.RemoveAllEffects();
            foreach(Effect e in CardEffects_listbox.Items)
            {
                card.AddEffectById(e.Id);
            }
        }
Ejemplo n.º 2
0
        public void Parse(List<Card> outList)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(mFilename);

            XmlNodeList nodes = doc.SelectNodes(ROOT_NODE);

            foreach (XmlNode node in nodes)
            {
                Card card = new Card();

                foreach(XmlNode c in node.ChildNodes)
                {
                    switch(c.Name)
                    {
                        case P_NAME:
                            {
                                card.Name = c.InnerText;
                                break;
                            }
                        case P_TYPE:
                            {
                                card.Type = ParseEnum<Card.CardType>(c.InnerText);
                                break;
                            }
                        case P_SUBTYPE:
                            {
                                card.SubType = ParseEnum<Card.CardSubType>(c.InnerText);
                                break;
                            }
                        case P_ID:
                            {
                                card.Id = Convert.ToUInt32(c.InnerText);
                                break;
                            }
                        case P_COST:
                            {
                                card.Cost = Convert.ToUInt32(c.InnerText);
                                break;
                            }
                        case P_FACTIONS:
                            {
                                card.SetFactions(Convert.ToUInt32(c.InnerText));
                                break;
                            }
                        case P_FRAMECOLOR:
                            {
                                card.FrameColor = ParseEnum<Card.eFrameColor>(c.InnerText);
                                break;
                            }
                        case P_ATTACK:
                            {
                                card.Attack = Convert.ToInt32(c.InnerText);
                                break;
                            }
                        case P_DEFENSE:
                            {
                                card.Defense = Convert.ToInt32(c.InnerText);
                                break;
                            }
                        case P_HITPOINTS:
                            {
                                card.Hitpoints = Convert.ToInt32(c.InnerText);
                                break;
                            }
                        case P_EFFECTS:
                            {
                                foreach(XmlNode e in c.ChildNodes)
                                {
                                    uint eId = Convert.ToUInt32(e.InnerText);
                                    card.AddEffectById(eId);
                                }
                                break;
                            }
                        default:
                            {
                                Console.WriteLine("Unhandled node type: " + c.Name);
                                break;
                            }
                    }
                }

                outList.Add(card);
            }
        }