Files
josh 290e4cb45d Add riverboat captain career and distinct ship classes
Add class-specific vessel geometry and sea motion, a guided helm qualification path, dockside sailing orders, and local excursions at all 24 ports.
2026-11-29 20:41:00 -05:00

113 lines
5.7 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using UnityEngine;
using UnityEngine.UIElements;
namespace BigShipTycoon
{
public sealed partial class TycoonApp
{
private void DrawVoyageFolio(VisualElement chart, VisualElement folio, Ship ship, Voyage quote)
{
PortSpec origin = Market.Ports[quote.Origin];
PreparePortOrders(ship, quote);
AddText(folio, $"DEPARTURE FROM {origin.Name.ToUpperInvariant()}", "chart-paper-kicker chart-paper-section");
DrawWeatherPicker(folio, quote);
var passage = Add(folio, "chart-passage");
AddText(passage, $"{quote.Miles:N0} nm · {quote.Days} days", "chart-passage-distance");
AddText(passage, $"{quote.Guests} / {quote.Capacity} guests", "chart-passage-guests");
var settlement = Add(folio, "chart-settlement");
AddText(settlement, "EST. VOYAGE PROFIT", "chart-paper-kicker");
AddDisplay(settlement, Money(quote.NetIncome), quote.NetIncome >= 0 ? "chart-projected-profit" : "chart-projected-profit chart-projected-loss");
var fares = Add(folio, "chart-money-row");
AddText(fares, ship.SuiteBerths > 0 ? "Base fare per guest" : "Fare per guest", "chart-money-label");
ChartStepper(fares, Money(ship.Fare), "fare", () => ChangeFare(ship, -50), () => ChangeFare(ship, 50),
ship.Fare > Market.MinFare, ship.Fare < Market.MaxFare);
if (ship.SuiteBerths > 0)
ChartLine(folio, $"{quote.SuiteGuests:N0} / {ship.SuiteBerths:N0} suite berths booked", $"+{Money(quote.SuitePremium)}");
DrawPortOrdersLink(folio, quote.Plan);
if (company.IsCaptainCareer)
AddText(folio, "Helm practice · Take command on the bridge, complete the check and let the boat reach port.", "chart-paper-note");
DrawChartBunkering(folio, ship, quote);
string blocker = company.DepartureBlock(ship, quote);
if (!string.IsNullOrEmpty(blocker))
AddText(folio, blocker, "chart-paper-note chart-departure-blocker");
else
{
int seconds = Mathf.RoundToInt(PassageDuration(quote) / PortPlanning.SpeedRate(PortPlanning.EngineMode(quote.Plan.Order)));
AddText(folio, $"Cleared for departure · {seconds / 60}m {seconds % 60:00}s at 1×", "chart-cleared");
}
Button launch = Action("Cast off →", () => BeginVoyage(quote), "chart-ink-button chart-wide-button chart-cast-off", "dispatch");
launch.SetEnabled(blocker == null);
folio.Add(launch);
if (portOrdersOpen)
DrawPortOrders(chart, ship, quote);
}
private void DrawChartBunkering(VisualElement folio, Ship ship, Voyage quote = null)
{
PortSpec dock = Market.Ports[ship.Port];
AddText(folio, "FUEL AT BERTH", "chart-paper-kicker chart-paper-section");
ChartLine(folio, "Aboard / capacity", $"{ship.Fuel} / {ship.Tank} t");
var tank = Add(folio, "chart-tank");
Add(tank, "chart-tank-fill").style.width = Length.Percent(100f * ship.Fuel / ship.Tank);
if (quote != null)
ChartLine(folio, "Burn + reserve", $"{quote.DepartureFuelBurn} + {quote.Reserve} t");
else
ChartLine(folio, "Indicative safe range", $"{ship.SafeRange:N0} nm");
ChartLine(folio, $"Price in {dock.Name}", $"{Money(Market.FuelPrice(ship.Port, company.Day))} / t");
var buying = Add(folio, "chart-buying");
ChartStepper(buying, $"{bunkerTons} t", "tons", () => ChangeQuantity(ship, -10), () => ChangeQuantity(ship, 10),
bunkerTons > 0, bunkerTons < ship.Tank - ship.Fuel);
Button buy = Action($"Buy {Money(company.BunkerCost(ship, bunkerTons))}", () =>
{
int ordered = bunkerTons;
string failure = company.Refuel(ship, ordered);
if (failure == null)
SetRecommendedFuel();
Apply(failure, $"Loaded {ordered} t of fuel in {dock.Name}.");
}, "chart-ink-button chart-buy-fuel", "buy-fuel");
buy.SetEnabled(bunkerTons > 0 && company.AvailableCash >= company.BunkerCost(ship, bunkerTons));
buying.Add(buy);
}
private void ChangeFare(Ship ship, int amount)
{
ship.Fare = Market.Clamp(ship.Fare + amount, Market.MinFare, Market.MaxFare);
Apply(null, null);
}
private void ChangeQuantity(Ship ship, int amount)
{
bunkerTons = Mathf.Clamp(bunkerTons + amount, 0, ship.Tank - ship.Fuel);
Notify(null);
Render();
}
private static void ChartStepper(VisualElement parent, string value, string id, Action minus, Action plus, bool canMinus, bool canPlus)
{
var stepper = Add(parent, "chart-stepper");
Button down = Action("-", minus, "chart-step", id + "-minus");
down.tooltip = id == "fare" ? "Lower passenger fare by $50" : "Buy 10 fewer tons";
down.SetEnabled(canMinus);
stepper.Add(down);
AddText(stepper, value, "chart-step-value");
Button up = Action("+", plus, "chart-step", id + "-plus");
up.tooltip = id == "fare" ? "Raise passenger fare by $50" : "Buy 10 more tons";
up.SetEnabled(canPlus);
stepper.Add(up);
}
private static void ChartLine(VisualElement parent, string description, string value)
{
var line = Add(parent, "chart-paper-line");
AddText(line, description, "chart-paper-caption");
AddText(line, value, "chart-paper-value");
}
}
}