示例#1
0
        public static DataSet1.dtIngGatheredDataTable SortGatheredIngDataTable(DataSet1.dtIngGatheredDataTable dtIngredsIn)
        {
            var sDict = new SortedDictionary <string, DataSet1.dtIngGatheredRow>();

            foreach (DataSet1.dtIngGatheredRow row in dtIngredsIn.Rows)
            {
                sDict.Add(row.IngredientName, row);
            }

            var dtIngredsOut = new DataSet1.dtIngGatheredDataTable();

            foreach (DataSet1.dtIngGatheredRow row in sDict.Values)
            {
                DataSet1.dtIngGatheredRow newRow = dtIngredsOut.NewdtIngGatheredRow();
                newRow.Profession     = row.Profession;
                newRow.Quantity       = row.Quantity;
                newRow.IngredientName = row.IngredientName;
                newRow.Tier           = row.Tier;
                dtIngredsOut.AdddtIngGatheredRow(newRow);
            }

            return(dtIngredsOut);
        }
示例#2
0
        private void AddSimpleToOutput(Ingredient ing, ref long supplierTotal,
                                       ref DataSet1.dtIngGatheredDataTable dtIngGathered,
                                       ref DataSet1.dtIngSupplierDataTable dtIngSupplier)
        {
            bool bFound = false;

            if ((ing is SupplierIngredients) || (ing is TraderIngredients))
            {
                long cost = 0;
                if (ing is SupplierIngredients)
                {
                    var supIng = (SupplierIngredients)ing;
                    cost = supIng.EstimatedCost;
                }
                foreach (DataSet1.dtIngSupplierRow row in dtIngSupplier.Rows)
                {
                    if (row.IngredientName == ing.Name)
                    {
                        int oldQuantity = Convert.ToInt32(row.Quantity);
                        row.Quantity   = Convert.ToString(oldQuantity + ing.QuantityRequested);
                        supplierTotal += (cost * ing.QuantityRequested);
                        bFound         = true;
                        break;
                    }
                }
                if (!bFound)
                {
                    DataSet1.dtIngSupplierRow dtRow = dtIngSupplier.NewdtIngSupplierRow();
                    dtRow.Quantity       = ing.QuantityRequested.ToString();
                    dtRow.IngredientName = ing.Name;
                    dtRow.SupplierType   = ing.FormatIngredientType();
                    if (cost > 0)
                    {
                        dtRow.Price    = cost.ToString();
                        supplierTotal += (cost * ing.QuantityRequested);
                    }
                    else
                    {
                        dtRow.Price = "0";
                    }

                    dtIngSupplier.AdddtIngSupplierRow(dtRow);
                }
            }
            else //  gathered
            {
                var simpIng = (SimpleIngredients)ing;
                foreach (DataSet1.dtIngGatheredRow row in dtIngGathered.Rows)
                {
                    if (row.IngredientName == ing.Name)
                    {
                        row.Quantity = Convert.ToString(Convert.ToInt32(row.Quantity) + Convert.ToInt32(ing.QuantityRequested));
                        bFound       = true;
                        break;
                    }
                }
                if (!bFound)
                {
                    DataSet1.dtIngGatheredRow dtRow = dtIngGathered.NewdtIngGatheredRow();
                    dtRow.Quantity       = ing.QuantityRequested.ToString();
                    dtRow.IngredientName = ing.Name;
                    dtRow.Tier           = ProfessionTier.FormatTier(simpIng.Tier);
                    if (ing is FarmedIngredients)
                    {
                        dtRow.Profession = "Farming";
                    }
                    else if (ing is ForesterIngredients)
                    {
                        dtRow.Profession = "Forester";
                    }
                    else if (ing is PickedIngredients)
                    {
                        dtRow.Profession = "Picked";
                    }
                    else if (ing is FishingIngredients)
                    {
                        dtRow.Profession = "Fishing";
                    }
                    else if (ing is MobDropIngredients)
                    {
                        dtRow.Profession = "Mob Drop";
                    }
                    else if (ing is ProspectorIngredients)
                    {
                        dtRow.Profession = "Prospector";
                    }
                    else if (ing is ScholarIngredients)
                    {
                        dtRow.Profession = "Scholar";
                    }

                    dtIngGathered.AdddtIngGatheredRow(dtRow);
                }
            }
        }