Rebuild Soundings around harbor gameplay and guided careers

This commit is contained in:
josh
2026-11-27 21:11:51 -05:00
parent 75afa1c194
commit 4b870fb0ce
30 changed files with 3523 additions and 819 deletions

View File

@@ -1,3 +1,4 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
@@ -8,263 +9,379 @@ namespace Soundings
private int inspectedPort = 1;
private int selectedVoyage;
private bool worldChart;
private float chartScrollPosition;
private static readonly Vector2[][] AtlanticCoastlines =
{
new[]
{
new Vector2(0, 0), new Vector2(.33f, 0), new Vector2(.30f, .09f), new Vector2(.28f, .19f),
new Vector2(.25f, .21f), new Vector2(.26f, .26f), new Vector2(.22f, .31f), new Vector2(.21f, .37f),
new Vector2(.19f, .40f), new Vector2(.18f, .47f), new Vector2(.15f, .51f), new Vector2(.14f, .57f),
new Vector2(.15f, .64f), new Vector2(.13f, .68f), new Vector2(.12f, .64f), new Vector2(.11f, .56f),
new Vector2(.08f, .54f), new Vector2(.06f, .51f), new Vector2(.03f, .55f), new Vector2(0, .51f)
},
new[]
{
new Vector2(.75f, 0), new Vector2(.96f, 0), new Vector2(1, .08f), new Vector2(1, .41f),
new Vector2(.97f, .38f), new Vector2(.93f, .34f), new Vector2(.91f, .30f), new Vector2(.88f, .29f),
new Vector2(.84f, .25f), new Vector2(.85f, .18f), new Vector2(.88f, .16f), new Vector2(.86f, .11f),
new Vector2(.81f, .09f)
},
new[]
{
new Vector2(1, .44f), new Vector2(.94f, .37f), new Vector2(.90f, .42f), new Vector2(.89f, .47f),
new Vector2(.86f, .54f), new Vector2(.85f, .65f), new Vector2(.87f, .71f), new Vector2(.91f, .74f),
new Vector2(.94f, .79f), new Vector2(1, .82f)
},
new[]
{
new Vector2(0, .79f), new Vector2(.026f, .83f), new Vector2(.05f, .90f), new Vector2(.062f, .91f),
new Vector2(.078f, .95f), new Vector2(.12f, .96f), new Vector2(.16f, 1), new Vector2(0, 1)
},
new[]
{
new Vector2(.11f, .78f), new Vector2(.15f, .75f), new Vector2(.23f, .76f), new Vector2(.27f, .78f),
new Vector2(.23f, .79f), new Vector2(.17f, .781f), new Vector2(.13f, .80f)
},
new[]
{
new Vector2(.33f, .84f), new Vector2(.36f, .82f), new Vector2(.39f, .83f), new Vector2(.39f, .86f),
new Vector2(.36f, .86f), new Vector2(.34f, .85f)
}
};
private void OpenVoyageChart()
{
int port = destination >= 0 ? destination : Ship?.Port ?? 0;
worldChart = port >= Market.StarterPortCount || (Ship?.Port ?? 0) >= Market.StarterPortCount;
inspectedPort = port;
chartScrollPosition = 0;
ChangePage(3);
}
private void DrawPorts(VisualElement pageRoot)
{
var columns = Add(pageRoot, "columns");
var chartCard = Card(columns, "Shipping lanes", "wide");
var scope = Add(chartCard, "deck-tabs");
scope.Add(Action("Atlantic", () => ChangeChart(false), worldChart ? "" : "active-option", "chart-atlantic"));
scope.Add(Action("World", () => ChangeChart(true), worldChart ? "active-option" : "", "chart-world"));
var chart = Add(chartCard, "chart");
var labels = Add(chartCard, "chart-legend");
AddText(labels, "● Permit held", "gain");
AddText(labels, "● Permit required", "gold");
chart.generateVisualContent += DrawChart;
var board = Add(pageRoot, "navigation-chart");
board.styleSheets.Add(Resources.Load<StyleSheet>("Chart"));
var heading = Add(board, "chart-heading");
AddText(heading, Ship == null ? "PORT DIRECTORY" : $"ABOARD {Ship.Name.ToUpperInvariant()}", "chart-kicker");
AddDisplay(heading, "Shipping chart", "chart-heading-title");
var plot = Add(board, "chart-plot");
plot.generateVisualContent += DrawChart;
DrawChartLabels(plot);
var switches = Add(board, "chart-scopes");
switches.Add(Action("Atlantic", () => ChangeChart(false), worldChart ? "chart-scope" : "chart-scope chart-scope-current", "chart-atlantic"));
switches.Add(Action("World", () => ChangeChart(true), worldChart ? "chart-scope chart-scope-current" : "chart-scope", "chart-world"));
for (int i = 0; i < ChartPortCount; i++)
{
int portId = i;
PortSpec port = Market.Ports[i];
var marker = Action("●", () => { inspectedPort = portId; Notify(null); Render(); },
company.Permits[i] ? "map-port gain" : "map-port gold", "map-" + i);
bool berth = Ship?.Port == i;
bool cleared = company.Permits[i];
bool selected = inspectedPort == i;
string styles = "chart-port-pin";
if (berth)
styles += " chart-port-berth";
else if (!cleared)
styles += " chart-port-locked";
if (selected)
styles += " chart-port-selected";
var marker = Action("", () => InspectChartPort(portId), styles, "port-" + i);
marker.tooltip = $"{port.Name} · {(berth ? "Current port" : cleared ? "Permit held" : "Permit required")}";
Vector2 point = ChartPoint(port);
marker.style.left = Length.Percent(point.x * 100);
marker.style.top = Length.Percent(point.y * 100);
marker.EnableInClassList("active-option", i == inspectedPort);
marker.tooltip = port.Name;
chart.Add(marker);
var light = Add(marker, "chart-pin-light");
light.pickingMode = PickingMode.Ignore;
var caption = AddText(marker, port.Name, point.x > .77f ? "chart-pin-label chart-pin-label-west" : "chart-pin-label");
caption.EnableInClassList("chart-pin-label-on-focus", worldChart && !selected && !berth);
plot.Add(marker);
}
PortSpec current = Market.Ports[inspectedPort];
var portInfo = Card(columns, current.Name, "narrow");
AddText(portInfo, $"{current.Country} / {current.Region}", "muted");
AddLine(portInfo, "Bunker price", $"{Money(Market.FuelPrice(inspectedPort, company.Day))} / t");
AddLine(portInfo, "Arrival dues", Money(current.Fee));
AddLine(portInfo, "Destination appeal", $"{current.Appeal:P0}");
AddLine(portInfo, "Minimum hull", Market.Hulls[current.MinimumHull].Name);
bool licensed = company.Permits[inspectedPort];
AddLine(portInfo, "Port access", licensed ? "Permit held" : "Permit required", licensed ? "gain" : "gold");
if (!licensed)
{
int portId = inspectedPort;
string blocker = company.PermitBlock(portId);
Button license = Action($"Acquire permit · {Money(current.Permit)}", () =>
{
string failure = company.Permit(portId);
if (failure == null && destination < 0)
ResetItinerary();
Apply(failure, $"{current.Name} is now licensed.");
}, "primary full-button", "permit");
license.SetEnabled(blocker == null);
portInfo.Add(license);
if (blocker != null)
AddText(portInfo, blocker, "body-copy");
}
if (Ship != null && Market.TryDistance(Ship.Port, inspectedPort, out int miles))
{
AddLine(portInfo, $"From {Market.Ports[Ship.Port].Name}", $"{miles:N0} nm");
Button plan = Action("Plan this sailing →", () =>
{
destination = inspectedPort;
SetRecommendedFuel();
ChangePage(0);
}, "full-button", "plan-port");
portInfo.Add(plan);
}
var legend = Add(board, "chart-legends");
ChartKey(legend, "Current berth", "chart-key-berth");
ChartKey(legend, "Open port", "chart-key-open");
ChartKey(legend, "Permit required", "chart-key-locked");
var index = Card(pageRoot, "Port directory", "second-row");
var grid = Add(index, "port-grid");
var folio = new ScrollView(ScrollViewMode.Vertical) { horizontalScrollerVisibility = ScrollerVisibility.Hidden };
folio.AddToClassList("chart-folio");
float scrollPosition = chartScrollPosition;
folio.verticalScroller.valueChanged += value => chartScrollPosition = value;
if (scrollPosition > 0)
folio.schedule.Execute(() => folio.scrollOffset = new Vector2(0, scrollPosition));
board.Add(folio);
var contents = Add(folio, "chart-folio-content");
AddText(contents, "LOOK UP PORT", "chart-paper-kicker");
AddChartDirectory(contents);
DrawPortFolio(contents);
}
private static void ChartKey(VisualElement legend, string name, string color)
{
var key = Add(legend, "chart-key");
Add(key, "chart-key-light " + color);
AddText(key, name, "chart-key-label");
}
private void AddChartDirectory(VisualElement parent)
{
var choices = new List<string>(ChartPortCount);
for (int i = 0; i < ChartPortCount; i++)
choices.Add(Market.Ports[i].Name);
var selector = new DropdownField(choices, inspectedPort) { name = "chart-directory" };
selector.AddToClassList("chart-directory");
selector.RegisterValueChangedCallback(evt =>
{
int portId = i;
PortSpec port = Market.Ports[i];
Button option = Action("", () => { inspectedPort = portId; Notify(null); Render(); },
inspectedPort == i ? "port-row active-option" : "port-row", "port-" + i);
AddText(option, port.Name, "option-title");
AddText(option, $"{port.Country} · {Money(Market.FuelPrice(i, company.Day))}/t",
company.Permits[i] ? "muted" : "gold");
grid.Add(option);
int port = choices.IndexOf(evt.newValue);
if (port >= 0)
InspectChartPort(port);
});
parent.Add(selector);
}
private void DrawPortFolio(VisualElement parent)
{
Ship ship = Ship;
int selected = inspectedPort;
PortSpec port = Market.Ports[selected];
bool berth = ship?.Port == selected;
Voyage quote = ship == null ? null : company.Forecast(ship, selected);
bool permitted = company.Permits[selected];
bool eligible = ship == null || ship.HullIndex >= port.MinimumHull;
AddDisplay(parent, port.Name, "chart-port-name");
AddText(parent, $"{port.Country} · {port.Region}", "chart-paper-caption");
if (quote != null && permitted && eligible)
{
DrawVoyageFolio(parent, ship, quote);
return;
}
AddText(parent, berth ? "CURRENT BERTH" : "PORT CONDITIONS", "chart-paper-kicker chart-paper-section");
ChartLine(parent, "Fuel at this port", $"{Money(Market.FuelPrice(selected, company.Day))} / t");
ChartLine(parent, "Arrival dues", Money(port.Fee));
ChartLine(parent, "Destination appeal", $"{port.Appeal:P0}");
ChartLine(parent, "Minimum hull", Market.Hulls[port.MinimumHull].Name);
if (quote != null)
ChartLine(parent, $"From {Market.Ports[ship.Port].Name}", $"{quote.Miles:N0} nm");
if (berth)
{
DrawChartBunkering(parent, ship);
return;
}
if (!permitted)
{
string blocker = company.PermitBlock(selected);
Button permit = Action($"Acquire permit · {Money(port.Permit)}", () =>
{
string failure = company.Permit(selected);
Apply(failure, $"{port.Name} is now licensed.");
}, "chart-ink-button chart-wide-button", "permit");
permit.SetEnabled(blocker == null);
parent.Add(permit);
AddText(parent, blocker ?? $"Open {port.Name} to your fleet.", "chart-paper-note");
}
else if (!eligible)
{
AddText(parent, $"This sailing requires a {Market.Hulls[port.MinimumHull].Name} hull.", "chart-paper-note");
}
else if (ship == null)
{
AddText(parent, "Assign a vessel to plan a sailing.", "chart-paper-note");
parent.Add(Action("Visit shipyard", () => ChangePage(2), "chart-ink-button chart-wide-button"));
}
else
{
AddText(parent, $"There is no direct route from {Market.Ports[ship.Port].Name}. Select a linked port to plan this sailing.", "chart-paper-note");
}
}
private int ChartPortCount => worldChart ? Market.Ports.Count : Market.StarterPortCount;
private void ChangeChart(bool global)
private void InspectChartPort(int port)
{
worldChart = global;
if (inspectedPort >= ChartPortCount)
inspectedPort = Market.Lisbon;
if (port != inspectedPort)
chartScrollPosition = 0;
inspectedPort = port;
if (Ship != null && Market.TryDistance(Ship.Port, port, out _) && destination != port)
{
destination = port;
SetRecommendedFuel();
}
Notify(null);
Render();
}
private Vector2 ChartPoint(PortSpec port) => worldChart
? new Vector2((port.Longitude + 180) / 360, (76 - port.Latitude) / 137)
: new Vector2(port.MapX, port.MapY);
private void ChangeChart(bool global)
{
worldChart = global;
if (inspectedPort >= ChartPortCount)
{
InspectChartPort(Market.Lisbon);
return;
}
Notify(null);
Render();
}
private Vector2 ChartPoint(PortSpec port)
{
Vector2 point = worldChart
? new Vector2((port.Longitude + 180) / 360, (76 - port.Latitude) / 137)
: new Vector2(port.MapX, port.MapY);
return PlotInset(point);
}
private static Vector2 PlotInset(Vector2 point) => new Vector2(.035f + point.x * .93f, .035f + point.y * .93f);
private void DrawChartLabels(VisualElement plot)
{
if (worldChart)
{
OceanName("NORTH PACIFIC", .15f, .62f);
OceanName("ATLANTIC", .37f, .56f);
OceanName("INDIAN OCEAN", .62f, .72f);
OceanName("SOUTH PACIFIC", .11f, .88f);
}
else
{
OceanName("NORTH ATLANTIC", .48f, .29f);
OceanName("CARIBBEAN SEA", .25f, .95f);
}
void OceanName(string name, float x, float y)
{
Label label = AddText(plot, name, "chart-water-name");
label.style.left = Length.Percent(x * 100);
label.style.top = Length.Percent(y * 100);
}
}
private void DrawChart(MeshGenerationContext context)
{
VisualElement chart = context.visualElement;
float width = chart.contentRect.width;
float height = chart.contentRect.height;
Vector2 Point(float x, float y) => new Vector2(width * x, height * y);
float width = context.visualElement.contentRect.width;
float height = context.visualElement.contentRect.height;
if (width < 32 || height < 32)
return;
Vector2 Point(Vector2 point) => new Vector2(width * point.x, height * point.y);
Painter2D painter = context.painter2D;
painter.strokeColor = new Color(.18f, .32f, .36f);
painter.strokeColor = new Color(.23f, .39f, .44f, .44f);
painter.lineWidth = 1;
painter.BeginPath();
for (int i = 1; i < 12; i++)
for (int i = 0; i <= 12; i++)
{
painter.MoveTo(Point(i / 12f, 0));
painter.LineTo(Point(i / 12f, 1));
painter.MoveTo(Point(PlotInset(new Vector2(i / 12f, 0))));
painter.LineTo(Point(PlotInset(new Vector2(i / 12f, 1))));
}
for (int i = 1; i < 7; i++)
for (int i = 0; i <= 8; i++)
{
painter.MoveTo(Point(0, i / 7f));
painter.LineTo(Point(1, i / 7f));
painter.MoveTo(Point(PlotInset(new Vector2(0, i / 8f))));
painter.LineTo(Point(PlotInset(new Vector2(1, i / 8f))));
}
painter.Stroke();
void Polygon(Vector2[] points)
painter.fillColor = new Color(.139f, .255f, .276f);
painter.strokeColor = new Color(.49f, .55f, .49f, .72f);
painter.lineWidth = 1.15f;
foreach (Vector2[] outline in worldChart ? WorldCoastlines.Shapes : AtlanticCoastlines)
{
painter.BeginPath();
painter.MoveTo(Point(points[0].x, points[0].y));
for (int i = 1; i < points.Length; i++)
painter.LineTo(Point(points[i].x, points[i].y));
painter.MoveTo(Point(PlotInset(outline[0])));
for (int i = 1; i < outline.Length; i++)
painter.LineTo(Point(PlotInset(outline[i])));
painter.ClosePath();
painter.Fill();
painter.Stroke();
}
painter.fillColor = new Color(.15f, .28f, .29f);
painter.strokeColor = new Color(.30f, .43f, .42f);
if (worldChart)
{
foreach (Vector2[] continent in WorldCoastlines.Shapes)
Polygon(continent);
}
else
{
Polygon(new[]
{
new Vector2(0,0), new Vector2(.30f,0), new Vector2(.27f,.12f), new Vector2(.26f,.26f),
new Vector2(.23f,.33f), new Vector2(.20f,.46f), new Vector2(.15f,.52f), new Vector2(.13f,.60f),
new Vector2(.15f,.68f), new Vector2(.12f,.74f), new Vector2(.10f,.64f), new Vector2(.08f,.57f),
new Vector2(.02f,.54f), new Vector2(0,.60f)
});
Polygon(new[]
{
new Vector2(1,0), new Vector2(.84f,0), new Vector2(.86f,.08f), new Vector2(.88f,.13f),
new Vector2(.86f,.24f), new Vector2(.90f,.30f), new Vector2(.94f,.28f), new Vector2(.95f,.33f),
new Vector2(.90f,.39f), new Vector2(.86f,.52f), new Vector2(.87f,.68f), new Vector2(.95f,.83f), new Vector2(1,.83f)
});
Polygon(new[]
{
new Vector2(0,.84f), new Vector2(.08f,.88f), new Vector2(.15f,.92f),
new Vector2(.21f,.84f), new Vector2(.34f,.97f), new Vector2(.41f,1), new Vector2(0,1)
});
}
int berth = Ship?.Port ?? -1;
bool CanShow(Lane lane) => lane.A < ChartPortCount && lane.B < ChartPortCount;
bool IsSelected(Lane lane) => berth >= 0 && lane.Other(berth) == inspectedPort;
foreach (Lane lane in Market.Lanes)
{
if (lane.A >= ChartPortCount || lane.B >= ChartPortCount)
if (!CanShow(lane) || IsSelected(lane))
continue;
bool active = company.Permits[lane.A] && company.Permits[lane.B];
DrawLane(lane, active ? new Color(.40f, .73f, .71f, .68f) : new Color(.60f, .52f, .39f, .62f), active ? 1.55f : 1.1f);
}
foreach (Lane lane in Market.Lanes)
{
if (!CanShow(lane) || !IsSelected(lane))
continue;
DrawLane(lane, new Color(.92f, .65f, .28f, .18f), 9);
DrawLane(lane, new Color(.98f, .75f, .38f, 1), 2.3f);
}
DrawCompass(painter, new Vector2(width - 69, height - 76), 34);
void DrawLane(Lane lane, Color color, float thickness)
{
Vector2 a = ChartPoint(Market.Ports[lane.A]);
Vector2 b = ChartPoint(Market.Ports[lane.B]);
bool active = company.Permits[lane.A] && company.Permits[lane.B];
painter.strokeColor = active ? new Color(.41f, .75f, .68f, .8f) : new Color(.69f, .62f, .44f, .59f);
painter.lineWidth = active ? 1.65f : 1;
if (worldChart && Mathf.Abs(a.x - b.x) > .5f)
painter.strokeColor = color;
painter.lineWidth = thickness;
if (worldChart && Mathf.Abs(a.x - b.x) > .465f)
{
if (a.x > b.x)
(a, b) = (b, a);
float y = Mathf.Lerp(a.y, b.y, a.x / (a.x + 1 - b.x));
RouteSegment(a, new Vector2(0, y));
RouteSegment(new Vector2(1, y), b);
float toEdge = a.x - .035f;
float y = Mathf.Lerp(a.y, b.y, toEdge / (toEdge + .965f - b.x));
Curve(a, new Vector2(.035f, y));
Curve(new Vector2(.965f, y), b);
}
else
RouteSegment(a, b);
}
Curve(a, b);
void RouteSegment(Vector2 a, Vector2 b)
void Curve(Vector2 from, Vector2 to)
{
painter.BeginPath();
painter.MoveTo(Point(from));
float rise = (worldChart ? .10f : .145f) * Vector2.Distance(from, to);
painter.QuadraticCurveTo(Point((from + to) / 2 - new Vector2(0, rise)), Point(to));
painter.Stroke();
}
}
}
private static void DrawCompass(Painter2D painter, Vector2 center, float radius)
{
painter.lineWidth = 1;
painter.strokeColor = new Color(.64f, .58f, .44f, .68f);
painter.BeginPath();
painter.MoveTo(center + Vector2.right * radius);
const int segments = 48;
for (int i = 1; i <= segments; i++)
{
float angle = i * Mathf.PI * 2 / segments;
painter.LineTo(center + new Vector2(Mathf.Cos(angle), Mathf.Sin(angle)) * radius);
}
painter.ClosePath();
painter.Stroke();
painter.fillColor = new Color(.80f, .68f, .43f, .72f);
for (int i = 0; i < 4; i++)
{
float angle = i * Mathf.PI * .5f;
Vector2 axis = new Vector2(Mathf.Sin(angle), -Mathf.Cos(angle));
Vector2 wing = new Vector2(-axis.y, axis.x);
painter.BeginPath();
painter.MoveTo(Point(a.x, a.y));
float rise = worldChart ? .018f : .055f;
painter.QuadraticCurveTo(Point((a.x + b.x) / 2, (a.y + b.y) / 2 - rise), Point(b.x, b.y));
painter.MoveTo(center);
painter.LineTo(center + axis * radius * (i == 0 ? 1.28f : .95f));
painter.LineTo(center + wing * radius * .16f);
painter.ClosePath();
painter.Fill();
painter.Stroke();
}
}
private void DrawFinance(VisualElement pageRoot)
{
var summary = Add(pageRoot, "card deck-stats");
ForecastMetric(summary, "CASH RESERVES", Money(company.Cash), "gold");
ForecastMetric(summary, "OUTSTANDING DEBT", Money(company.Debt));
ForecastMetric(summary, "LIFETIME VOYAGE PROFIT", Money(company.LifetimeProfit), company.LifetimeProfit >= 0 ? "gain" : "loss");
ForecastMetric(summary, "COMPLETED VOYAGES", company.Voyages.ToString());
var columns = Add(pageRoot, "columns second-row");
var ledger = Card(columns, "Voyage ledger", "wide");
if (company.History.Count == 0)
AddText(ledger, "Completed voyages will be posted here.", "body-copy");
else
{
selectedVoyage = Mathf.Clamp(selectedVoyage, 0, company.History.Count - 1);
var list = new ScrollView(ScrollViewMode.Vertical);
list.AddToClassList("ledger-scroll");
ledger.Add(list);
for (int i = 0; i < company.History.Count; i++)
{
int record = i;
Voyage trip = company.History[i];
Button entry = Action("", () => { selectedVoyage = record; Render(); },
selectedVoyage == i ? "yard-item active-option" : "yard-item", "voyage-" + i);
var detail = Add(entry, "yard-copy");
AddText(detail, $"{Market.Ports[trip.Origin].Name} → {Market.Ports[trip.Destination].Name}", "option-title");
AddText(detail, $"Day {trip.Day} · {trip.ShipName} · {trip.Guests} guests", "muted");
AddText(entry, Money(trip.NetIncome), trip.NetIncome >= 0 ? "gain" : "loss");
list.Add(entry);
}
}
var account = Card(columns, "Financing", "narrow");
AddLine(account, "Interest", company.Debt > 0 ? "13% APR" : "No outstanding loan");
AddLine(account, "Principal per sailing day", company.Debt > 0 ? Money(850) : "—");
if (company.Debt > 0)
{
Button pay = Action($"Pay down · {Money(Mathf.Min(company.Debt, 25000))}",
() => Apply(company.PayDownDebt(), "Principal payment posted."), "full-button", "pay-debt");
pay.SetEnabled(company.Cash >= Mathf.Min(company.Debt, 25000));
account.Add(pay);
}
if (company.Bridge)
{
Button draw = Action("Draw $125,000 bridge loan", () => Apply(company.DrawBridge(), "Bridge loan posted."),
"full-button", "draw-bridge");
draw.SetEnabled(company.CanDrawBridge);
account.Add(draw);
if (!company.CanDrawBridge)
AddText(account, "Bridge credit opens below $100,000 cash.", "body-copy");
}
if (company.Flagship)
AddText(account, "Flagship milestone completed.", "body-copy gain");
if (company.History.Count == 0)
return;
Voyage selected = company.History[selectedVoyage];
var statement = Card(pageRoot, $"Sailing statement · Day {selected.Day}", "second-row");
var breakdown = Add(statement, "columns breakdown");
var earnings = Add(breakdown, "half");
AddLine(earnings, "Ticket revenue", Money(selected.TicketSales));
AddLine(earnings, "Onboard revenue", Money(selected.OnboardSales));
AddLine(earnings, "Crew & catering", Money(-selected.Crew - selected.Catering));
AddLine(earnings, "Port dues", Money(-selected.PortFees));
var costs = Add(breakdown, "half");
AddLine(costs, "Fuel consumed from inventory", Money(-selected.FuelExpense));
AddLine(costs, "Interest", Money(-selected.LoanInterest));
AddLine(costs, "Loan principal paid", Money(-selected.Principal));
AddLine(costs, "Cash change on arrival", Money(selected.CashChange), selected.CashChange >= 0 ? "gain" : "loss");
}
}
}