예제 #1
0
        public static IWarrior FromXml(this IWarbandRoster warbandRoster, XmlWarrior xmlWarrior)
        {
            IWarrior warrior = warbandRoster.WarBand.GetWarrior(xmlWarrior.TypeOfWarrior);

            warrior = warbandRoster.AddWarrior(warrior);
            foreach (string item in xmlWarrior.EquipmentList)
            {
                warrior.AddEquipment(item);
            }
            if (warrior is IHenchMen)
            {
                IHenchMen henchMan = warrior as IHenchMen;

                for (int i = 1; i < xmlWarrior.AmountInGroup; i++)
                {
                    henchMan.IncreaseGroupByOne();
                }
            }
            else if (warrior is IHero)
            {
                IHero hero = warrior as IHero;

                foreach (string skill in xmlWarrior.SkillList)
                {
                    hero.AddSkill(skill);
                }
            }
            if (warrior is IWizard)
            {
                IWizard wizard = warrior as IWizard;

                foreach (string item in xmlWarrior.SpellList)
                {
                    wizard.AddSpell(item);
                }
            }

            return(warrior);
        }