Exemplo 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());
    }
Exemplo n.º 2
0
    public bool ConsumeItemList(List <List <int> > item_list, bool is_check = false)
    {
        item_list = this.MergeItem(item_list);
        if (item_list == null)
        {
            return(false);
        }

        foreach (List <int> item_info in item_list)
        {
            int item_id = 0, count = 0, bind = 0, addition = 0;
            CustomFormat.ParseItemInfo(item_info, ref item_id, ref count, ref bind, ref addition);
            if (!this.ReduceItem(item_id, count, bind, is_check))
            {
                return(false);
            }
        }
        return(true);
    }