Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions darkstat/configs_export/routes_trades.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,16 @@ func NewTradeRoute(g *GraphResults, buying_good *MarketGood, selling_good *Marke

return route
}

func (t *TradeRoute) GetProffitVolume() float64 {
profit_v_t := GetProffitPerTime(t.Route.g, t.BuyingGood, t.SellingGood)
time_s := GetTimeS(t.Route.g, t.BuyingGood, t.SellingGood)
kilo_volume := KiloVolumesDeliverable(t.BuyingGood, t.SellingGood)
kilo_volume = math.Min(kilo_volume, 50)
if time_s == 0 || time_s > float64(trades.INF/2) {
return 0
}
return profit_v_t * time_s * kilo_volume
}
func (t *TradeRoute) GetProffitPerTime() float64 {
return GetProffitPerTime(t.Route.g, t.BuyingGood, t.SellingGood)
}
Expand Down Expand Up @@ -99,7 +108,7 @@ func NewTradePathExporter(

func (e *TradePathExporter) GetBaseTradePathsFiltered(TradeRoutes []*ComboTradeRoute) []*ComboTradeRoute {
sort.Slice(TradeRoutes, func(i, j int) bool {
return TradeRoutes[i].Transport.GetProffitPerTime() > TradeRoutes[j].Transport.GetProffitPerTime()
return TradeRoutes[i].Transport.GetProffitVolume() > TradeRoutes[j].Transport.GetProffitVolume()
})
return TradeRoutes
}
Expand Down Expand Up @@ -148,7 +157,7 @@ func (e *TradePathExporter) GetBaseTradePathsFrom(ctx context.Context, base *Bas
return
}
kilo_volumes := KiloVolumesDeliverable(buying_good, selling_good_at_base)
if kilo_volumes < 5 {
if kilo_volumes <= 0.01 {
return
}
TradeRoutes = append(TradeRoutes, trade_route)
Expand Down Expand Up @@ -198,7 +207,7 @@ func (e *TradePathExporter) GetBaseTradePathsTo(ctx context.Context, base *Base)
return
}
kilo_volumes := KiloVolumesDeliverable(buying_good, selling_good)
if kilo_volumes < 5 {
if kilo_volumes <= 0.01 {
return
}
TradeRoutes = append(TradeRoutes, trade_route)
Expand Down Expand Up @@ -298,6 +307,7 @@ func (e *TradePathExporter) GetBestTradeDeals(ctx context.Context, bases []*Base

type BaseBestPathTimes struct {
TransportProfitPerTime *float64
TransportProfitVolume *float64
FrigateProfitPerTime *float64
FreighterProfitPerTime *float64
}
Expand Down Expand Up @@ -336,14 +346,17 @@ func (e *TradePathExporter) GetBaseBestPathFrom(ctx context.Context, base *Base)
}

kilo_volumes := KiloVolumesDeliverable(buying_good, selling_good)
if kilo_volumes < 5 {
kilo_volumes = math.Min(kilo_volumes, 50)
if kilo_volumes <= 0.01 {
return
}

if result.TransportProfitPerTime == nil {
result.TransportProfitPerTime = ptr.Ptr(TransportProfitPerTime)
result.TransportProfitVolume = ptr.Ptr(TransportProfitPerTime * time_s * kilo_volumes)
} else if TransportProfitPerTime > *result.TransportProfitPerTime {
result.TransportProfitPerTime = ptr.Ptr(TransportProfitPerTime)
result.TransportProfitVolume = ptr.Ptr(TransportProfitPerTime * time_s * kilo_volumes)
}

if result.FrigateProfitPerTime == nil {
Expand Down Expand Up @@ -401,14 +414,17 @@ func (e *TradePathExporter) GetBaseBestPathTo(ctx context.Context, base *Base) *
}

kilo_volumes := KiloVolumesDeliverable(buying_good, selling_good)
if kilo_volumes < 5 {
kilo_volumes = math.Min(kilo_volumes, 50)
if kilo_volumes <= 0.01 {
return
}

if result.TransportProfitPerTime == nil {
result.TransportProfitPerTime = ptr.Ptr(TransportProfitPerTime)
result.TransportProfitVolume = ptr.Ptr(TransportProfitPerTime * time_s * kilo_volumes)
} else if TransportProfitPerTime > *result.TransportProfitPerTime {
result.TransportProfitPerTime = ptr.Ptr(TransportProfitPerTime)
result.TransportProfitVolume = ptr.Ptr(TransportProfitPerTime * time_s * kilo_volumes)
}

if result.FrigateProfitPerTime == nil {
Expand Down
14 changes: 14 additions & 0 deletions darkstat/front/bases.templ
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ templ BasesTable(
</th>
}
if tab_mode == BaseTabTradesFrom || tab_mode == BaseTabTradesTo || tab_mode == BaseTabOres {
<th style="width:50px;">
@frmt.MultiLinestring([]string{"Best", "Transport", "profit", "volume"})
</th>
<th style="width:50px;">
@frmt.MultiLinestring([]string{"Best", "Transport", "profit/v", "¢/sec"})
</th>
Expand Down Expand Up @@ -288,6 +291,13 @@ templ BaseRow(base *configs_export.Base, tab_mode BaseMode, pinm tab.PinMod, sha
}
}
if routes != nil {
<td>
if routes.TransportProfitVolume != nil {
{ fmt.Sprintf("%2.0f", *routes.TransportProfitVolume * 1000) }
} else {
0
}
</td>
<td
class="route_transport"
>
Expand Down Expand Up @@ -667,6 +677,9 @@ templ BaseTradesShared(shared *types.SharedData, tab_mode BaseMode) {
<thead>
<tr class="flexed-tr">
<th style="width:200px;">Commodity</th>
<th style="width:50px;">
@frmt.MultiLinestring([]string{"Transport", "Profit", "volume"})
</th>
<th style="width:50px;">
@frmt.MultiLinestring([]string{"Transport", "Profit/v/t", "¢ents/sec"})
</th>
Expand Down Expand Up @@ -798,6 +811,7 @@ templ TradeRouteRow(trade_route *configs_export.ComboTradeRoute, shared *types.S
{ trade_route.Transport.SellingGood.Name + frmt.FormattedShipClassOfCommodity(trade_route.Transport.SellingGood.ShipClass) }
}
</td>
<td>{ fmt.Sprintf("%.0f", trade_route.Transport.GetProffitVolume() * 1000) }</td>
<td class="route_transport">{ fmt.Sprintf("%.2f", trade_route.Transport.GetProffitPerTime() * 100) }</td>
if shared.ShowDisco {
<td class="route_frigate">{ fmt.Sprintf("%.2f", trade_route.Frigate.GetProffitPerTime() * 100) }</td>
Expand Down