示例#1
0
        public PlayerCharacter(Game game, int id, string n, int[] hpsp, int[] s, int[] g, string gra, Gender gen, Arcana a)
        {
            Name               = n;
            ID                 = id;
            StatGain           = g;
            Inventory.Capacity = 16;
            Spells.Capacity    = 8;
            //stats
            BattleStats = new BattleStats(null);
            BattleStats.baseAttributes.Add(Magicians.Attributes.Strength, s[0]);
            BattleStats.baseAttributes.Add(Magicians.Attributes.Magic, s[1]);
            BattleStats.baseAttributes.Add(Magicians.Attributes.Dexterity, s[2]);


            BattleStats.MaxHP = hpsp[0];
            BattleStats.HP    = BattleStats.MaxHP;
            BattleStats.MaxSP = hpsp[1];
            BattleStats.SP    = BattleStats.MaxSP;
            this.Arcana       = a;

            foreach (KeyValuePair <Attributes, int> kvp in BattleStats.baseAttributes)
            {
                BattleStats.Attributes.Add(kvp.Key, kvp.Value);
            }
            BattleStats.baseResistances.Add(DamageTypes.Physical, 0);
            BattleStats.baseResistances.Add(DamageTypes.Fire, 0);
            BattleStats.baseResistances.Add(DamageTypes.Cold, 0);
            BattleStats.baseResistances.Add(DamageTypes.Electricity, 0);
            BattleStats.baseResistances.Add(DamageTypes.Poison, 0);
            BattleStats.baseResistances.Add(DamageTypes.Raw, 0);
            BattleStats.baseResistances.Add(DamageTypes.Light, 100);

            foreach (KeyValuePair <DamageTypes, int> kvp in BattleStats.baseResistances)
            {
                BattleStats.Resistances.Add(kvp.Key, kvp.Value);
            }

            for (int i = 0; i < Equips.Length; i++)
            {
                Equips[i] = null;
            }
            GraphicsFolderName = gra;
            Gender             = gen;
            Level = 1;
            GetLevelUps(game);
        }
示例#2
0
        public static bool GetDodgeChance(Battle battle, BattleStats attacker, BattleStats target)
        {
            if (!target.canAct)
            {
                return(false);
            }
            float bonus = 0;

            if (attacker.Attributes[Attributes.Dexterity] < target.Attributes[Attributes.Dexterity])
            {
                bonus = (target.Attributes[Attributes.Dexterity] - attacker.Attributes[Attributes.Dexterity]) / 4f;
            }
            if (battle.Random.Next(0, 100) <= MathHelper.Clamp(target.DodgeChance + attacker.MissRate + bonus, -99, 99))
            {
                return(true);
            }
            return(false);
        }
示例#3
0
 public Battler(PlayerCharacter pc, string n, string gra, BattleStats bs)
 {
     Name = n;
     battlerGraphicsFolder = gra;
     BattleStats           = bs;
     Sounds = new SortedList <BattlerAnimType, string>();
     Sounds.Add(BattlerAnimType.Recoil, "");
     Sounds.Add(BattlerAnimType.Dead, "");
     if (pc.Gender == Gender.Male)
     {
         Sounds[BattlerAnimType.Recoil] = "MalePain1|MalePain2|MalePain3|MalePain4|MalePain5";
         Sounds[BattlerAnimType.Die]    = "MaleDeath";
     }
     if (pc.Gender == Gender.Female)
     {
         Sounds[BattlerAnimType.Recoil] = "FemalePain1|FemalePain2|FemalePain3|FemalePain4|FemalePain5";
         Sounds[BattlerAnimType.Die]    = "FemaleDeath";
     }
 }
示例#4
0
 public Battler(string n, string gra, int hp, int sp, SortedList <DamageTypes, int> r, SortedList <Attributes, int> s)
 {
     Name = n;
     battlerGraphicsFolder       = gra;
     BattleStats                 = new BattleStats(this);
     BattleStats.MaxHP           = hp;
     BattleStats.MaxSP           = sp;
     BattleStats.HP              = BattleStats.MaxHP;
     BattleStats.SP              = BattleStats.MaxSP;
     BattleStats.baseResistances = r;
     BattleStats.baseAttributes  = s;
     foreach (KeyValuePair <Attributes, int> kvp in BattleStats.baseAttributes)
     {
         BattleStats.Attributes.Add(kvp.Key, kvp.Value);
     }
     foreach (KeyValuePair <DamageTypes, int> kvp in BattleStats.baseResistances)
     {
         BattleStats.Resistances.Add(kvp.Key, kvp.Value);
     }
 }
示例#5
0
 public static LuckResult GetLuckResult(Battle battle, BattleStats caller)
 {
     if (caller.Luck > 0)
     {
         int luckBase = 100 - (20 * caller.Luck);
         if (battle.Random.Next(0, 100) < luckBase)
         {
             return(LuckResult.Positive);
         }
         return(LuckResult.Neutral);
     }
     if (caller.Luck < 0)
     {
         int luckBase = 100 - (20 * caller.Luck);
         if (battle.Random.Next(0, 100) < luckBase)
         {
             return(LuckResult.Negative);
         }
         return(LuckResult.Neutral);
     }
     return(LuckResult.Neutral);
 }
示例#6
0
        public Battler(Game g, string name)
        {
            var      mod  = new Modifier();
            var      data = XDocument.Load(g.Content.RootDirectory + g.PathSeperator + "Data" + g.PathSeperator + "Battlers.xml", LoadOptions.None);
            XElement el   = null;

            foreach (XElement elem in data.Descendants("Battler"))
            {
                if (elem.Attribute("internal").Value == name)
                {
                    el = elem;
                    break;
                }
            }
            this.Name                  = g.LoadString("Battlers", el.Attribute("internal").Value);
            this.internalName          = (string)el.Attribute("internal");
            this.battlerGraphicsFolder = (string)el.Attribute("battlegraphics");
            this.worldGraphicsFolder   = (string)el.Attribute("worldgraphics");
            useBossHealthBar           = bool.Parse(el.Attribute("boss").Value);
            displayStats               = !bool.Parse(el.Attribute("boss").Value);
            exp        = int.Parse(el.Attribute("exp").Value);
            gold       = int.Parse(el.Attribute("gold").Value);
            dropchance = int.Parse(el.Attribute("chance").Value);
            itemDrop   = el.Attribute("item").Value;
            twoTurns   = false;
            if (el.Attribute("twoturns") != null)
            {
                twoTurns = true;
            }
            if (el.Attribute("inorder") != null)
            {
                inOrder = true;
            }
            if (el.Attribute("behaviour") != null)
            {
                var args = el.Attribute("behaviour").Value.Split(',');
                for (int i = 0; i < args.Length; i++)
                {
                    switch (args[i])
                    {
                    case ("avoidlight"):
                    {
                        AddBehaviour(Behaviours.FreezeOnLight);
                        break;
                    }

                    case ("flying"):
                    {
                        AddBehaviour(Behaviours.Flying);
                        break;
                    }

                    case ("interactwithent"):
                    {
                        AddBehaviour(Behaviours.InteractWithEntity);
                        break;
                    }

                    case ("sentry"):
                    {
                        AddBehaviour(Behaviours.Sentry);
                        break;
                    }

                    case ("blind"):
                    {
                        AddBehaviour(Behaviours.Blind);
                        break;
                    }

                    case ("wanders"):
                    {
                        AddBehaviour(Behaviours.Wanders);
                        break;
                    }
                    }
                }
            }

            if (el.Element("Sprite") != null)
            {
                Width    = (int)el.Attribute("width");
                Height   = (int)el.Attribute("height");
                Duration = (float)el.Attribute("interval");
            }
            if (el.Element("Sounds") != null)
            {
                if (el.Element("Sounds").Attribute("attack") != null)
                {
                    Sounds.Add(BattlerAnimType.Attack, el.Element("Sounds").Attribute("attack").Value);
                }
                if (el.Element("Sounds").Attribute("die") != null)
                {
                    Sounds.Add(BattlerAnimType.Die, el.Element("Sounds").Attribute("die").Value);
                }
                if (el.Element("Sounds").Attribute("recoil") != null)
                {
                    Sounds.Add(BattlerAnimType.Recoil, el.Element("Sounds").Attribute("recoil").Value);
                }
                if (el.Element("Sounds").Attribute("spell") != null)
                {
                    Sounds.Add(BattlerAnimType.CastSpell, el.Element("Sounds").Attribute("spell").Value);
                }
            }
            if (el.Element("ScaleFromPlayer") != null)
            {
                BattleStats = new BattleStats(this);
                var playerID = int.Parse(el.Element("ScaleFromPlayer").Attribute("id").Value);
                var pc       = g.party.GetPlayerCharacter(playerID);
                BattleStats.MaxHP   += pc.BattleStats.MaxHP;
                BattleStats.HP      += pc.BattleStats.MaxHP;
                BattleStats.MaxSP   += pc.BattleStats.MaxSP;
                BattleStats.SP      += pc.BattleStats.MaxSP;
                BattleStats.baseLuck = pc.BattleStats.baseLuck;
                if (BattleStats.baseAttributes.Count == 0)
                {
                    BattleStats.baseAttributes.Add(Attributes.Strength, 0);
                    BattleStats.baseAttributes.Add(Attributes.Magic, 0);
                    BattleStats.baseAttributes.Add(Attributes.Dexterity, 0);
                }
                BattleStats.baseAttributes[Attributes.Strength]  += pc.BattleStats.Attributes[Attributes.Strength];
                BattleStats.baseAttributes[Attributes.Magic]     += pc.BattleStats.Attributes[Attributes.Magic];
                BattleStats.baseAttributes[Attributes.Dexterity] += pc.BattleStats.Attributes[Attributes.Dexterity];
                BattleStats.baseArmour += pc.BattleStats.Armour;
                BattleStats.baseLuck   += pc.BattleStats.Luck;
                BattleStats.baseResistances.Add(DamageTypes.Physical, pc.BattleStats.Resistances[DamageTypes.Physical]);
                BattleStats.baseResistances.Add(DamageTypes.Fire, pc.BattleStats.Resistances[DamageTypes.Fire]);
                BattleStats.baseResistances.Add(DamageTypes.Electricity, pc.BattleStats.Resistances[DamageTypes.Electricity]);
                BattleStats.baseResistances.Add(DamageTypes.Cold, pc.BattleStats.Resistances[DamageTypes.Cold]);
                BattleStats.baseResistances.Add(DamageTypes.Light, pc.BattleStats.Resistances[DamageTypes.Light]);
                BattleStats.baseResistances.Add(DamageTypes.Poison, pc.BattleStats.Resistances[DamageTypes.Poison]);
            }
            if (el.Element("World") != null)
            {
                if (el.Element("World").Attribute("speed") != null)
                {
                    worldMovementSpeed = int.Parse(el.Element("World").Attribute("speed").Value);
                }
            }
            else
            {
                worldMovementSpeed = 4;
            }

            if (BattleStats == null)
            {
                BattleStats = new BattleStats(this);
            }
            BattleStats.MaxHP += int.Parse(el.Element("Stats").Attribute("health").Value);
            BattleStats.HP    += int.Parse(el.Element("Stats").Attribute("health").Value);
            BattleStats.MaxSP += int.Parse(el.Element("Stats").Attribute("mana").Value);
            BattleStats.SP    += int.Parse(el.Element("Stats").Attribute("mana").Value);
            if (BattleStats.baseAttributes.Count == 0)
            {
                BattleStats.baseAttributes.Add(Attributes.Strength, 0);
                BattleStats.baseAttributes.Add(Attributes.Magic, 0);
                BattleStats.baseAttributes.Add(Attributes.Dexterity, 0);
            }
            BattleStats.baseAttributes[Attributes.Strength]  += int.Parse(el.Element("Stats").Attribute("strength").Value);
            BattleStats.baseAttributes[Attributes.Magic]     += int.Parse(el.Element("Stats").Attribute("magic").Value);
            BattleStats.baseAttributes[Attributes.Dexterity] += int.Parse(el.Element("Stats").Attribute("agility").Value);
            BattleStats.baseArmour += int.Parse(el.Element("Stats").Attribute("armour").Value);
            BattleStats.baseLuck   += int.Parse(el.Element("Stats").Attribute("luck").Value);
            if (BattleStats.baseResistances.Count == 0)
            {
                BattleStats.baseResistances.Add(DamageTypes.Physical, int.Parse(el.Element("Resistances").Attribute("phys").Value));
                BattleStats.baseResistances.Add(DamageTypes.Fire, int.Parse(el.Element("Resistances").Attribute("fire").Value));
                BattleStats.baseResistances.Add(DamageTypes.Electricity, int.Parse(el.Element("Resistances").Attribute("elec").Value));
                BattleStats.baseResistances.Add(DamageTypes.Cold, int.Parse(el.Element("Resistances").Attribute("cold").Value));
                BattleStats.baseResistances.Add(DamageTypes.Light, int.Parse(el.Element("Resistances").Attribute("light").Value));
                BattleStats.baseResistances.Add(DamageTypes.Poison, int.Parse(el.Element("Resistances").Attribute("poison").Value));
                if (el.Element("Resistances").Attribute("raw") != null)
                {
                    BattleStats.baseResistances.Add(DamageTypes.Raw, int.Parse(el.Element("Resistances").Attribute("raw").Value));
                }
                else
                {
                    BattleStats.baseResistances.Add(DamageTypes.Raw, 0);
                }
            }
            if (el.Element("Invulns") != null)
            {
                BattleStats.modInvulnerabilities = el.Element("Invulns").Value.Split(',');
            }
            if (el.Element("Vulns") != null)
            {
                BattleStats.modVulnerabilities = el.Element("Vulns").Value.Split(',');
            }

            battleActions = new List <BattleAction>();
            var actions = el.Element("Actions").Value.Split(',');

            if (actions[0] == "copy_from_player")
            {
                for (int i = 0; i < g.party.PlayerCharacters[0].Spells.Count; i++)
                {
                    if (g.party.PlayerCharacters[0].Spells[i].Usage == Usage.Battle || g.party.PlayerCharacters[0].Spells[i].Usage == Usage.BothSame)
                    {
                        if (g.party.PlayerCharacters[0].Spells[i].BattleAction.tag != "")
                        {
                            battleActions.Add(g.party.PlayerCharacters[0].Spells[i].BattleAction);
                        }
                    }
                }
                for (int i = 0; i < g.party.PlayerCharacters[0].Inventory.Count; i++)
                {
                    if (g.party.PlayerCharacters[0].Inventory[i].Usage == Usage.Battle || g.party.PlayerCharacters[0].Inventory[i].Usage == Usage.BothSame)
                    {
                        if (g.party.PlayerCharacters[0].Inventory[i] is ConsumableItem)
                        {
                            var consum = (ConsumableItem)g.party.PlayerCharacters[0].Inventory[i];
                            if (consum.BattleAction.tag != "")
                            {
                                if (!battleActions.Contains(consum.BattleAction))
                                {
                                    battleActions.Add(consum.BattleAction);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                for (int i = 0; i < actions.Length; i++)
                {
                    try { battleActions.Add(g.battleActions.Find(b => b.Name == actions[i])); }
                    catch { Console.WriteLine("PANIC: BATTLER " + internalName + " IS SET TO HAVE ACTION " + actions[i] + " BUT THE ACTION WAS NOT FOUND"); }
                }
            }
            if (el.Element("DefaultAction") != null)
            {
                try { defaultAction = g.battleActions.Find(b => b.Name == el.Element("DefaultAction").Value); }
                catch { Console.WriteLine("PANIC: BATTLER " + internalName + " IS SET TO HAVE DEFAULT ACTION " + el.Element("DefaultAction").Value + " BUT THE ACTION WAS NOT FOUND"); }
            }
            if (el.Element("DeathAction") != null)
            {
                try { deathAction = g.battleActions.Find(b => b.Name == el.Element("DeathAction").Value); }
                catch { Console.WriteLine("PANIC: BATTLER " + internalName + " IS SET TO HAVE DEATH ACTION " + el.Element("DeathAction").Value + " BUT THE ACTION WAS NOT FOUND"); }
            }
            if (el.Attribute("behaviour").Value == "flying")
            {
                BattleStats.Modifiers.Add(g.modifiers.Find(m => m.Name == "mod_flying"));
            }
            if (el.Element("Modifiers") != null)
            {
                var args = el.Element("Modifiers").Value.Split(',');
                foreach (string arg in args)
                {
                    var modi = g.modifiers.Find(m => m.Name == arg);
                    if (modi != null)
                    {
                        BattleStats.Modifiers.Add(modi);
                    }
                }
            }
            if (el.Attribute("tags") != null)
            {
                var args = el.Attribute("tags").Value.Split(',');
                for (int i = 0; i < args.Length; i++)
                {
                    switch (args[i])
                    {
                    case ("flying"): BattleStats.tags.Add(BattlerTags.Flying); break;

                    case ("organic"): BattleStats.tags.Add(BattlerTags.Organic); break;

                    case ("machine"): BattleStats.tags.Add(BattlerTags.Mechanic); break;

                    case ("plant"): BattleStats.tags.Add(BattlerTags.Plant); break;

                    case ("magical"): BattleStats.tags.Add(BattlerTags.Magical); break;

                    default: Console.WriteLine("PANIC: ATTEMPTED TO ADD BATTLER TAG:" + args[i] + "TO " + internalName + ", BUT BATTLER TAG DOES NOT EXIST"); break;
                    }
                }
            }
        }
示例#7
0
        public PlayerCharacter(Game game, CharacterSave charsave)
        {
            ID                = charsave.ID;
            BattleStats       = new BattleStats(null);
            Name              = charsave.Name;
            BattleStats.HP    = charsave.HpSp[0];
            BattleStats.MaxHP = charsave.HpSp[1];
            BattleStats.SP    = charsave.HpSp[2];
            BattleStats.MaxSP = charsave.HpSp[3];
            BattleStats.baseAttributes.Add(Magicians.Attributes.Strength, charsave.Stats[0]);
            BattleStats.baseAttributes.Add(Magicians.Attributes.Magic, charsave.Stats[1]);
            BattleStats.baseAttributes.Add(Magicians.Attributes.Dexterity, charsave.Stats[2]);
            StatGain           = charsave.StatGain.ToArray();
            Inventory.Capacity = 16;
            Spells.Capacity    = 8;
            foreach (KeyValuePair <Attributes, int> kvp in BattleStats.baseAttributes)
            {
                BattleStats.Attributes.Add(kvp.Key, kvp.Value);
            }
            BattleStats.baseResistances.Add(DamageTypes.Physical, 0);
            BattleStats.baseResistances.Add(DamageTypes.Fire, 0);
            BattleStats.baseResistances.Add(DamageTypes.Cold, 0);
            BattleStats.baseResistances.Add(DamageTypes.Electricity, 0);
            BattleStats.baseResistances.Add(DamageTypes.Poison, 0);
            BattleStats.baseResistances.Add(DamageTypes.Raw, 0);
            BattleStats.baseResistances.Add(DamageTypes.Light, 100);

            foreach (KeyValuePair <DamageTypes, int> kvp in BattleStats.baseResistances)
            {
                BattleStats.Resistances.Add(kvp.Key, kvp.Value);
            }
            this.Arcana = charsave.Arcana;
            for (int i = 0; i < charsave.Inventory.Count; i++)
            {
                Inventory.Add(game.Items.Find(p => p.InternalName == charsave.Inventory[i]));
            }
            for (int i = 0; i < charsave.Equips.Length; i++)
            {
                for (int e = 0; e < Inventory.Count; e++)
                {
                    if (Inventory[e].InternalName == charsave.Equips[i])
                    {
                        EquipItem(e);
                    }
                }
            }
            for (int i = 0; i < charsave.Spells.Count; i++)
            {
                for (int x = 0; x < game.Spells.Count; x++)
                {
                    if (game.Spells[x].InternalName == charsave.Spells[i])
                    {
                        LearnSpell(game.Spells[x]);
                        break;
                    }
                }
            }

            Level        = charsave.Level;
            Exp          = charsave.Exp;
            TotalExp     = charsave.TotalExp;
            NextLevelExp = charsave.NextLevelExp;
            BattleStats.RecalculateStats();
            GraphicsFolderName = charsave.SpriteFolder;
            Gender             = charsave.Gender;
            if (Spells.Count > 8)
            {
                Spells.RemoveRange(8, Spells.Count - 8);
            }
            Spells.Capacity = 8;
            GetLevelUps(game);

            LearnableSpellLevels = charsave.LearnLevels;
            if (charsave.LearnSpells != null)
            {
                foreach (string s in charsave.LearnSpells)
                {
                    var spell = game.Spells.Find(spl => spl.InternalName == s);
                    if (spell != null)
                    {
                        LearnableSpells.Add(spell);
                    }
                }
            }
        }
示例#8
0
        //creating characters from an XML element
        public PlayerCharacter(Game game, XElement element)
        {
            ID   = int.Parse(element.Attribute("id").Value);
            Name = element.Attribute("name").Value;
            GraphicsFolderName = element.Attribute("spriteDir").Value;
            Level        = int.Parse(element.Attribute("level").Value);
            Exp          = int.Parse(element.Attribute("exp").Value);
            NextLevelExp = int.Parse(element.Attribute("nextExp").Value);
            TotalExp     = uint.Parse(element.Attribute("totalExp").Value);
            switch (element.Attribute("gender").Value)
            {
            case "Male": Gender = Gender.Male; break;

            case "Female": Gender = Gender.Female; break;
            }
            switch (element.Attribute("arcana").Value)
            {
            case "Light": Arcana = Arcana.Light; break;

            case "Shadow": Arcana = Arcana.Shadow; break;

            case "Fire": Arcana = Arcana.Fire; break;

            case "Water": Arcana = Arcana.Water; break;

            case "Earth": Arcana = Arcana.Earth; break;

            case "Wind": Arcana = Arcana.Wind; break;
            }
            Inventory.Capacity     = 16;
            Spells.Capacity        = 8;
            BattleStats            = new BattleStats(null);
            BattleStats.MaxHP      = int.Parse(element.Attribute("maxHP").Value);
            BattleStats.MaxSP      = int.Parse(element.Attribute("maxSP").Value);
            BattleStats.HP         = int.Parse(element.Attribute("hp").Value);
            BattleStats.SP         = int.Parse(element.Attribute("sp").Value);
            BattleStats.baseArmour = int.Parse(element.Attribute("armour").Value);
            var statEls = element.Element("Stats").Descendants("Stat").ToArray <XElement>();

            BattleStats.baseAttributes.Add(Magicians.Attributes.Strength, int.Parse(statEls[0].Value));
            BattleStats.baseAttributes.Add(Magicians.Attributes.Magic, int.Parse(statEls[1].Value));
            BattleStats.baseAttributes.Add(Magicians.Attributes.Dexterity, int.Parse(statEls[2].Value));
            foreach (KeyValuePair <Attributes, int> kvp in BattleStats.baseAttributes)
            {
                BattleStats.Attributes.Add(kvp.Key, kvp.Value);
            }
            var statGns = element.Element("Gains").Descendants("Gain").ToArray <XElement>();
            var gns     = new List <int>();

            gns.Add(int.Parse(statGns[0].Value));
            gns.Add(int.Parse(statGns[1].Value));
            gns.Add(int.Parse(statGns[2].Value));
            StatGain[0] = gns[0];
            StatGain[1] = gns[1];
            StatGain[2] = gns[2];
            BattleStats.baseResistances.Add(DamageTypes.Physical, 0);
            BattleStats.baseResistances.Add(DamageTypes.Fire, 0);
            BattleStats.baseResistances.Add(DamageTypes.Cold, 0);
            BattleStats.baseResistances.Add(DamageTypes.Electricity, 0);
            BattleStats.baseResistances.Add(DamageTypes.Poison, 0);
            BattleStats.baseResistances.Add(DamageTypes.Raw, 0);
            BattleStats.baseResistances.Add(DamageTypes.Light, 100);
            foreach (KeyValuePair <DamageTypes, int> kvp in BattleStats.baseResistances)
            {
                BattleStats.Resistances.Add(kvp.Key, kvp.Value);
            }
            var items = element.Element("Items").Descendants("Item").ToList();

            for (int i = 0; i < items.Count; i++)
            {
                Inventory.Add(game.Items.Find(p => p.InternalName == items[i].Value));
            }
            var spells = element.Element("Spells").Descendants("Spell").ToList();

            for (int i = 0; i < spells.Count; i++)
            {
                Spells.Add(game.Spells.Find(p => p.InternalName == spells[i].Value));
            }
            Equips = new EquippableItem[4];
            var equipEls = element.Element("Equips").Descendants("Equip").ToArray();

            for (int i = 0; i < equipEls.Length; i++)
            {
                for (int e = 0; e < Inventory.Count; e++)
                {
                    if (Inventory[e].InternalName == equipEls[i].Value)
                    {
                        EquipItem(e);
                    }
                }
            }
            var learnSpells = element.Element("LearnSpells").Descendants("LevelSpell").ToArray();

            for (int i = 0; i < learnSpells.Length; i++)
            {
                var args = learnSpells[i].Value.Split('|');
                LearnableSpellLevels.Add(int.Parse(args[0]));
                LearnableSpells.Add(game.Spells.Find(p => p.InternalName == args[1]));
            }
        }