Esempio n. 1
0
    private List <List <int> > MergeItem(List <List <int> > item_list)
    {
        TwoKeyDictionary <int, int, List <int> > map = new TwoKeyDictionary <int, int, List <int> >();

        foreach (List <int> item_info in item_list)
        {
            int  item_id = 0, count = 0, bind = 0, addition = 0;
            bool result = CustomFormat.ParseItemInfo(item_info, ref item_id, ref count, ref bind, ref addition);
            if (!result)
            {
                return(null);
            }

            List <int> info = map.Get(item_id, bind);
            if (info == null)
            {
                info = new List <int> {
                    item_id, 0, bind, addition
                };
            }
            info[2] += count;
            map.Set(item_id, bind, info);
        }
        return(map.ToList());
    }