public RawMaterialTableBuilder(db.Db dataBase, calculator.T2Builder t2builder, Market.Market market, StreamWriter sw, string tableName, ApiImport.MainImport import) { var office = import.ESIbuildCorpAssets.GetContainer(1022964286749); long[,] materials = new long[1, 1]; if (tableName == "Minerals") { materials = t2builder.GetGroup(4); } else if (tableName == "Planetary Interaction") { materials = t2builder.GetGroup(2); } else if (tableName == "Advanced Materials") { materials = t2builder.GetGroup(6); } string[] names = new string[materials.Length / 2]; int i = 0; while (i < names.Length) { names[i] = dataBase.types.TypeName(materials[i, 0]); i++; } sw.WriteLine("<table>"); sw.WriteLine("<caption><b>" + tableName + "</b></caption>"); sw.WriteLine("<tr><td>Name</td><td>Needed</td><td>Have</td><td>Lacking</td><td>Value</td></tr>"); i = 0; decimal totalValue = 0; while (i < names.Length) { long need = materials[i, 1]; long have = office.FindItem(Convert.ToInt32(materials[i, 0])); long lacking; decimal value = 0; if (have - need >= 0) { lacking = 0; } else { lacking = need - have; value = market.FindPrice("the forge", "buy", materials[i, 0]) * lacking; totalValue += value; } sw.WriteLine("<tr><td>" + names[i] + "</td><td>" + string.Format("{0:n0}", need) + "</td><td>" + string.Format("{0:n0}", have) + "</td><td>" + string.Format("{0:n0}", lacking) + "</td><td>" + string.Format("{0:n0}", value) + "</td></tr>"); i++; } sw.WriteLine("<tr><td><b>Sum</b></td><td></td><td><b>" + null + "</b></td><td><b>" + null + "</b></td><td><b>" + string.Format("{0:n0}", totalValue) + "</b></td></tr>"); sw.WriteLine("</table>"); }
public Output(calculator.T2Builder t2mods, db.Db dataBase, Market.Market market, ApiImport.MainImport import) { StreamReader sr; using (StreamWriter sw = new StreamWriter("moduleNumbers.html")) { using (sr = new StreamReader("files\\htmloutputone.txt")) { sw.WriteLine(sr.ReadToEnd()); OutputTableBuilder otb = new OutputTableBuilder(dataBase, t2mods, sw, "T2Modules(and ships)"); IntermediaryTableBuilder itb = new IntermediaryTableBuilder(dataBase, t2mods, sw, "T2Components", import, market); itb = new IntermediaryTableBuilder(dataBase, t2mods, sw, "T1modules", import, market); itb = new IntermediaryTableBuilder(dataBase, t2mods, sw, "T1ships", import, market); itb = new IntermediaryTableBuilder(dataBase, t2mods, sw, "Tools", import, market); RawMaterialTableBuilder rmtb = new RawMaterialTableBuilder(dataBase, t2mods, market, sw, "Minerals", import); rmtb = new RawMaterialTableBuilder(dataBase, t2mods, market, sw, "Planetary Interaction", import); rmtb = new RawMaterialTableBuilder(dataBase, t2mods, market, sw, "Advanced Materials", import); } using (sr = new StreamReader("files\\htmloutputtwo.txt")) sw.WriteLine(sr.ReadToEnd()); sw.Close(); } System.Diagnostics.Process.Start(@"moduleNumbers.html"); new MarketInfo(dataBase, t2mods, import, market); }
public T2Builder(db.Db dataBase_, Market.Market market) : base(market, dataBase_) { this.market = market; t1Modules = new long[256, 2]; // categoryid=7 t1ships = new long[256, 2]; // categoryid=6 planetaryComodities = new long[256, 2]; // categoryid=43 tools = new long[256, 2]; // groupid=332 minerals = new long[256, 2]; // groupid=18 constructionComponents = new long[256, 2]; // groupid=334 compopsites = new long[256, 2]; // groupip=429 dataBase = dataBase_; moduleMats = new int[dataBase.t2bpoOwned.Index()][, ]; moduleAmounts = new int[dataBase.t2bpoOwned.Index()]; output = new int[dataBase.t2bpoOwned.Index(), 2]; outputName = new string[dataBase.t2bpoOwned.Index()]; outputTotalValue = new decimal[dataBase.t2bpoOwned.Index()]; outputTotalCost = new decimal[dataBase.t2bpoOwned.Index()]; int i = 0; while (i < dataBase.t2bpoOwned.Index()) // adds amounts { int bpoid = dataBase.t2bpoOwned.Bpo(i); moduleAmounts[i] = GetBuildAmount(bpoid); moduleMats[i] = dataBase.bpo.ManufacturingMats(bpoid); materialModifier = MaterialModifier(); int[,] bpoOutput = dataBase.bpo.ManufacturingOutput(bpoid); output[i, 0] = bpoOutput[0, 0]; output[i, 1] = bpoOutput[0, 1] * moduleAmounts[i]; outputName[i] = dataBase.types.TypeName(output[i, 0]); outputTotalValue[i] = output[i, 1] * market.FindPrice(dataBase.settings.MarketRegion, "sell", output[i, 0]); int j = 0; while (j < (moduleMats[i].Length / 2)) { if (moduleMats[i][j, 1] == 1) { moduleMats[i][j, 1] = Convert.ToInt32(Math.Ceiling(moduleMats[i][j, 1] * moduleAmounts[i] * 1.0)); } else { moduleMats[i][j, 1] = Convert.ToInt32(Math.Ceiling(moduleMats[i][j, 1] * moduleAmounts[i] * materialModifier)); } j++; } //test variable decimal installcost = FindInstallCost(bpoid) * moduleAmounts[i]; outputTotalCost[i] = SortMaterials(moduleMats[i]) + installcost; i++; } TotalModuleMaterials(); }
public Market(db.Db dataBase) { ESIcostIndices = StaticInfo.ESIImportCrawl <ESI.CostIndice>("/industry/systems/", pageSize: 10000); Console.WriteLine("....Done getting cost indices"); ESImarketPrices = StaticInfo.ESIImportCrawl <ESI.MarketPrice>("/markets/prices/", pageSize: 20000); Console.WriteLine("....Done getting estimated prices"); this.dataBase = dataBase; region[0] = new Region(10000002); // the forge/jita //region[1] = new Region(10000060); // delve }
internal static decimal GetBuildCostIndex(this List <CostIndice> indices, db.Db dataBase) { foreach (var indice in indices) { if (indice.solar_system_id == dataBase.settings.ProductionSystem) { return(indice.manufacturing); } } return(0); }
/// <summary> /// takes a typeID and returns the amount of items being produced currently /// </summary> /// <param name="typeID"></param> /// <returns></returns> internal static int GetJobs(this List <IndustryJob> jobs, int typeID, db.Db dataBase) { int totalRuns = 0; foreach (var job in jobs) { if (job.product_type_id == typeID) { totalRuns += job.runs; } } int[,] bpoOutput = dataBase.bpo.ManufacturingOutput(dataBase.bpo.FindBpoTypeIdForItem(typeID)); return(totalRuns * bpoOutput[0, 1]); }
public IntermediateBuilder(long[,] buildlist, db.Db data, string rigGroup, Market.Market market) : base(market, data) { this.market = market; rigTypeUsed = rigGroup; dataBase = data; int i = 0; moduleMats = new long[buildlist.Length / 2][, ]; while (i < (buildlist.Length / 2)) { // buildlist[i, 0] = FindBpoTypeIdForItem(Convert.ToInt32(buildlist[i, 0])); i++; } moduleMats = GetMaterialBill(buildlist); totalMats = TotalModuleMaterials(moduleMats); costOfMats = FindCosts(totalMats); }
public OutputTableBuilder(db.Db dataBase, calculator.T2Builder t2builder, StreamWriter sw, string tableName) { string[] name = t2builder.OutputName; int[,] output = t2builder.Output; decimal[] totalCost = t2builder.OutputTotalCost; decimal[] totalValue = t2builder.OutputTotalValue; sw.WriteLine("<table>"); sw.WriteLine("<caption><b>" + tableName + "</b></caption>"); sw.WriteLine("<tr><td>Name</td><td>Amount</td><td>Value</td><td>Cost</td><td>Profit</td><td>Profit/m^3 ratio</td></tr>"); int i = 0; while (i < name.Length) { decimal profit = totalValue[i] - totalCost[i]; decimal profitRatio = profit / (dataBase.types.GetRepackagedVolume(output[i, 0]) * output[i, 1]); sw.WriteLine("<tr><td>" + string.Format("{0:n0}", name[i]) + "</td><td>" + string.Format("{0:n0}", output[i, 1]) + "</td><td>" + string.Format("{0:n0}", totalValue[i]) + "</td><td>" + string.Format("{0:n0}", totalCost[i]) + "</td><td>" + string.Format("{0:n0}", profit) + "</td><td>" + string.Format("{0:n0}", profitRatio) + "</td></tr>"); i++; } decimal valueSum = totalValue.Sum(); decimal costSum = totalCost.Sum(); i = 0; decimal profitSum = 0; while (i < name.Length) { if ((totalValue[i] - totalCost[i]) > 0) { profitSum += totalValue[i] - totalCost[i]; } i++; } sw.WriteLine("<tr><td><b>Sum</b></td><td></td><td><b>" + string.Format("{0:n0}", valueSum) + "</b></td><td><b>" + string.Format("{0:n0}", costSum) + "</b></td><td><b>" + string.Format("{0:n0}", profitSum) + "</b></td></b><td></td></tr>"); sw.WriteLine("</table>"); }
int[,] compopsites; //advanced materials public Calculator() { Console.WriteLine("..Loading the database..."); dataBase = new db.Db(); Console.WriteLine("..Done loading the database"); Console.WriteLine("..Authenticating with SSO..."); new ESI.Login(ESI.CharacterEnum.BuildCorp); new ESI.Login(ESI.CharacterEnum.EmpireDonkey); Console.WriteLine("..Done authenticating"); Console.WriteLine("..Importing API's..."); apiImports = new ApiImport.MainImport(); Console.WriteLine("..Done importing API's"); Console.WriteLine("..Generating the market Class..."); market = new Market.Market(dataBase); Console.WriteLine("..Done generating the market class"); Console.WriteLine("..Calculates t2 production..."); T2Builder t2mods = new T2Builder(dataBase, market); Console.WriteLine("..Done calculating t2 production"); Console.WriteLine("..Generates output files..."); Output.Output output = new Output.Output(t2mods, dataBase, market, apiImports); Console.WriteLine("..Done generating output files"); }
public MarketInfo(db.Db dataBase, calculator.T2Builder t2mods, ApiImport.MainImport import, Market.Market market) { using (StreamWriter sw = new StreamWriter("marketInfo.txt")) { var office = import.ESIbuildCorpAssets.GetContainer(1022964286749); int i = 0; sw.WriteLine("Name" + "\t" + "Buildcost" + "\t" + "Haulingcost" + "\t" + "Market sell" + "\t" + "Amount on market" + "\t" + "Stock in xanadu" + "\t" + "Stock in chanuur" + "\t" + "Order price" + "\t" + "Avg daily volume" + "\t" + "Item category" + "\t" + "Max output"); while (i < t2mods.OutputName.Length) { decimal itemCost = t2mods.OutputTotalCost[i] / t2mods.Output[i, 1]; decimal haulingCost = dataBase.types.GetRepackagedVolume(t2mods.Output[i, 0]) * 800; decimal marketSell = market.FindPrice(dataBase.settings.MarketRegion, "sell", t2mods.Output[i, 0]); decimal sellOrderPrize = import.ESIcorpMarketOrders.SellOrderPrice(t2mods.Output[i, 0]); sw.WriteLine( t2mods.OutputName[i] //name + "\t" + itemCost.ToString(StaticInfo.ci) //cost per item + "\t" + haulingCost.ToString(StaticInfo.ci) // hauling cost per item (800 is ITL's price per m3 from delve to jita, hardcoding it because im lazy + "\t" + marketSell.ToString(StaticInfo.ci) // gets the sale value of the item + "\t" + import.ESIcorpMarketOrders.ItemsOnMarket(t2mods.Output[i, 0]) //amount we have on the market + "\t" + import.ESIempireDonkey.FindItem(t2mods.Output[i, 0]) // amount on Reluah + "\t" + office.FindItem(t2mods.Output[i, 0]) // ammount on chanuur + "\t" + sellOrderPrize.ToString(StaticInfo.ci) // value of our sell order + "\t" + market.FindAverageVolume(dataBase.settings.MarketRegion, t2mods.Output[i, 0], 30) // average volume sold per day(last 30 days) + "\t" + dataBase.categoryIDs.GetName(dataBase.groupIDs.CategoryID(dataBase.types.GroupID(t2mods.Output[i, 0])), 0) // items category + "\t" + t2mods.Output[i, 1] //amount of items produced per cycle ); i++; } sw.WriteLine("market orders cached until" + "\t" + import.ESIcorpMarketOrders.CachedUntil); sw.WriteLine("build corp assets cached until" + "\t" + import.ESIbuildCorpAssets.CachedUntil); sw.WriteLine("empire donkey corp assets cached until" + "\t" + import.ESIempireDonkey.CachedUntil); sw.Close(); } System.Diagnostics.Process.Start(@"marketInfo.txt"); }
protected long[,] compopsites; //advanced materials public ProductionMethods(Market.Market market, db.Db dataBase) { this.dataBase = dataBase; this.market = market; }
public IntermediaryTableBuilder(db.Db dataBase, calculator.T2Builder t2builder, StreamWriter sw, string tableName, ApiImport.MainImport import, Market.Market market) { var office = import.ESIbuildCorpAssets.GetContainer(1022964286749); long[,] materials = new long[1, 1]; if (tableName == "T2Components") { materials = t2builder.GetGroup(5); } else if (tableName == "T1modules") { materials = t2builder.GetGroup(0); } else if (tableName == "T1ships") { materials = t2builder.GetGroup(1); } else if (tableName == "Tools") { materials = t2builder.GetGroup(3); } string[] names = new string[materials.Length / 2]; int i = 0; while (i < names.Length) { names[i] = dataBase.types.TypeName(materials[i, 0]); i++; } sw.WriteLine("<table>"); sw.WriteLine("<caption><b>" + tableName + "</b></caption>"); sw.WriteLine("<tr><td>Name</td><td>Needed</td><td>Have</td><td>Building</td><td>Lacking</td><td>Value</td></tr>"); i = 0; decimal totalValue = 0; while (i < names.Length) { long need = materials[i, 1]; long have = office.FindItem(Convert.ToInt32(materials[i, 0])); long building = import.ESIjobs.GetJobs(Convert.ToInt32(materials[i, 0]), dataBase); long lacking; if ((have + building) - need >= 0) { lacking = 0; } else { lacking = need - building - have; } decimal value = market.FindPrice("the forge", "buy", materials[i, 0]) * lacking; totalValue += value; sw.WriteLine("<tr><td>" + names[i] + "</td><td>" + string.Format("{0:n0}", need) + "</td><td>" + string.Format("{0:n0}", have) + "</td><td>" + string.Format("{0:n0}", building) + "</td><td>" + string.Format("{0:n0}", lacking) + "</td><td>" + string.Format("{0:n0}", value) + "</td></tr>"); i++; } sw.WriteLine("<tr><td><b>Sum</b></td><td>" + null + "</td><td>" + null + "</td><td>" + null + "</td><td>" + null + "</td><td><b>" + string.Format("{0:n0}", totalValue) + "</b></td></tr>"); sw.WriteLine("</table>"); }
internal static int GetJobs(this ESIResponse <List <IndustryJob> > response, int typeID, db.Db dataBase) { return(response.Result.GetJobs(typeID, dataBase)); }
internal static decimal GetBuildCostIndex(this ESIResponse <List <CostIndice> > response, db.Db dataBase) { return(response.Result.GetBuildCostIndex(dataBase)); }