예제 #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();
            }
        }
예제 #2
0
 private void PAResetBtn_Click(object sender, EventArgs e)
 {
     Refresh();
     PAItemList.SelectedIndex = -1;
     PAIntroLabel.Text        = string.Empty;
     PAListBoxResults.Items.Clear();
     SelectedItem = null;
     _            = PAItemList.Focus();
 }
예제 #3
0
        private void PAItemList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if ((PAItemList.SelectedIndex == -1) ||
                ((PAItemList.SelectedIndex == 0) &&
                 (PAItemList.SelectedItem is string thisString) &&
                 (thisString == "Empty!")))
            {
                SelectedItem = null;
                return;
            }
            const string Surplus = "This item is surplus. It may be sold.";

            PAListBoxResults.Items.Clear();
            long ThisID;

            try { ThisID = (PAItemList.SelectedItem as ItemsFormat).ItemID; }
            catch (NullReferenceException)
            {
                PAListBoxResults.Items.Clear();
                return;
            }
            int       ThisQuant = (PAItemList.SelectedItem as ItemsFormat).ItemQuant;
            QuestItem ThisItem  = Program.itemList[ThisID];

            if (ThisQuant == 0)
            {
                PAIntroLabel.Text = Surplus;
                return;
            }
            else
            {
                Dictionary <long, WantResults> CharsWants = GetWants(ThisItem);
                if (CharsWants.Count == 0)
                {
                    PAIntroLabel.Text = Surplus;
                    return;
                }
                double      biggestWant  = CharsWants.Values.Select(p => p.GreedRate).Max();
                List <long> WantingChars = new List <long>();
                foreach (KeyValuePair <long, WantResults> ThisPair in CharsWants)
                {
                    if (ThisPair.Value.GreedRate == biggestWant)
                    {
                        WantingChars.Add(ThisPair.Key);
                    }
                }
                if (WantingChars.Contains(PAChosenChar))
                {
                    PAIntroLabel.Text = $"{Program.charList[PAChosenChar].name} may add {ThisItem.ItemName} to {Program.questList[CharsWants[PAChosenChar].QuestID].QuestName}.";
                }
                else if (WantingChars.Count == 1)
                {
                    PAIntroLabel.Text = $"If possible, please mail {ServerMates[WantingChars[0]].name} {ThisItem.ItemName} for {Program.questList[CharsWants[WantingChars[0]].QuestID].QuestName}.";
                }
                else
                {
                    PAIntroLabel.Text = "Multiple characters have equal want of this item. Please refer below.";
                }
                PAListBoxResults.Items.Clear();
                foreach (KeyValuePair <long, WantResults> keyValuePair in CharsWants)
                {
                    PAListBoxResults.Items.Add(new ResultsBoxItem(keyValuePair.Key, keyValuePair.Value.QuestID, keyValuePair.Value.GreedRate));
                }
                SelectedItem = PAItemList.SelectedItem as ItemsFormat;
                PAListBoxResults.SelectedIndex = -1;
            }
        }