Exemplo n.º 1
0
        public static CommodityTemplate Parse(int id, IDataProperty property)
        {
            var t = new CommodityTemplate {
                ID = id
            };

            property.Resolve(p =>
            {
                t.ItemID         = p.Resolve <int>("ItemId") ?? 0;
                t.Count          = p.Resolve <short>("Count") ?? 1;
                t.Priority       = p.Resolve <byte>("Priority") ?? 0;
                t.Price          = p.Resolve <int>("Price") ?? 0;
                t.Bonus          = p.Resolve <byte>("Bonus") ?? 0;
                t.Period         = p.Resolve <short>("Period") ?? 0;
                t.ReqPOP         = p.Resolve <short>("ReqPOP") ?? 0;
                t.ReqLEV         = p.Resolve <short>("ReqLEV") ?? 0;
                t.MaplePoint     = p.Resolve <int>("MaplePoint") ?? 0;
                t.Meso           = p.Resolve <int>("Meso") ?? 0;
                t.ForPremiumUser = p.Resolve <bool>("Premium") ?? false;
                t.Gender         = p.Resolve <sbyte>("Gender") ?? 0;
                t.OnSale         = p.Resolve <bool>("OnSale") ?? false;
                t.Class          = p.Resolve <byte>("Class") ?? 0;
                t.Limit          = p.Resolve <byte>("Limit") ?? 0;
                t.PbCash         = p.Resolve <short>("PbCash") ?? 0;
                t.PbPoint        = p.Resolve <short>("PbPoint") ?? 0;
                t.PbGift         = p.Resolve <short>("PbGift") ?? 0;
            });

            return(t);
        }
        public override Task LoadAll()
        {
            var property = Collection.Resolve("Etc/Commodity.img");

            property.Children
            .ToDictionary(
                c => c.Resolve <int>("SN") ?? 0,
                c => CommodityTemplate.Parse(c.Resolve <int>("SN") ?? 0, c)
                )
            .ForEach(kv => Templates.Add(kv.Key, kv.Value));
            return(Task.CompletedTask);
        }