Exemplo n.º 1
0
        private void AddRecipeToOutput(CompositeIngredients rec, ref long supplierTotal,
                                       ref DataSet1.dtRecipeDataTable dtRecipes,
                                       ref DataSet1.dtIngCraftedDataTable dtIngCrafted,
                                       ref DataSet1.dtIngGatheredDataTable dtIngGathered,
                                       ref DataSet1.dtIngSupplierDataTable dtIngSupplier,
                                       ref DataSet1.dtCraftingXPDataTable dtCraftingXp)
        {
            bool bFound = false;

            // if already added, then sum, else create
            foreach (DataSet1.dtRecipeRow row in dtRecipes.Rows)
            {
                if (row.RecipeName == rec.Name)
                {
                    row.Quantity = Convert.ToString(Convert.ToInt32(row.Quantity) + rec.QuantityRequested);
                    bFound       = true;
                    break;
                }
            }
            if (!bFound)
            {
                DataSet1.dtRecipeRow dtRow = dtRecipes.NewdtRecipeRow();
                dtRow.Quantity   = rec.QuantityRequested.ToString();
                dtRow.Profession = GetProfession(rec);
                dtRow.RecipeName = rec.Name;
                dtRow.Tier       = ProfessionTier.FormatTier(rec.Tier);
                dtRow.Facility   = GetFacility(rec);
                dtRecipes.AdddtRecipeRow(dtRow);
            }
            addCraftingXp(rec, ref dtCraftingXp);

            // breakdown the ingredients
            foreach (Ingredient subIng in rec.GetRecipeIngredients().Values)
            {
                if (subIng is CompositeIngredients)
                {
                    var newIng = (CompositeIngredients)subIng;
                    AddComponentToOutput(newIng, ref supplierTotal, ref dtIngCrafted, ref dtIngGathered, ref dtIngSupplier, ref dtCraftingXp);
                }
                else
                {
                    AddSimpleToOutput(subIng, ref supplierTotal, ref dtIngGathered, ref dtIngSupplier);
                }
            }
        }
Exemplo n.º 2
0
        public static DataSet1.dtIngCraftedDataTable SortCraftedIngDataTable(DataSet1.dtIngCraftedDataTable dtIngredsIn)
        {
            var sDict = new SortedDictionary <string, DataSet1.dtIngCraftedRow>();

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

            var dtIngredsOut = new DataSet1.dtIngCraftedDataTable();

            foreach (DataSet1.dtIngCraftedRow row in sDict.Values)
            {
                DataSet1.dtIngCraftedRow newRow = dtIngredsOut.NewdtIngCraftedRow();
                newRow.Facility       = row.Facility;
                newRow.Profession     = row.Profession;
                newRow.Quantity       = row.Quantity;
                newRow.IngredientName = row.IngredientName;
                newRow.Tier           = row.Tier;
                dtIngredsOut.AdddtIngCraftedRow(newRow);
            }

            return(dtIngredsOut);
        }
Exemplo n.º 3
0
 private void Deconstruct(bool hasProfession, ProfessionTierEnum tierAvail, ref long supplierTotal,
                          CompositeIngredients compIng,
                          ref DataSet1.dtIngCraftedDataTable dtIngCrafted,
                          ref DataSet1.dtIngGatheredDataTable dtIngGathered,
                          ref DataSet1.dtIngSupplierDataTable dtIngSupplier,
                          ref DataSet1.dtCraftingXPDataTable dtCraftingXp)
 {
     if (hasProfession && (tierAvail >= compIng.Tier)) // decompose
     {
         foreach (Ingredient ing in compIng.GetRecipeIngredients().Values)
         {
             if (ing is CompositeIngredients)
             {
                 var newIng = (CompositeIngredients)ing;
                 AddComponentToOutput(newIng, ref supplierTotal, ref dtIngCrafted, ref dtIngGathered, ref dtIngSupplier, ref dtCraftingXp);
             }
             else
             {
                 AddSimpleToOutput(ing, ref supplierTotal, ref dtIngGathered, ref dtIngSupplier);
             }
         }
     }
     // else do nothing. this composite ing was added by caller.
 }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (null == Session["Cook"])
            {
                Response.Redirect("~/default.aspx");
                return;
            }

            if (Page.IsPostBack)
            {
                return;
            }

            var dtCart = (DataTable)Session["dtCart"];

            if (null == dtCart)
            {
                dtCart = new DataTable();
                dtCart.Columns.Add("Recipe", typeof(string));
                dtCart.Columns.Add("Tier", typeof(string));
                dtCart.Columns.Add("Quantity", typeof(string));
                Session.Add("dtCart", dtCart);
            }

            var recsAll = (SortedDictionary <string, Ingredient>)Application["Recipes"];
            //var ingsAll = (SortedDictionary<string, Ingredient>)Application["Ingredients"];
            //var ds = new DataSet1();

            //var dt = ds.dtRecipe;

            long supplierTotal = 0;

            var dtRecipesUnsorted     = new DataSet1.dtRecipeDataTable();
            var dtIngCraftedUnsorted  = new DataSet1.dtIngCraftedDataTable();
            var dtIngGatheredUnsorted = new DataSet1.dtIngGatheredDataTable();
            var dtIngSupplierUnsorted = new DataSet1.dtIngSupplierDataTable();
            var dtCraftingXp          = new DataSet1.dtCraftingXPDataTable();

            for (int i = 0; i < 9; i++)
            {
                // ProfessionTierEnum.Apprentice
                var dtCraftingXpRow = dtCraftingXp.NewdtCraftingXPRow();
                dtCraftingXpRow.Tier        = ProfessionTier.FormatTier((ProfessionTierEnum)i);
                dtCraftingXpRow.Cook        = 0;
                dtCraftingXpRow.Forester    = 0;
                dtCraftingXpRow.Jeweler     = 0;
                dtCraftingXpRow.Metalsmith  = 0;
                dtCraftingXpRow.Prospector  = 0;
                dtCraftingXpRow.Scholar     = 0;
                dtCraftingXpRow.Tailor      = 0;
                dtCraftingXpRow.Weaponsmith = 0;
                dtCraftingXpRow.Woodworker  = 0;
                dtCraftingXp.Rows.Add(dtCraftingXpRow);
            }

            foreach (DataRow dtRow in dtCart.Rows)
            {
                var recipeName = (string)dtRow["Recipe"];
                //string Tier = (string)dtRow["Tier"];
                var quantity       = (string)dtRow["Quantity"];
                int quantityToMake = 1;
                try { quantityToMake = Convert.ToInt16(quantity); }
// ReSharper disable EmptyGeneralCatchClause
                catch { }
// ReSharper restore EmptyGeneralCatchClause

                var rec = (CompositeIngredients)recsAll[recipeName];
                rec.QuantityRequested = quantityToMake;

                AddRecipeToOutput(rec, ref supplierTotal,
                                  ref dtRecipesUnsorted, ref dtIngCraftedUnsorted, ref dtIngGatheredUnsorted, ref dtIngSupplierUnsorted, ref dtCraftingXp);
            }

            DataSet1.dtRecipeDataTable      dtRecipes     = DataSetHelpers.SortRecipeDataTable(dtRecipesUnsorted);
            DataSet1.dtIngCraftedDataTable  dtIngCrafted  = DataSetHelpers.SortCraftedIngDataTable(dtIngCraftedUnsorted);
            DataSet1.dtIngGatheredDataTable dtIngGathered = DataSetHelpers.SortGatheredIngDataTable(dtIngGatheredUnsorted);
            DataSet1.dtIngSupplierDataTable dtIngSupplier = DataSetHelpers.SortSupplierIngDataTable(dtIngSupplierUnsorted);

            var dtSupplierCost = new DataSet1.dtSupplierTotalDataTable();
            var dtSupplierRow  = dtSupplierCost.NewdtSupplierTotalRow();

            dtSupplierRow.TotalCost = FormatCost(supplierTotal);
            dtSupplierCost.AdddtSupplierTotalRow(dtSupplierRow);

            ReportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1_dtRecipe", (DataTable)dtRecipes));
            ReportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1_dtIngCrafted", (DataTable)dtIngCrafted));
            ReportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1_dtIngGathered", (DataTable)dtIngGathered));
            ReportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1_dtIngSupplier", (DataTable)dtIngSupplier));
            ReportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1_dtSupplierCost", (DataTable)dtSupplierCost));
            ReportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1_dtCraftingXP", (DataTable)dtCraftingXp));

            ReportViewer1.LocalReport.ReportPath = "Report1.rdlc";
            ReportViewer1.LocalReport.Refresh();
        }
Exemplo n.º 5
0
        private void AddComponentToOutput(CompositeIngredients compIng, ref long supplierTotal,
                                          ref DataSet1.dtIngCraftedDataTable dtIngCrafted,
                                          ref DataSet1.dtIngGatheredDataTable dtIngGathered,
                                          ref DataSet1.dtIngSupplierDataTable dtIngSupplier,
                                          ref DataSet1.dtCraftingXPDataTable dtCraftingXp)
        {
            bool bFound = false;

            foreach (DataSet1.dtIngCraftedRow row in dtIngCrafted.Rows)
            {
                if (row.IngredientName == compIng.Name)
                {
                    row.Quantity = Convert.ToString(Convert.ToInt32(row.Quantity) + Convert.ToInt32(compIng.QuantityRequested));
                    bFound       = true;
                    break;
                }
            }
            if (!bFound)
            {
                DataSet1.dtIngCraftedRow dtRow = dtIngCrafted.NewdtIngCraftedRow();
                dtRow.Quantity       = compIng.QuantityRequested.ToString();
                dtRow.Profession     = GetProfession(compIng);
                dtRow.IngredientName = compIng.Name;
                dtRow.Tier           = ProfessionTier.FormatTier(compIng.Tier);
                dtRow.Facility       = GetFacility(compIng);
                dtIngCrafted.AdddtIngCraftedRow(dtRow);
            }
            addCraftingXp(compIng, ref dtCraftingXp);

            if (compIng is CookIngredients)
            {
                var hasProfession = (bool)Session["Cook"];
                var tierAvail     = ProfessionTier.GetTier((string)Session["CookTier"]);
                Deconstruct(hasProfession, tierAvail, ref supplierTotal,
                            compIng, ref dtIngCrafted, ref dtIngGathered, ref dtIngSupplier, ref dtCraftingXp);
            }
            else if (compIng is ForesterCompIngredients)
            {
                var hasProfession = (bool)Session["Forester"];
                var tierAvail     = ProfessionTier.GetTier((string)Session["ForesterTier"]);
                Deconstruct(hasProfession, tierAvail, ref supplierTotal,
                            compIng, ref dtIngCrafted, ref dtIngGathered, ref dtIngSupplier, ref dtCraftingXp);
            }
            else if (compIng is JewelerIngredients)
            {
                var hasProfession = (bool)Session["Jeweler"];
                var tierAvail     = ProfessionTier.GetTier((string)Session["JewelerTier"]);
                Deconstruct(hasProfession, tierAvail, ref supplierTotal,
                            compIng, ref dtIngCrafted, ref dtIngGathered, ref dtIngSupplier, ref dtCraftingXp);
            }
            else if (compIng is MetalsmithIngredients)
            {
                var hasProfession = (bool)Session["Metalsmith"];
                var tierAvail     = ProfessionTier.GetTier((string)Session["MetalsmithTier"]);
                Deconstruct(hasProfession, tierAvail, ref supplierTotal,
                            compIng, ref dtIngCrafted, ref dtIngGathered, ref dtIngSupplier, ref dtCraftingXp);
            }
            else if (compIng is ProspectorCompIngredients)
            {
                var hasProfession = (bool)Session["Prospector"];
                var tierAvail     = ProfessionTier.GetTier((string)Session["ProspectorTier"]);
                Deconstruct(hasProfession, tierAvail, ref supplierTotal,
                            compIng, ref dtIngCrafted, ref dtIngGathered, ref dtIngSupplier, ref dtCraftingXp);
            }
            else if (compIng is ScholarCompIngredients)
            {
                var hasProfession = (bool)Session["Scholar"];
                var tierAvail     = ProfessionTier.GetTier((string)Session["ScholarTier"]);
                Deconstruct(hasProfession, tierAvail, ref supplierTotal,
                            compIng, ref dtIngCrafted, ref dtIngGathered, ref dtIngSupplier, ref dtCraftingXp);
            }
            else if (compIng is TailorIngredients)
            {
                var hasProfession = (bool)Session["Tailor"];
                var tierAvail     = ProfessionTier.GetTier((string)Session["TailorTier"]);
                Deconstruct(hasProfession, tierAvail, ref supplierTotal,
                            compIng, ref dtIngCrafted, ref dtIngGathered, ref dtIngSupplier, ref dtCraftingXp);
            }
            else if (compIng is WeaponsmithIngredients)
            {
                var hasProfession = (bool)Session["Weaponsmith"];
                var tierAvail     = ProfessionTier.GetTier((string)Session["WeaponsmithTier"]);
                Deconstruct(hasProfession, tierAvail, ref supplierTotal,
                            compIng, ref dtIngCrafted, ref dtIngGathered, ref dtIngSupplier, ref dtCraftingXp);
            }
            else if (compIng is WoodworkerIngredients)
            {
                var hasProfession = (bool)Session["Woodworker"];
                var tierAvail     = ProfessionTier.GetTier((string)Session["WoodworkerTier"]);
                Deconstruct(hasProfession, tierAvail, ref supplierTotal,
                            compIng, ref dtIngCrafted, ref dtIngGathered, ref dtIngSupplier, ref dtCraftingXp);
            }
        }