private void parse_power_block(XElement xml_doc)
        {
            IEnumerable <XElement> power_list = xml_doc.Descendants("Power");

            foreach (XElement power in power_list)
            {
                PlayerPower            new_power       = new PlayerPower();
                XAttribute             power_name      = power.FirstAttribute;
                IEnumerable <XElement> power_specifics = power.Descendants("specific");
                IEnumerable <XElement> power_weapons   = power.Descendants("Weapon");
                new_power.name = power_name.Value;
                foreach (XElement specific in power_specifics)
                {
                    XAttribute power_info = specific.FirstAttribute;
                    switch (power_info.Value)
                    {
                    case "Flavor":
                        new_power.flavor = specific.Value;
                        break;

                    case "Power Usage":
                        switch (specific.Value)
                        {
                        case "At-Will":
                            new_power.power_usage = PlayerPower.power_usage_e.AT_WILL;
                            break;

                        case "Encounter":
                            new_power.power_usage = PlayerPower.power_usage_e.ENCOUNTER;
                            break;

                        case "Daily":
                            new_power.power_usage = PlayerPower.power_usage_e.DAILY;
                            break;

                        default:
                            break;
                        }
                        break;

                    case "Display":
                        new_power.display = specific.Value;
                        break;

                    case "Keywords":
                        new_power.keywords = specific.Value;
                        break;

                    case "Attack Type":
                        new_power.attack_type = specific.Value;
                        break;

                    case "Target":
                        new_power.target = specific.Value;
                        break;

                    case "Attack":
                        new_power.attack = specific.Value;
                        break;

                    case "Hit":
                        new_power.hit = specific.Value;
                        break;

                    case "Miss":
                        new_power.miss = specific.Value;
                        break;

                    case "Action Type":
                        switch (specific.Value)
                        {
                        case "Standard Action":
                            new_power.action_type = PlayerPower.action_type_e.STANDARD;
                            break;

                        case "Minor Action":
                            new_power.action_type = PlayerPower.action_type_e.MINOR;
                            break;

                        case "Move Action":
                            new_power.action_type = PlayerPower.action_type_e.MOVEMENT;
                            break;

                        default:
                            break;
                        }
                        break;

                    case "Effect":
                        new_power.effect = specific.Value;
                        break;

                    default:
                        break;
                    }
                    power_info.GetType();
                    specific.GetType();
                }
                foreach (XElement weapon in power_weapons)
                {
                    PowerWeapon new_weapon = new PowerWeapon();
                    if (weapon.FirstAttribute.Value == "Unarmed")
                    {
                        continue;
                    }
                    new_weapon.name         = weapon.FirstAttribute.Value;
                    new_weapon.attack_bonus = Convert.ToByte(weapon.Descendants("AttackBonus").First().Value);
                    new_weapon.crit_damage  = weapon.Descendants("CritDamage").First().Value;
                    new_weapon.damage       = weapon.Descendants("Damage").First().Value;
                    new_power.weapons.Add(new_weapon);
                }
                charData.player_powers.Add(new_power);
            }
        }
Beispiel #2
0
 /// <summary>
 /// For the given attribute, returns its type, i.e., the most high-level,
 /// typed interface this attribute implements.
 /// </summary>
 /// <returns>High-level type interface of this attribute.</returns>
 /// <param name="attribute">Attribute to analyze.</param>
 public static Type GetType(XAttribute attribute)
 {
     return(attribute.GetType());
 }