Пример #1
0
 public static IEnumerable <MaterialID> GetMetaGroupVersionOfT1(MaterialID matID, int metaGroupID)
 {
     using (var cnn = new SQLiteConnection(DefaultDatabase.dbConnection))
     {
         cnn.Open();
         var query   = @"select typeId from invMetaTypes where parentTypeID = " + matID + " and metaGroupID = " + metaGroupID;
         var results = DefaultDatabase.RunSQLTableQuery(query, cnn);
         var t1Name  = CommonQueries.GetTypeName(matID);
         while (results.Read())
         {
             yield return(new MaterialID(results["typeID"].ToInt()));
         }
     }
 }
Пример #2
0
        public static TSpreadsheet Create <TSpreadsheet>(T2Blueprint bp, int rowNum = 0, TSpreadsheet existing = null, Decryptor decryptor = null) where TSpreadsheet : class, Spreadsheet, new()
        {
            var spreadsheet = existing ?? new TSpreadsheet();

            spreadsheet.AddCell(new SimpleCell("Invention"), 0, rowNum);

            rowNum++;

            spreadsheet.AddCell(new SimpleCell("Quantity"), 1, rowNum);
            spreadsheet.AddCell(new SimpleCell("Buy"), 2, rowNum);
            spreadsheet.AddCell(new SimpleCell("Sell"), 3, rowNum);
            spreadsheet.AddCell(new SimpleCell("BrokerFee"), 4, rowNum);
            spreadsheet.AddCell(new SimpleCell("TransactionTax"), 5, rowNum);
            spreadsheet.AddCell(new SimpleCell("Buy/Sell/CustomBuy"), 6, rowNum);
            spreadsheet.AddCell(new SimpleCell("Unit Cost"), 7, rowNum);
            spreadsheet.AddCell(new SimpleCell("Cost per run"), 8, rowNum);
            spreadsheet.AddCell(new SimpleCell("Total cost"), 9, rowNum);
            spreadsheet.AddCell(new SimpleCell("(Needed)"), 10, rowNum);

            var t1BP = new T1Blueprint(CommonQueries.GetBlueprintFromProduct(CommonQueries.GetT1VersionOfT2(bp.Product)), 0, 0);

            // TODO: too much copy&paste between this and ManufacturingSpreadsheet
            // TODO: brokerFee

            rowNum++;
            Cell topUnitCost = null, bottomUnitCost = null;
            Cell topCostPerRun = null, bottomCostPerRun = null;
            Cell topTotalCost = null, bottomTotalCost = null;
            var  mats = t1BP.InventionMaterials.Union(decryptor != null ? new[] { new BPMaterial(decryptor.MaterialID, 1) } : Enumerable.Empty <BPMaterial>());

            foreach (var mat in mats)
            {
                spreadsheet.AddCell(new SimpleCell(CommonQueries.GetTypeName(mat.matID)), 0, rowNum);
                var matQty   = spreadsheet.AddCell(new SimpleCell("=" + mat.quantity.ToString() + "*" + mat.damagePerJob.ToString()), 1, rowNum);
                var buy      = spreadsheet.AddCell(new EveCentralCell(mat.matID, type: PriceType.buy, measure: PriceMeasure.max), 2, rowNum);
                var sell     = spreadsheet.AddCell(new EveCentralCell(mat.matID, type: PriceType.sell, measure: PriceMeasure.min), 3, rowNum);
                var bfAmount = spreadsheet.AddCell(new FormulaCell("={0}*0.01", /*brokerFee, */ buy), 4, rowNum);
                // 5 empty
                var buysell = spreadsheet.AddCell(new SimpleCell("Sell"), 6, rowNum);

                var unitCost = spreadsheet.AddCell(new FormulaCell("=if({0}=\"Sell\",{1},if({0}=\"Buy\",{2}+{3},{0}+{3}))", buysell, sell, buy, /*brokerFee*/ bfAmount), 7, rowNum);
                bottomUnitCost = unitCost; topUnitCost = topUnitCost ?? unitCost;

                var costPerRun = spreadsheet.AddCell(new FormulaCell("={0}*{1}", unitCost, matQty), 8, rowNum);
                bottomCostPerRun = costPerRun; topCostPerRun = topCostPerRun ?? bottomCostPerRun;

                var totalCost = spreadsheet.AddCell(new FormulaCell("={0}", costPerRun), 9, rowNum);
                bottomTotalCost = totalCost; topTotalCost = topTotalCost ?? totalCost;

                rowNum++;
            }

            spreadsheet.AddCell(new SimpleCell(CommonQueries.GetTypeName(t1BP.InventionInterface)), 0, rowNum);
            spreadsheet.AddCell(new SimpleCell("0"), 1, rowNum);
            spreadsheet.AddCell(new EveCentralCell(t1BP.InventionInterface, type: PriceType.buy, measure: PriceMeasure.max), 2, rowNum);
            spreadsheet.AddCell(new EveCentralCell(t1BP.InventionInterface, type: PriceType.sell, measure: PriceMeasure.min), 3, rowNum);

            // todo:  meta items

            rowNum++;

            var totalUnitCost   = spreadsheet.AddCell(new FormulaCell("=SUM({0}:{1})", topUnitCost, bottomUnitCost), 7, rowNum);
            var totalCostPerRun = spreadsheet.AddCell(new FormulaCell("=SUM({0}:{1})", topCostPerRun, bottomCostPerRun), 8, rowNum);
            var totalTotalCost  = spreadsheet.AddCell(new FormulaCell("=SUM({0}:{1})", topTotalCost, bottomTotalCost), 9, rowNum);

            rowNum += 2;

            spreadsheet.AddCell(new SimpleCell("Datacore 1 skill"), 0, rowNum);
            var d1Skill = spreadsheet.AddCell(new SimpleCell("4"), 1, rowNum);

            rowNum++;
            spreadsheet.AddCell(new SimpleCell("Datacore 2 skill"), 0, rowNum);
            var d2Skill = spreadsheet.AddCell(new SimpleCell("4"), 1, rowNum);

            rowNum++;
            spreadsheet.AddCell(new SimpleCell("Interface skill"), 0, rowNum);
            var intSkill = spreadsheet.AddCell(new SimpleCell("4"), 1, rowNum);

            rowNum++;
            spreadsheet.AddCell(new SimpleCell("Decryptor modifier"), 0, rowNum);
            var decMod = spreadsheet.AddCell(new SimpleCell(decryptor != null ? decryptor.InventionMod.ToString() : "1"), 1, rowNum);

            rowNum++;
            spreadsheet.AddCell(new SimpleCell("Invention chance"), 0, rowNum);
            var invChance = spreadsheet.AddCell(new FormulaCell("=" + t1BP.BaseInventionChance() + "*(1+0.01*{0})*(1+({1}+{2})*(0.1/5-0))*{3}", intSkill, d1Skill, d2Skill, decMod), 1, rowNum);

            rowNum++;

            spreadsheet.AddCell(new SimpleCell("Cost per BP"), 0, rowNum);
            var costPerBP = spreadsheet.AddCell(new FormulaCell("={0}/{1}", totalTotalCost, invChance), 1, rowNum);

            rowNum++;

            int outputruns;
            var invResult = decryptor != null?t1BP.GetInventionResult(out outputruns, MLmod : decryptor.MlResult, PLmod : decryptor.PlResult, runsMod : decryptor.RunsMod, outputName : CommonQueries.GetTypeName(bp.Product))
                                : t1BP.GetInventionResult(out outputruns, outputName: CommonQueries.GetTypeName(bp.Product));

            spreadsheet.AddCell(new SimpleCell("Cost per unit"), 0, rowNum);
            var costPerUnit = spreadsheet.AddCell(new FormulaCell("={0}/" + outputruns, costPerBP), 1, rowNum);

            rowNum += 2;

            ManufacturingSpreadsheet.Create <TSpreadsheet>(invResult, rowNum, spreadsheet, costPerUnit);

            rowNum = spreadsheet.Height + 1;
            spreadsheet.AddCell(new SimpleCell("Copying time p/u: "), 0, rowNum);
            spreadsheet.AddCell(new SimpleCell((t1BP.CopyTime() / outputruns).FormatSeconds()), 1, rowNum);
            spreadsheet.AddCell(new SimpleCell((t1BP.CopyTime() / outputruns).ToString()), 2, rowNum);
            rowNum++;

            spreadsheet.AddCell(new SimpleCell("Invention time p/u: "), 0, rowNum);
            spreadsheet.AddCell(new SimpleCell((t1BP.InventionTime() / outputruns).FormatSeconds()), 1, rowNum);
            spreadsheet.AddCell(new SimpleCell((t1BP.InventionTime() / outputruns).ToString()), 2, rowNum);

            return(spreadsheet);
        }
Пример #3
0
        public static TSpreadsheet Create <TSpreadsheet>(IBlueprint bp, int rowNum = 0, TSpreadsheet existing = null, Cell blueprintCost = null, int numToMake = 1) where TSpreadsheet : class, Spreadsheet, new()
        {
            var spreadsheet = existing ?? new TSpreadsheet();

            spreadsheet.AddCell(new SimpleCell(CommonQueries.GetTypeName(bp.Product)), 0, rowNum);
            var quantity = new SimpleCell(numToMake.ToString());

            var brokerFee      = new SimpleCell("0.0045");
            var transactionTax = new SimpleCell("0.0105");

            rowNum++;

            spreadsheet.AddCell(new SimpleCell("Quantity"), 1, rowNum);
            spreadsheet.AddCell(new SimpleCell("Buy"), 2, rowNum);
            spreadsheet.AddCell(new SimpleCell("Sell"), 3, rowNum);
            spreadsheet.AddCell(new SimpleCell("BrokerFee"), 4, rowNum);
            spreadsheet.AddCell(new SimpleCell("TransactionTax"), 5, rowNum);
            spreadsheet.AddCell(new SimpleCell("Buy/Sell/CustomBuy"), 6, rowNum);
            spreadsheet.AddCell(new SimpleCell("Unit Cost"), 7, rowNum);
            spreadsheet.AddCell(new SimpleCell("Cost per run"), 8, rowNum);
            spreadsheet.AddCell(new SimpleCell("Total cost"), 9, rowNum);
            spreadsheet.AddCell(new SimpleCell("(Needed)"), 10, rowNum);

            rowNum++;
            Cell topUnitCost = null, bottomUnitCost = null;
            Cell topCostPerRun = null, bottomCostPerRun = null;
            Cell topTotalCost = null, bottomTotalCost = null;

            foreach (var mat in bp.Materials)
            {
                spreadsheet.AddCell(new SimpleCell(CommonQueries.GetTypeName(mat.matID)), 0, rowNum);
                var matQty = spreadsheet.AddCell(new SimpleCell("=" + mat.quantity.ToString() + "*" + mat.damagePerJob.ToString()), 1, rowNum);

                var buy      = spreadsheet.AddCell(new EveCentralCell(mat.matID, type: PriceType.buy, measure: PriceMeasure.max), 2, rowNum);
                var sell     = spreadsheet.AddCell(new EveCentralCell(mat.matID, type: PriceType.sell, measure: PriceMeasure.min), 3, rowNum);
                var bfAmount = spreadsheet.AddCell(new FormulaCell("={0}*{1}", brokerFee, buy), 4, rowNum);
                // 5 empty
                var buysell = spreadsheet.AddCell(new SimpleCell("Sell"), 6, rowNum);

                var unitCost = spreadsheet.AddCell(new FormulaCell("=if({0}=\"Sell\",{1},if({0}=\"Buy\",{2}+{3},{0}+{3}))", buysell, sell, buy, bfAmount), 7, rowNum);

                bottomUnitCost = unitCost; topUnitCost = topUnitCost ?? unitCost;

                var costPerRun = spreadsheet.AddCell(new FormulaCell("={0}*{1}", unitCost, matQty), 8, rowNum);
                bottomCostPerRun = costPerRun; topCostPerRun = topCostPerRun ?? bottomCostPerRun;

                var totalCost = spreadsheet.AddCell(new FormulaCell("={0}*{1}", costPerRun, quantity), 9, rowNum);
                bottomTotalCost = totalCost; topTotalCost = topTotalCost ?? totalCost;

                var needed = spreadsheet.AddCell(new FormulaCell("={0}*{1}", matQty, quantity), 10, rowNum);

                rowNum++;
            }

            if (blueprintCost != null)
            {
                spreadsheet.AddCell(new SimpleCell("Blueprint (per unit)"), 0, rowNum);
                var costPerRun = spreadsheet.AddCell(new FormulaCell("={0}", blueprintCost), 8, rowNum);
                bottomCostPerRun = costPerRun; topCostPerRun = topCostPerRun ?? bottomCostPerRun;

                var totalCost = spreadsheet.AddCell(new FormulaCell("={0}*{1}", costPerRun, quantity), 9, rowNum);
                bottomTotalCost = totalCost; topTotalCost = topTotalCost ?? totalCost;

                rowNum++;
            }

            var totalUnitCost   = spreadsheet.AddCell(new FormulaCell("=SUM({0}:{1})", topUnitCost, bottomUnitCost), 7, rowNum);
            var totalCostPerRun = spreadsheet.AddCell(new FormulaCell("=SUM({0}:{1})", topCostPerRun, bottomCostPerRun), 8, rowNum);
            var totalTotalCost  = spreadsheet.AddCell(new FormulaCell("=SUM({0}:{1})", topTotalCost, bottomTotalCost), 9, rowNum);

            rowNum += 2;

            spreadsheet.AddCell(new SimpleCell("Buy/Sell/CustomSell"), 6, rowNum);
            spreadsheet.AddCell(new SimpleCell("Unit Value"), 7, rowNum);
            spreadsheet.AddCell(new SimpleCell("Total Value"), 9, rowNum);

            rowNum++;
            spreadsheet.AddCell(new SimpleCell(CommonQueries.GetTypeName(bp.Product)), 0, rowNum);
            var prodBuy  = spreadsheet.AddCell(new EveCentralCell(bp.Product, type: PriceType.buy, measure: PriceMeasure.max), 2, rowNum);
            var prodSell = spreadsheet.AddCell(new EveCentralCell(bp.Product, type: PriceType.sell, measure: PriceMeasure.min), 3, rowNum);
            // 4 empty
            var ttAmount    = spreadsheet.AddCell(new FormulaCell("={0}*{1}", prodSell, transactionTax), 5, rowNum);
            var prodBuySell = spreadsheet.AddCell(new SimpleCell("Sell"), 6, rowNum);
            var prodValue   = spreadsheet.AddCell(new FormulaCell("=if({0}=\"Sell\",{1}-{3},if({0}=\"Buy\",{2},{0}-{3}))", prodBuySell, prodSell, prodBuy, ttAmount), 7, rowNum);
            var totalValue  = spreadsheet.AddCell(new FormulaCell("={0}*{1}", prodValue, quantity), 9, rowNum);

            rowNum += 2;
            spreadsheet.AddCell(new SimpleCell("Profit"), 9, rowNum);
            spreadsheet.AddCell(new SimpleCell("Margin"), 10, rowNum);

            rowNum++;
            var profit = spreadsheet.AddCell(new FormulaCell("={0}-{1}", totalValue, totalTotalCost), 9, rowNum);

            spreadsheet.AddCell(new FormulaCell("={0}/{1}", profit, totalValue), 10, rowNum);

            rowNum--;

            spreadsheet.AddCell(new SimpleCell("Number of runs: "), 0, rowNum);
            spreadsheet.AddCell(quantity, 1, rowNum);
            rowNum++;
            spreadsheet.AddCell(new SimpleCell("Broker fee: "), 0, rowNum);
            spreadsheet.AddCell(brokerFee, 1, rowNum);
            rowNum++;
            spreadsheet.AddCell(new SimpleCell("Transaction tax: "), 0, rowNum);
            spreadsheet.AddCell(transactionTax, 1, rowNum);
            rowNum++;
            spreadsheet.AddCell(new SimpleCell("Production time: "), 0, rowNum);
            spreadsheet.AddCell(new SimpleCell(bp.ManufacturingTime().FormatSeconds()), 1, rowNum);
            var mt = spreadsheet.AddCell(new SimpleCell(bp.ManufacturingTime().ToString()), 2, rowNum);

            return(spreadsheet);
        }
Пример #4
0
        public override string Format(object input)
        {
            var typeId = new TypeID(input.ToInt());

            return(CommonQueries.GetTypeName(typeId));
        }
Пример #5
0
        public static MaterialID GetT2VersionOfT1(MaterialID matID, string outputName = null)
        {
            var result = GetMetaGroupVersionOfT1(matID, 2); // note metaGroup not metaLevel

            return(result.FirstOrDefault(r => outputName != null ? CommonQueries.GetTypeName(r) == outputName : true));
        }