Пример #1
0
        public void loadChar(string path)
        {
            setBlankChar();
            classes.Clear();
            this.path = path;
            int bC;

            foreach (string line in File.ReadAllLines(path))
            {
                string[] sLine = line.Split('>');

                if (sLine.Length == 2)
                {
                    switch (sLine[0])
                    {
                    case "image":
                        tryLoadImage(sLine[1]);
                        break;

                    case "imageBC":
                        if (int.TryParse(sLine[1], out bC))
                        {
                            imageBackColor = Color.FromArgb(bC);
                        }
                        else
                        {
                            setRandBackColor();
                        }
                        break;

                    case "name":
                        name = sLine[1];
                        break;

                    case "subtitle":
                        subtitle = sLine[1];
                        break;

                    case "notes":
                        notes.Add(sLine[1]);
                        break;

                    case "race":
                        race = sLine[1];
                        break;

                    case "size":
                        size = sLine[1];
                        break;

                    case "gender":
                        gender = sLine[1];
                        break;

                    case "alignment":
                        alignment = sLine[1];
                        break;

                    case "color": {
                        if (int.TryParse(sLine[1], out bC))
                        {
                            charColor = Color.FromArgb(bC);
                        }
                        else
                        {
                            charColor = Color.ForestGreen;
                        }
                        break;
                    }

                    case "strength": {
                        strength.fromString(sLine[1]);
                        break;
                    }

                    case "dexterity": {
                        dexterity.fromString(sLine[1]);
                        break;
                    }

                    case "constitution": {
                        constitution.fromString(sLine[1]);
                        break;
                    }

                    case "intelligence": {
                        intelligence.fromString(sLine[1]);
                        break;
                    }

                    case "wisdom": {
                        wisdom.fromString(sLine[1]);
                        break;
                    }

                    case "charisma": {
                        charisma.fromString(sLine[1]);
                        break;
                    }

                    case "class": {
                        Klass k = new Klass();
                        k.fromString(sLine[1]);
                        classes.Add(k);
                        break;
                    }

                    case "skill": {
                        Skill s = new Skill();
                        s.fromString(sLine[1]);
                        skills.Add(s);
                        break;
                    }

                    case "level": {
                        if (!int.TryParse(sLine[1], out level))
                        {
                            level = 0;
                        }
                        break;
                    }

                    case "exp": {
                        if (!int.TryParse(sLine[1], out exp))
                        {
                            exp = 0;
                        }
                        break;
                    }

                    case "expToAdvance": {
                        if (!int.TryParse(sLine[1], out expToAdvance))
                        {
                            expToAdvance = 0;
                        }
                        break;
                    }

                    case "hp": {
                        if (!int.TryParse(sLine[1], out hp))
                        {
                            hp = 0;
                        }
                        break;
                    }

                    case "maxHP": {
                        if (!int.TryParse(sLine[1], out maxHP))
                        {
                            maxHP = 0;
                        }
                        break;
                    }

                    case "hpHidden": {
                        if (!bool.TryParse(sLine[1], out hpHidden))
                        {
                            hpHidden = false;
                        }
                        break;
                    }

                    case "fortitude": {
                        if (!int.TryParse(sLine[1], out fortitude))
                        {
                            fortitude = 0;
                        }
                        break;
                    }

                    case "reflex": {
                        if (!int.TryParse(sLine[1], out reflex))
                        {
                            reflex = 0;
                        }
                        break;
                    }

                    case "will": {
                        if (!int.TryParse(sLine[1], out will))
                        {
                            will = 0;
                        }
                        break;
                    }

                    case "bab": {
                        if (!int.TryParse(sLine[1], out bab))
                        {
                            bab = 0;
                        }
                        break;
                    }

                    case "melee": {
                        if (!int.TryParse(sLine[1], out melee))
                        {
                            melee = 0;
                        }
                        break;
                    }

                    case "ranged": {
                        if (!int.TryParse(sLine[1], out ranged))
                        {
                            ranged = 0;
                        }
                        break;
                    }

                    case "ac": {
                        if (!int.TryParse(sLine[1], out ac))
                        {
                            ac = 0;
                        }
                        break;
                    }

                    case "ff": {
                        if (!int.TryParse(sLine[1], out flatFooted))
                        {
                            flatFooted = 0;
                        }
                        break;
                    }

                    case "touch": {
                        if (!int.TryParse(sLine[1], out touch))
                        {
                            touch = 0;
                        }
                        break;
                    }

                    case "initiative": {
                        if (!int.TryParse(sLine[1], out initiative))
                        {
                            initiative = 0;
                        }
                        break;
                    }

                    case "speed": {
                        if (!int.TryParse(sLine[1], out speed))
                        {
                            speed = 0;
                        }
                        break;
                    }

                    case "item": {
                        Item i = new Item();
                        i.fromString(sLine[1]);
                        inv.Add(i);
                        break;
                    }

                    case "weapon": {
                        Weapon w = new Weapon();
                        w.fromString(sLine[1]);
                        weapons.Add(w);
                        break;
                    }

                    case "armor": {
                        Armor a = new Armor();
                        a.fromString(sLine[1]);
                        armor.Add(a);
                        break;
                    }

                    case "spell": {
                        Spell s = new Spell();
                        s.fromString(sLine[1]);
                        spellbook.Add(s);
                        break;
                    }

                    case "spellsLeft":
                        setSpellsLeft(sLine[1]);
                        break;
                    }
                }
            }

            setSkillMods();
        }