Esempio n. 1
0
        public DataSet GenerateSkillTable()
        {
            Wz_Node skillWz = PluginManager.FindWz(Wz_Type.Skill);

            if (skillWz == null)
            {
                return(null);
            }

            Regex r = new Regex(@"^(\d+)\.img", RegexOptions.Compiled);

            DataSet   ds       = new DataSet();
            DataTable jobTable = new DataTable("ms_job");

            jobTable.Columns.Add("jobID", typeof(string));
            jobTable.Columns.Add("jobName", typeof(string));

            DataTable skillTable = new DataTable("ms_skill");

            skillTable.Columns.Add("jobID", typeof(string));
            skillTable.Columns.Add("skillID", typeof(string));
            skillTable.Columns.Add("skillName", typeof(string));
            skillTable.Columns.Add("skillDesc", typeof(string));
            skillTable.Columns.Add("maxLevel", typeof(int));
            skillTable.Columns.Add("invisible", typeof(bool));
            skillTable.Columns.Add("hyper", typeof(int));
            skillTable.Columns.Add("reqSkill", typeof(string));
            skillTable.Columns.Add("reqSkillLevel", typeof(int));
            skillTable.Columns.Add("reqLevel", typeof(int));

            DataTable skillLevelTable = new DataTable("ms_skillLevel");

            skillLevelTable.Columns.Add("skillID", typeof(string));
            skillLevelTable.Columns.Add("level", typeof(int));
            skillLevelTable.Columns.Add("levelDesc", typeof(string));

            DataTable skillCommonTable = new DataTable("ms_skillCommon");

            skillCommonTable.Columns.Add("skillID", typeof(string));
            skillCommonTable.Columns.Add("commonName", typeof(string));
            skillCommonTable.Columns.Add("commonValue", typeof(string));

            DataTable skillPVPCommonTable = new DataTable("ms_skillPVPCommon");

            skillPVPCommonTable.Columns.Add("skillID", typeof(string));
            skillPVPCommonTable.Columns.Add("commonName", typeof(string));
            skillPVPCommonTable.Columns.Add("commonValue", typeof(string));

            DataTable skillHTable = new DataTable("ms_skillH");

            skillHTable.Columns.Add("skillID", typeof(string));
            skillHTable.Columns.Add("desc", typeof(string));
            skillHTable.Columns.Add("pdesc", typeof(string));
            skillHTable.Columns.Add("h", typeof(string));
            skillHTable.Columns.Add("ph", typeof(string));
            skillHTable.Columns.Add("hch", typeof(string));

            StringResult sr;

            foreach (Wz_Node node in skillWz.Nodes)
            {
                //获取职业
                Match    m   = r.Match(node.Text);
                Wz_Image img = node.GetValue <Wz_Image>(null);
                if (!m.Success)
                {
                    continue;
                }
                if (img == null || !img.TryExtract())
                {
                    continue;
                }
                //导入职业
                string jobID = m.Result("$1");
                sl.StringSkill2.TryGetValue(jobID, out sr);
                jobTable.Rows.Add(jobID, (sr != null ? sr["bookName"] : null));

                //获取技能
                Wz_Node skillListNode = img.Node.FindNodeByPath("skill");
                if (skillListNode == null || skillListNode.Nodes.Count <= 0)
                {
                    continue;
                }

                foreach (Wz_Node skillNode in skillListNode.Nodes)
                {
                    Skill skill = Skill.CreateFromNode(skillNode, PluginManager.FindWz);
                    if (skill == null)
                    {
                        continue;
                    }

                    // if (skill.Invisible) //过滤不可见技能
                    //     continue;

                    //导入技能
                    string skillID = skillNode.Text;
                    sl.StringSkill2.TryGetValue(skillID, out sr);

                    string reqSkill      = null;
                    int    reqSkillLevel = 0;
                    if (skill.ReqSkill.Count > 0)
                    {
                        foreach (var kv in skill.ReqSkill)
                        {
                            reqSkill      = kv.Key.ToString();
                            reqSkillLevel = kv.Value;
                        }
                    }

                    skillTable.Rows.Add(
                        jobID,
                        skillID,
                        sr != null ? sr.Name : null,
                        sr != null ? sr.Desc : null,
                        skill.MaxLevel,
                        skill.Invisible,
                        skill.Hyper,
                        reqSkill,
                        reqSkillLevel,
                        skill.ReqLevel
                        );


                    if (!skill.PreBBSkill)
                    {
                        //导入技能common
                        foreach (var kv in skill.Common)
                        {
                            skillCommonTable.Rows.Add(
                                skillID,
                                kv.Key,
                                kv.Value
                                );
                        }
                        foreach (var kv in skill.PVPcommon)
                        {
                            skillPVPCommonTable.Rows.Add(
                                skillID,
                                kv.Key,
                                kv.Value
                                );
                        }
                        //导入技能说明
                        skillHTable.Rows.Add(
                            skillID,
                            sr != null ? sr["desc"] : null,
                            sr != null ? sr["pdesc"] : null,
                            sr != null ? sr["h"] : null,
                            sr != null ? sr["ph"] : null,
                            sr != null ? sr["hch"] : null
                            );
                    }

                    //导入技能等级
                    for (int i = 1, j = skill.MaxLevel + (skill.CombatOrders ? 2 : 0); i <= j; i++)
                    {
                        skill.Level = i;
                        string levelDesc = SummaryParser.GetSkillSummary(skill, sr, SummaryParams.Default);
                        skillLevelTable.Rows.Add(
                            skillID,
                            i,
                            levelDesc);
                    }
                }

                img.Unextract();
            }

            ds.Tables.Add(jobTable);
            ds.Tables.Add(skillTable);
            ds.Tables.Add(skillLevelTable);
            ds.Tables.Add(skillCommonTable);
            ds.Tables.Add(skillPVPCommonTable);
            ds.Tables.Add(skillHTable);
            return(ds);
        }
Esempio n. 2
0
        public bool Load(Wz_File stringWz)
        {
            if (stringWz == null || stringWz.Node == null)
            {
                return(false);
            }
            this.Clear();
            int id;

            foreach (Wz_Node node in stringWz.Node.Nodes)
            {
                Wz_Image image = node.Value as Wz_Image;
                if (image == null)
                {
                    continue;
                }
                switch (node.Text)
                {
                case "Pet.img":
                case "Cash.img":
                case "Ins.img":
                case "Consume.img":
                    if (!image.TryExtract())
                    {
                        break;
                    }
                    foreach (Wz_Node tree in image.Node.Nodes)
                    {
                        if (Int32.TryParse(tree.Text, out id))
                        {
                            StringResult strResult = new StringResult();
                            strResult.Name     = GetDefaultString(tree, "name");
                            strResult.Desc     = GetDefaultString(tree, "desc");
                            strResult.AutoDesc = GetDefaultString(tree, "autodesc");
                            strResult.FullPath = tree.FullPath;

                            AddAllValue(strResult, tree);
                            stringItem[id] = strResult;
                        }
                    }
                    break;

                case "Etc.img":
                    if (!image.TryExtract())
                    {
                        break;
                    }
                    foreach (Wz_Node tree0 in image.Node.Nodes)
                    {
                        foreach (Wz_Node tree in tree0.Nodes)
                        {
                            if (Int32.TryParse(tree.Text, out id))
                            {
                                StringResult strResult = new StringResult();
                                strResult.Name     = GetDefaultString(tree, "name");
                                strResult.Desc     = GetDefaultString(tree, "desc");
                                strResult.FullPath = tree.FullPath;

                                AddAllValue(strResult, tree);
                                stringItem[id] = strResult;
                            }
                        }
                    }
                    break;

                case "Mob.img":
                    if (!image.TryExtract())
                    {
                        break;
                    }
                    foreach (Wz_Node tree in image.Node.Nodes)
                    {
                        if (Int32.TryParse(tree.Text, out id))
                        {
                            StringResult strResult = new StringResult();
                            strResult.Name     = GetDefaultString(tree, "name");
                            strResult.FullPath = tree.FullPath;

                            AddAllValue(strResult, tree);
                            stringMob[id] = strResult;
                        }
                    }
                    break;

                case "Npc.img":
                    if (!image.TryExtract())
                    {
                        break;
                    }
                    foreach (Wz_Node tree in image.Node.Nodes)
                    {
                        if (Int32.TryParse(tree.Text, out id))
                        {
                            StringResult strResult = new StringResult();
                            strResult.Name     = GetDefaultString(tree, "name");
                            strResult.Desc     = GetDefaultString(tree, "func");
                            strResult.FullPath = tree.FullPath;

                            AddAllValue(strResult, tree);
                            stringNpc[id] = strResult;
                        }
                    }
                    break;

                case "Map.img":
                    if (!image.TryExtract())
                    {
                        break;
                    }
                    foreach (Wz_Node tree0 in image.Node.Nodes)
                    {
                        foreach (Wz_Node tree in tree0.Nodes)
                        {
                            if (Int32.TryParse(tree.Text, out id))
                            {
                                StringResult strResult = new StringResult();
                                strResult.Name = string.Format("{0}:{1}",
                                                               GetDefaultString(tree, "streetName"),
                                                               GetDefaultString(tree, "mapName"));
                                strResult.Desc     = GetDefaultString(tree, "mapDesc");
                                strResult.FullPath = tree.FullPath;

                                AddAllValue(strResult, tree);
                                stringMap[id] = strResult;
                            }
                        }
                    }
                    break;

                case "Skill.img":
                    if (!image.TryExtract())
                    {
                        break;
                    }
                    foreach (Wz_Node tree in image.Node.Nodes)
                    {
                        StringResult strResult = new StringResult(true);
                        strResult.Name  = GetDefaultString(tree, "name");   //?? GetDefaultString(tree, "bookName");
                        strResult.Desc  = GetDefaultString(tree, "desc");
                        strResult.Pdesc = GetDefaultString(tree, "pdesc");
                        strResult.SkillH.Add(GetDefaultString(tree, "h"));
                        strResult.SkillpH.Add(GetDefaultString(tree, "ph"));
                        strResult.SkillhcH.Add(GetDefaultString(tree, "hch"));
                        if (strResult.SkillH[0] == null)
                        {
                            strResult.SkillH.RemoveAt(0);
                            for (int i = 1; ; i++)
                            {
                                string hi = GetDefaultString(tree, "h" + i);
                                if (string.IsNullOrEmpty(hi))
                                {
                                    break;
                                }
                                strResult.SkillH.Add(hi);
                            }
                        }
                        strResult.SkillH.TrimExcess();
                        strResult.SkillpH.TrimExcess();
                        strResult.FullPath = tree.FullPath;

                        AddAllValue(strResult, tree);
                        if (tree.Text.Length >= 7 && Int32.TryParse(tree.Text, out id))
                        {
                            stringSkill[id] = strResult;
                        }
                        stringSkill2[tree.Text] = strResult;
                    }
                    break;

                case "Eqp.img":
                    if (!image.TryExtract())
                    {
                        break;
                    }
                    foreach (Wz_Node tree0 in image.Node.Nodes)
                    {
                        foreach (Wz_Node tree1 in tree0.Nodes)
                        {
                            foreach (Wz_Node tree in tree1.Nodes)
                            {
                                if (Int32.TryParse(tree.Text, out id))
                                {
                                    StringResult strResult = new StringResult();
                                    strResult.Name     = GetDefaultString(tree, "name");
                                    strResult.Desc     = GetDefaultString(tree, "desc");
                                    strResult.FullPath = tree.FullPath;

                                    AddAllValue(strResult, tree);
                                    stringEqp[id] = strResult;
                                }
                            }
                        }
                    }
                    break;
                }
            }

            return(this.HasValues);
        }