Exemple #1
0
        public static void Extract(DbContextOptions options)
        {
            var wz = new Wz_Structure();

            wz.Load(@"C:\Nexon\MapleStory\Character.wz");
            var character = Directory.CreateDirectory("Character");

            Directory.SetCurrentDirectory(character.FullName);

            using (var db = new MapleStoryDbContext(options)) {
                foreach (var img in wz.WzNode.Nodes.Where(x => x.Value is Wz_Image).OrderBy(x => x.Text).Select(x => x.GetNodeWzImage()))
                {
                    var eq = CreateEquipment(img, false);
                    if (eq != null)
                    {
                        db.Equipments.Add(eq);
                    }
                }
                db.SaveChanges();

                var list = new[] {
                    "Accessory",
                    "Cap",
                    "Cape",
                    "Coat",
                    "Face",
                    "Glove",
                    "Hair",
                    "Longcoat",
                    "Pants",
                    "Ring",
                    "Shield",
                    "Shoes",
                    "Weapon"
                };
                foreach (var dir in wz.WzNode.Nodes.Where(x => !(x.Value is Wz_Image) && list.Contains(x.Text)).OrderBy(x => x.Text))
                {
                    Log(dir);
                    var fullpathes          = new List <string>();
                    var referenceFullpathes = new List <string>();
                    foreach (var img in dir.Nodes.OrderBy(x => x.Text).Select(x => x.GetNodeWzImage()))
                    {
                        var eq = CreateEquipment(img, dir.Text == "Hair");
                        if (eq != null)
                        {
                            db.Equipments.Add(eq);
                            referenceFullpathes.AddRange(eq.Frames.SelectMany(fr => fr.FrameImages.Select(fi => fi.ImageLogicalPath)));
                            fullpathes.AddRange(eq.Frames.SelectMany(fr => fr.FrameImages.Select(fi => fi.Image?.ImageLogicalPath)));
                        }
                    }
                    foreach (var i in referenceFullpathes.Except(fullpathes))
                    {
                        Console.WriteLine(i);
                    }
                    db.SaveChanges();
                }
            }
        }
Exemple #2
0
        public static void Extract(DbContextOptions options)
        {
            var wz = new Wz_Structure();

            wz.Load(@"C:\Nexon\MapleStory\String.wz");
            using (var db = new MapleStoryDbContext(options)) {
                var eqp = wz.WzNode.Nodes["Eqp.img"].GetNodeWzImage();
                if (!eqp.TryExtract())
                {
                    throw new Exception();
                }
                foreach (var dir in eqp.Node.Nodes.SelectMany(x => x.Nodes))
                {
                    foreach (var item in dir.Nodes)
                    {
                        var eq = db.Equipments.SingleOrDefault(x => x.EquipmentId == int.Parse(item.Text));
                        if (eq != null)
                        {
                            eq.EquipmentName = (string)item.Nodes["name"]?.Value;
                        }
                    }
                }
                db.SaveChanges();
            }
        }
Exemple #3
0
        public static void Extract(DbContextOptions options)
        {
            var wz = new Wz_Structure();

            wz.Load(@"C:\Nexon\MapleStory\Base.wz");
            using (var db = new MapleStoryDbContext(options)) {
                var zmap = wz.WzNode.Nodes["zmap.img"].GetNodeWzImage();
                if (!zmap.TryExtract())
                {
                    throw new Exception();
                }
                foreach (var(value, index) in zmap.Node.Nodes.Reverse().Select((value, index) => (value, index)))
                {
                    db.Zmaps.Add(new Zmap()
                    {
                        Name  = value.Text,
                        Index = index
                    });
                }

                var smap = wz.WzNode.Nodes["smap.img"].GetNodeWzImage();
                if (!smap.TryExtract())
                {
                    throw new Exception();
                }

                foreach (var(value, index) in smap.Node.Nodes.Reverse().Select((value, index) => (value, index)))
                {
                    db.Smaps.Add(new Smap()
                    {
                        Key   = value.Text,
                        Value = value.GetValue <string>(),
                        Index = index
                    });
                }
                db.SaveChanges();
            }
        }
        public static void Extract(DbContextOptions options)
        {
            var regex = new Regex(@"(^begin|^end)(\d*)$");
            var wz    = new Wz_Structure();

            wz.Load(@"C:\Nexon\MapleStory\Item.wz");
            using (var db = new MapleStoryDbContext(options)) {
                var eqp = wz.WzNode.Nodes["ThothSearchOption.img"].GetNodeWzImage();
                if (!eqp.TryExtract())
                {
                    throw new Exception();
                }
                db.ItemCategories.AddRange(new[] {
                    new ItemCategory {
                        ItemCategory1          = "Character",
                        ItemCategory2          = "Body",
                        ItemCategoryName       = "肌",
                        ItemCategoryRangeBegin = 2000,
                        ItemCategoryRangeEnd   = 2099
                    },
                    new ItemCategory {
                        ItemCategory1          = "Character",
                        ItemCategory2          = "Head",
                        ItemCategoryName       = "肌(顔)",
                        ItemCategoryRangeBegin = 12000,
                        ItemCategoryRangeEnd   = 12099
                    },
                    new ItemCategory {
                        ItemCategory1          = "Character",
                        ItemCategory2          = "Hair",
                        ItemCategoryName       = "髪",
                        ItemCategoryRangeBegin = 30000,
                        ItemCategoryRangeEnd   = 49999
                    },
                    new ItemCategory {
                        ItemCategory1          = "Character",
                        ItemCategory2          = "Face",
                        ItemCategoryName       = "顔",
                        ItemCategoryRangeBegin = 20000,
                        ItemCategoryRangeEnd   = 29999
                    },
                });

                foreach (var category1 in eqp.Node.Nodes["ItemDetailCategory"].Nodes)
                {
                    foreach (var category2 in category1.Nodes)
                    {
                        var ranges =
                            category2
                            .Nodes
                            .Where(x => regex.IsMatch(x.Text))
                            .GroupBy(x => regex.Replace(x.Text, "$2"))
                            .Select(x => {
                            int?begin = null;
                            int?end   = null;
                            foreach (var attr in x)
                            {
                                if (attr.Text.StartsWith("begin"))
                                {
                                    begin = GetValue <int>(attr.Value);
                                }
                                if (attr.Text.StartsWith("end"))
                                {
                                    end = GetValue <int>(attr.Value);
                                }
                            }
                            return(begin, end);
                        });
                        foreach (var(begin, end) in ranges)
                        {
                            var category = new ItemCategory {
                                ItemCategory1          = category1.Text,
                                ItemCategory2          = category2.Text,
                                ItemCategoryName       = GetValue <string>(category2.Nodes["string"].Value),
                                ItemCategoryRangeBegin = (int)begin,
                                ItemCategoryRangeEnd   = (int)end
                            };

                            db.ItemCategories.Add(category);
                        }
                    }
                }
                db.SaveChanges();
            }
        }