Exemplo n.º 1
0
        private void Confirm_Cull(ResultsBoxItem resultsBoxItem)
        {
            List <ItemsFormat> QuestItemFormats = new List <ItemsFormat>();
            List <QuestItem>   QuestItemList    = new List <QuestItem>();
            //int QuestIndex = Program.questList.IndexOf(Program.questList.Find(p => p.DaybreakID == resultsBoxItem.QuestID));
            int         QuestCount, CharCountdown = 0;
            List <long> QuestList = new List <long>();

            foreach (object ThisObject in PAItemList.Items)
            {
                ItemsFormat ThisItem = ThisObject as ItemsFormat;
                if (Program.questList[resultsBoxItem.QuestID].items.Contains(ThisItem.ItemID))
                {
                    QuestItemFormats.Add(ThisItem);
                    QuestItemList.Add(Program.itemList[ThisItem.ItemID]);
                }
            }
            foreach (ItemsFormat itemsFormat in QuestItemFormats)
            {
                PAItemList.Items.Remove(itemsFormat);
            }
            foreach (QuestItem questItem in QuestItemList)
            {
                foreach (CollQuest ThisQuest in Program.questList.Values)
                {
                    if (ThisQuest.items.Contains(questItem.DaybreakID))
                    {
                        QuestList.Add(ThisQuest.DaybreakID);
                    }
                }
                QuestCount = QuestList.Count * ServerMates.Count;
                foreach (Characters ThisChar in ServerMates.Values)
                {
                    foreach (long ThisQuest in QuestList)
                    {
                        int OldCount = Program.questList[ThisQuest].items.Count;
                        if (ThisChar.IsComplete(ThisQuest) || (ThisChar.CharCollection.ContainsKey(ThisQuest) && ThisChar.CharCollection[ThisQuest].Contains(questItem.DaybreakID)))
                        {
                            CharCountdown++;
                        }
                        if ((OldCount != Program.questList[ThisQuest].items.Count) && (FinalResult == DialogResult.Retry))
                        {
                            FinalResult = DialogResult.OK;
                        }
                    }
                }
                QuestCount -= CharCountdown;
                if (QuestCount < 0)
                {
                    ReturnedException = new Exception($"The characters have collected more {questItem.ItemName} than the number of quests needing it * the number of characters.");
                    FinalResult       = DialogResult.Abort;
                    Close();
                }
                _             = PAItemList.Items.Add(new ItemsFormat(questItem.ToString(), QuestCount, questItem.DaybreakID));
                CharCountdown = 0;
                QuestCount    = 0;
                QuestList.Clear();
            }
        }
Exemplo n.º 2
0
        private Dictionary <long, WantResults> GetWants(QuestItem ThisItem)
        {
            Dictionary <long, WantResults> returnValue = new Dictionary <long, WantResults>(); // This will contain the charIDs as the key and the wantResults as the value.
            Dictionary <long, int>         QuestDict   = new Dictionary <long, int>();         // Contains each questID (key) that uses this item and the number of items required for those quests (value).

            foreach (CollQuest ThisQuest in Program.questList.Values)
            {
                if (ThisQuest.items.Contains(ThisItem.DaybreakID))
                {
                    QuestDict[ThisQuest.DaybreakID] = ThisQuest.items.Count;
                }
            }
            if (QuestDict.Count < 1)
            {
                FinalResult       = DialogResult.Abort;
                ReturnedException = new Exception("No quests exist for the item being sought. This should never happen.");
                Close();
            }
            foreach ((Characters ThisChar, KeyValuePair <long, int> ThisQuest) in from Characters ThisChar in ServerMates.Values
                     from KeyValuePair <long, int> ThisQuest in QuestDict
                     select(ThisChar, ThisQuest))
            {
                if ((!returnValue.ContainsKey(ThisChar.DaybreakID)) &&
                    (!ThisChar.CharCollection.ContainsKey(ThisQuest.Key)))
                {
                    returnValue[ThisChar.DaybreakID] = new WantResults()
                    {
                        QuestID   = ThisQuest.Key,
                        GreedRate = 0.0
                    };
                }
                else if (!ThisChar.CharCollection.ContainsKey(ThisQuest.Key))
                {
                    continue;  // A want already exists for this character and it is >= 0.
                }
                else if (!returnValue.ContainsKey(ThisChar.DaybreakID))
                {
                    int OldValue = ThisChar.CharCollection[ThisQuest.Key].Count;
                    if (ThisChar.CharCollection[ThisQuest.Key].Contains(ThisItem.DaybreakID) || ThisChar.IsComplete(ThisQuest.Key))
                    {
                        if ((OldValue != ThisChar.CharCollection[ThisQuest.Key].Count) && (FinalResult == DialogResult.Retry))
                        {
                            FinalResult = DialogResult.OK;
                        }
                        continue;
                    }

                    if (Program.questList[ThisQuest.Key].ExpertColl)
                    {
                        returnValue[ThisChar.DaybreakID] = new WantResults()
                        {
                            QuestID   = ThisQuest.Key,
                            GreedRate = ((double)ThisChar.CharCollection[ThisQuest.Key].Count) / ThisQuest.Value * ExpertMult
                        }
                    }
                    ;
                    else
                    {
                        returnValue[ThisChar.DaybreakID] = new WantResults()
                        {
                            QuestID   = ThisQuest.Key,
                            GreedRate = ((double)ThisChar.CharCollection[ThisQuest.Key].Count) / ThisQuest.Value
                        }
                    };
                }
                else if ((QuestDict.Count > 1) && (ThisQuest.Key != QuestDict.Keys.First()))
                {
                    if (ThisChar.CharCollection[ThisQuest.Key].Contains(ThisItem.DaybreakID))
                    {
                        continue;
                    }
                    double OldVal = returnValue[ThisChar.DaybreakID].GreedRate;
                    double NewVal = ((double)ThisChar.CharCollection[ThisQuest.Key].Count) / ThisQuest.Value;
                    if (Program.questList[ThisQuest.Key].ExpertColl)
                    {
                        NewVal *= ExpertMult;
                    }
                    if (OldVal < NewVal)
                    {
                        returnValue[ThisChar.DaybreakID] = new WantResults()
                        {
                            QuestID   = ThisQuest.Key,
                            GreedRate = NewVal
                        };
                    }
                }
            }
            return(returnValue);
        }