public SingleTripDisplayItem(Map map, SingleTrip data, Parameters parameters) { Text = data.TypeName; profit = (int)data.Profit; int profitPercentage = (profit * 100) / (int)parameters.Isk; SolarSystem startingSystem = map.GetSystem(parameters.StartingSystem); if (startingSystem == null) { profitPerWarp = (int)data.ProfitPerWarp(true); } else { data.StartingSystem = startingSystem; profitPerWarp = (int)data.ProfitPerWarpFromStartingSystem(true); } int jumpsFromStart = map.DistanceBetween(startingSystem, data.Source.System, true); int jumps = data.Jumps(true); string source = data.Source.Name; string destination = data.Destination.Name; SecurityStatus.Level security = data.Security; LimitingFactor limitedBy = data.LimitedBy; SubItems.Add(profitPerWarp.ToString()); SubItems.Add(profitPercentage + "%"); SubItems.Add(security.ToString()); SubItems.Add(jumpsFromStart.ToString()); SubItems.Add(jumps.ToString()); SubItems.Add(source); SubItems.Add(destination); SubItems.Add(limitedBy.ToString()); }
internal SingleTrip GetBestTrade(Station source, Station destination, TransactionList tradeList) { SingleTrip trade = new SingleTrip(map, source, destination); float iskLeft = parameters.Isk; float cargoSpaceLeft = parameters.CargoSpace; foreach (Transaction t in tradeList) { Transaction addTransaction = t.GetTransactionByLimits(iskLeft, cargoSpaceLeft); if (addTransaction != null) { iskLeft -= addTransaction.Cost; cargoSpaceLeft -= addTransaction.Volume; trade.AddPurchase(addTransaction); } // We'll break out when isk or cargo is low (but not zero), to prevent looking for filler cargo. if ((cargoSpaceLeft == 3.0f) || (iskLeft == 10.0f)) { break; } } trade.Compress(); return(trade); }
public SingleTripDisplayItem(Map map, SingleTrip data, Parameters parameters) { Text = data.TypeName; profit = (int)data.Profit; int profitPercentage = (profit * 100) / (int)parameters.Isk; SolarSystem startingSystem = map.GetSystem(parameters.StartingSystem); if (startingSystem == null) profitPerWarp = (int)data.ProfitPerWarp(true); else { data.StartingSystem = startingSystem; profitPerWarp = (int)data.ProfitPerWarpFromStartingSystem(true); } int jumpsFromStart = map.DistanceBetween(startingSystem, data.Source.System, true); int jumps = data.Jumps(true); string source = data.Source.Name; string destination = data.Destination.Name; SecurityStatus.Level security = data.Security; LimitingFactor limitedBy = data.LimitedBy; SubItems.Add(profitPerWarp.ToString()); SubItems.Add(profitPercentage + "%"); SubItems.Add(security.ToString()); SubItems.Add(jumpsFromStart.ToString()); SubItems.Add(jumps.ToString()); SubItems.Add(source); SubItems.Add(destination); SubItems.Add(limitedBy.ToString()); }
private void AddRoundTrips() { foreach (SingleTrip trade in singleTrips) { SingleTrip there = trade; SingleTrip backAgain = GetBestSingleTrip(there.Destination, there.Source); RoundTrip trip = new RoundTrip(there, backAgain); roundTrips.Add(trip); } roundTrips.Sort(RoundTrip.CompareByProfitPerWarpSecure); }
private void AddProfitableTrades() { foreach (Station origin in market.StationsWithItemsForSale) { foreach (Station destination in market.StationsWithItemsWanted) { TransactionList profitableTransactions = GetProfitableTransactions(origin, destination); if (profitableTransactions.Count > 0) { profitableTransactions.Sort(TransactionList.DecreasingProfitPerCargo); SingleTrip trip = GetBestTrade(origin, destination, profitableTransactions); if (trip.Profit > 0.0f) { singleTrips.Add(trip); } } } } //singleTrips.Sort(SingleTrip.CompareByProfitPerWarp); }
public string Info(SingleTrip route) { return Info(route, SecurityStatus.Level.HighSec); }
public RoundTrip(SingleTrip there, SingleTrip backAgain) { this.there = there; this.backAgain = backAgain; }
public static int CompareByProfit(SingleTrip a, SingleTrip b) { return b.Profit.CompareTo(a.Profit); // highest profit comes first }
public static int CompareByProfitPerWarpSecure(SingleTrip a, SingleTrip b) { return b.ProfitPerWarp(true).CompareTo(a.ProfitPerWarp(true)); // highest profit per warp comes first }
public static int CompareByProfitPerWarpShortest(SingleTrip a, SingleTrip b) { return b.ProfitPerWarp(false).CompareTo(a.ProfitPerWarp(false)); // highest profit per warp comes first }
public static int CompareByProfitPerWarpFromStartingSystemShortest(SingleTrip a, SingleTrip b) { return b.profitPerWarpFromStartingSystemShortest.CompareTo(a.profitPerWarpFromStartingSystemShortest); // highest profit per warp comes first }
public string Info(SingleTrip route) { return(Info(route, SecurityStatus.Level.HighSec)); }
public static int CompareByProfit(SingleTrip a, SingleTrip b) { return(b.Profit.CompareTo(a.Profit)); // highest profit comes first }
public static int CompareByProfitPerWarpShortest(SingleTrip a, SingleTrip b) { return(b.ProfitPerWarp(false).CompareTo(a.ProfitPerWarp(false))); // highest profit per warp comes first }
public static int CompareByProfitPerWarpFromStartingSystemShortest(SingleTrip a, SingleTrip b) { return(b.profitPerWarpFromStartingSystemShortest.CompareTo(a.profitPerWarpFromStartingSystemShortest)); // highest profit per warp comes first }
internal SingleTrip GetBestTrade(Station source, Station destination, TransactionList tradeList) { SingleTrip trade = new SingleTrip(map, source, destination); float iskLeft = parameters.Isk; float cargoSpaceLeft = parameters.CargoSpace; foreach (Transaction t in tradeList) { Transaction addTransaction = t.GetTransactionByLimits(iskLeft, cargoSpaceLeft); if (addTransaction != null) { iskLeft -= addTransaction.Cost; cargoSpaceLeft -= addTransaction.Volume; trade.AddPurchase(addTransaction); } // We'll break out when isk or cargo is low (but not zero), to prevent looking for filler cargo. if ((cargoSpaceLeft == 3.0f) || (iskLeft == 10.0f)) { break; } } trade.Compress(); return trade; }
public string Info(SingleTrip route, SecurityStatus.Level startingTrip) { SecurityStatus.Level security = SecurityStatus.Min(startingTrip, route.Security); string output; string TradeSec = string.Empty; // todo: this differently int CurPercent = Convert.ToInt32(FormatPercent(route.ProfitMargin).Replace("%", "")); int GreyPercent = 100 - CurPercent; // ^--------------------^ float taxrate = 0.01f - (Convert.ToInt32(input["accounting"]) * 0.001f); switch (security) { case SecurityStatus.Level.LowSecOnly: TradeSec = "<b><font color='#FF0000' size='$fontsz_small' face='$fontname'>Routes through lowsec only!</font></b>"; break; case SecurityStatus.Level.LowSecShortcut: TradeSec = "<font color='#FF0000' size='$fontsz_small' face='$fontname'>Route has lowsec shortcut.</font>"; break; case SecurityStatus.Level.HighSec: TradeSec = "<font color='#00FF00' size='$fontsz_small' face='$fontname'>Routes through highsec only.</font>"; break; case SecurityStatus.Level.Isolated: TradeSec = "</b><font color='#00FF00' size='$fontsz_small' face='$fontname'>Routes within system!</font></b>"; break; } // Bug here :/ if (route.Profit - Variables.Total_Sales * taxrate <= 0) { return(""); } /*{ * if (Constants.IsBetaVersion) * { * return "Strange, a trade that would result in a loss was passed here. Don't report this."; * } * else * { */ // return ""; // } //} output = ReadFromResource("Web_Server.TradePage.html"); // Replace $Identifiers .. output = output.Replace("$TO", Info(route.Destination, route.Source.System)); output = output.Replace("$FROM", Info(route.Source, systemName)); output = output.Replace("$HISK", FormatIsk(route.ProfitPerWarp(true))); output = output.Replace("$LISK", FormatIsk(route.ProfitPerWarp(false))); output = output.Replace("$CURPERCENT", String.Format("{0}", CurPercent)); output = output.Replace("$ENDPERCENT", String.Format("{0}", GreyPercent)); output = output.Replace("$TRADESEC", TradeSec); output = output.Replace("$LISTP", route.ListPurchases()); output = output.Replace("$LISTS", route.ListSales()); output = output.Replace("$CNEED", String.Format("{0:0.##}m3", route.Volume)); output = output.Replace("$RNEED", String.Format("{0:0.##} ISK", route.Cost)); output = output.Replace("$TAXTOTAL", String.Format("{0:0.##} ({1:0.##}%)", Variables.Total_Sales * taxrate, taxrate * 100)); output = output.Replace("$PROFIT", FormatIsk(route.Profit - (Variables.Total_Sales * taxrate)) + " (" + FormatPercent(route.ProfitMargin) + ")"); output = ReplaceVariables(output, null, null, null); return(output); }
public string Info(SingleTrip route, SecurityStatus.Level startingTrip) { SecurityStatus.Level security = SecurityStatus.Min(startingTrip, route.Security); string output; string TradeSec = string.Empty; // todo: this differently int CurPercent = Convert.ToInt32(FormatPercent(route.ProfitMargin).Replace("%", "")); int GreyPercent = 100 - CurPercent; // ^--------------------^ float taxrate = 0.01f - (Convert.ToInt32(input["accounting"]) * 0.001f); switch (security) { case SecurityStatus.Level.LowSecOnly: TradeSec = "<b><font color='#FF0000' size='$fontsz_small' face='$fontname'>Routes through lowsec only!</font></b>"; break; case SecurityStatus.Level.LowSecShortcut: TradeSec = "<font color='#FF0000' size='$fontsz_small' face='$fontname'>Route has lowsec shortcut.</font>"; break; case SecurityStatus.Level.HighSec: TradeSec = "<font color='#00FF00' size='$fontsz_small' face='$fontname'>Routes through highsec only.</font>"; break; case SecurityStatus.Level.Isolated: TradeSec = "</b><font color='#00FF00' size='$fontsz_small' face='$fontname'>Routes within system!</font></b>"; break; } // Bug here :/ if (route.Profit - Variables.Total_Sales * taxrate <= 0) return ""; /*{ if (Constants.IsBetaVersion) { return "Strange, a trade that would result in a loss was passed here. Don't report this."; } else { */ // return ""; // } //} output = ReadFromResource("Web_Server.TradePage.html"); // Replace $Identifiers .. output = output.Replace("$TO", Info(route.Destination, route.Source.System)); output = output.Replace("$FROM", Info(route.Source, systemName)); output = output.Replace("$HISK", FormatIsk(route.ProfitPerWarp(true))); output = output.Replace("$LISK", FormatIsk(route.ProfitPerWarp(false))); output = output.Replace("$CURPERCENT", String.Format("{0}", CurPercent)); output = output.Replace("$ENDPERCENT", String.Format("{0}", GreyPercent)); output = output.Replace("$TRADESEC", TradeSec); output = output.Replace("$LISTP", route.ListPurchases()); output = output.Replace("$LISTS", route.ListSales()); output = output.Replace("$CNEED", String.Format("{0:0.##}m3", route.Volume)); output = output.Replace("$RNEED", String.Format("{0:0.##} ISK", route.Cost)); output = output.Replace("$TAXTOTAL", String.Format("{0:0.##} ({1:0.##}%)", Variables.Total_Sales * taxrate, taxrate * 100)); output = output.Replace("$PROFIT", FormatIsk(route.Profit - (Variables.Total_Sales * taxrate)) + " (" + FormatPercent(route.ProfitMargin) + ")"); output = ReplaceVariables(output, null, null, null); return output; }