Esempio n. 1
0
        public void addSpell(string spellType)
        {
            switch (spellType)
            {
            case "Damage":
                Spell ds = new DamageSpell();
                spells.Add(ds);
                break;

            case "Utility":
                Spell us = new UtilitySpell();
                spells.Add(us);
                break;
            }
        }
Esempio n. 2
0
        public Character(string file)
        {
            abilities  = new Dictionary <string, Ability>();
            skills     = new Dictionary <string, Skill>();
            items      = new ObservableCollection <Item>();
            spells     = new ObservableCollection <Spell>();
            pObservers = new List <ProficiencyObserver>();
            initializeAbilities();
            initializeSkills();

            using (StreamReader reader = new StreamReader(file))
            {
                name         = reader.ReadLine();
                charClass    = reader.ReadLine();
                race         = reader.ReadLine();
                alignment    = reader.ReadLine();
                level        = Convert.ToInt16(reader.ReadLine());
                speed        = Convert.ToInt16(reader.ReadLine());
                armorClass   = Convert.ToInt16(reader.ReadLine());
                currentHP    = Convert.ToInt16(reader.ReadLine());
                maxHP        = Convert.ToInt16(reader.ReadLine());
                playerAvatar = (Directory.GetCurrentDirectory().Substring(0, Directory.GetCurrentDirectory().Length - 10)) + reader.ReadLine();
                featInfo     = "";
                reader.ReadLine();
                string line = reader.ReadLine();
                while (line != "END FEAT INFO")
                {
                    featInfo += line + "\n";
                    line      = reader.ReadLine();
                }

                foreach (KeyValuePair <string, Ability> a in abilities)
                {
                    string[] ability = reader.ReadLine().Split(':');
                    abilities[ability[0]].setScore(Convert.ToInt16(ability[1]));
                }
                foreach (KeyValuePair <string, Skill> s in skills)
                {
                    string[] skill = reader.ReadLine().Split(':');
                    skills[skill[0]].setProficiency(Convert.ToBoolean(skill[1]));
                }
                //Read the number of items, and then load each item based on its type.
                int itemCount = Convert.ToInt16(reader.ReadLine());
                for (int i = 0; i < itemCount; i++)
                {
                    string type = reader.ReadLine();
                    if (type == "Weapon")
                    {
                        string   iName        = reader.ReadLine();
                        string   iInfo        = reader.ReadLine();
                        int      iWeight      = Convert.ToInt16(reader.ReadLine());
                        string   iAbility     = reader.ReadLine();
                        string   iDamageType  = reader.ReadLine();
                        string[] dmg          = reader.ReadLine().Split('d');
                        int      iNumDice     = Convert.ToInt16(dmg[0]);
                        int      iDmgDice     = Convert.ToInt16(dmg[1]);
                        int      iRange       = Convert.ToInt16(reader.ReadLine());
                        bool     iProf        = Convert.ToBoolean(reader.ReadLine());
                        string   iWeaponImage = reader.ReadLine();
                        Weapon   w            = new Weapon(iName, iInfo, iWeight, iAbility, iDamageType, iNumDice, iDmgDice, iRange, iProf, iWeaponImage);
                        items.Add(w);
                    }
                    else if (type == "Armor")
                    {
                        string iName       = reader.ReadLine();
                        string iInfo       = reader.ReadLine();
                        int    iWeight     = Convert.ToInt16(reader.ReadLine());
                        int    iAC         = Convert.ToInt16(reader.ReadLine());
                        bool   iEquipped   = Convert.ToBoolean(reader.ReadLine());
                        string iArmorImage = reader.ReadLine();

                        Armor a = new Armor(iName, iInfo, iWeight, iAC, iEquipped, iArmorImage);
                        items.Add(a);
                    }
                    else if (type == "Misc")
                    {
                        string iName   = reader.ReadLine();
                        string iInfo   = reader.ReadLine();
                        int    iWeight = Convert.ToInt16(reader.ReadLine());

                        Misc m = new Misc(iName, iInfo, iWeight);
                        items.Add(m);
                    }
                }
                int spellCount = Convert.ToInt16(reader.ReadLine());
                for (int i = 0; i < spellCount; i++)
                {
                    string type = reader.ReadLine();
                    if (type == "Damage")
                    {
                        string sName       = reader.ReadLine();
                        string sLevel      = reader.ReadLine();
                        string sCastTime   = reader.ReadLine();
                        string sDuration   = reader.ReadLine();
                        string sRange      = reader.ReadLine();
                        string sSchool     = reader.ReadLine();
                        string sComps      = reader.ReadLine();
                        string sInfo       = reader.ReadLine();
                        string sSave       = reader.ReadLine();
                        string sDamage     = reader.ReadLine();
                        string sDamageType = reader.ReadLine();
                        Spell  s           = new DamageSpell(sName, sLevel, sCastTime, sDuration, sRange, sSchool, sComps, sInfo, sSave, sDamage, sDamageType);
                        spells.Add(s);
                    }
                    else if (type == "Utility")
                    {
                        string sName     = reader.ReadLine();
                        string sLevel    = reader.ReadLine();
                        string sCastTime = reader.ReadLine();
                        string sDuration = reader.ReadLine();
                        string sRange    = reader.ReadLine();
                        string sSchool   = reader.ReadLine();
                        string sComps    = reader.ReadLine();
                        string sInfo     = reader.ReadLine();
                        string sSave     = reader.ReadLine();
                        Spell  s         = new UtilitySpell(sName, sLevel, sCastTime, sDuration, sRange, sSchool, sComps, sInfo, sSave);
                        spells.Add(s);
                    }
                }
            }

            updatePerception();
        }