Пример #1
0
        public IEnumerable <RebalanceInfo> Transform(IList <Node> definitionNodes)
        {
            var groupings = FindItemNodes(definitionNodes)
                            .SelectMany(node => FindAllInfos(node.Parent.Name)
                                        .Select(i =>
            {
                return(new RebalanceInfo
                {
                    id = i.Id,
                    name = _classNameSource.TryGet(i.Name) ?? i.Name,
                    info = node.Value.Replace("\n", "\r\n"),
                    category = i.Category,
                    itemclass = _classNameSource.NormalizeClassName(i.Class),
                    slot = i.Slot,
                    attributes = node.Parent
                                 .Childs.Where(c => c.Name.ToLower().StartsWith("attribute"))
                                 .Select(n => new RebalanceAttribute
                    {
                        id = n.Childs.FirstOrDefault(c => c.Name == "id")?.Value,
                        value = n.Childs.FirstOrDefault(c => c.Name == "value")?.Value,
                    }),
                    additionalFields = node.Parent
                                       .Childs.Where(c =>
                    {
                        var name = c.Name.ToLower();
                        return !name.StartsWith("attribute") &&
                        name != "info" &&
                        name != "keepattribs";
                    })
                                       .ToDictionary(n => n.Name, n => n.Value),
                });
            }));

            return(groupings);
        }
        public IEnumerable <RebalanceInfo> Transform(IList <Node> definitionNodes)
        {
            var weaponNode = definitionNodes.SelectMany(n => n.Childs);

            return(weaponNode.SelectMany(w =>
            {
                var weaponIds = w.Name.Split(';', StringSplitOptions.RemoveEmptyEntries)
                                .Select(s => s.Trim());
                return weaponIds.SelectMany(id => _itemInfoSource.Get(id))
                .Select(info =>
                {
                    return new RebalanceInfo
                    {
                        id = info.Id,
                        name = info.Name,
                        info = "from Custom Attributes",
                        category = info.Category,
                        itemclass = _classNameSource.NormalizeClassName(info.Class),
                        slot = info.Slot,
                        attributes = w.Childs
                                     .Select(a => new RebalanceAttribute
                        {
                            id = a.Name,
                            value = a.Value,
                        }),
                        additionalFields = new Dictionary <string, string>(),
                    };
                });
            }));
        }