예제 #1
0
        public bool addConditionItem(Condition cond)
        {
            if (cond == null || !cond.isLoaded())//should never happen, checked at loading
            {
                Log.outError(LogFilter.Loot, "LootTemplate.addConditionItem: condition is null");
                return(false);
            }

            if (!Entries.Empty())
            {
                foreach (var i in Entries)
                {
                    if (i.itemid == cond.SourceEntry)
                    {
                        i.conditions.Add(cond);
                        return(true);
                    }
                }
            }

            if (!Groups.Empty())
            {
                foreach (var group in Groups.Values)
                {
                    if (group == null)
                    {
                        continue;
                    }

                    LootStoreItemList itemList = group.GetExplicitlyChancedItemList();
                    if (!itemList.Empty())
                    {
                        foreach (var i in itemList)
                        {
                            if (i.itemid == cond.SourceEntry)
                            {
                                i.conditions.Add(cond);
                                return(true);
                            }
                        }
                    }

                    itemList = group.GetEqualChancedItemList();
                    if (!itemList.Empty())
                    {
                        foreach (var i in itemList)
                        {
                            if (i.itemid == cond.SourceEntry)
                            {
                                i.conditions.Add(cond);
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }