Add multi-stop voyages, a live chart, and named port announcements

This commit is contained in:
josh
2026-11-27 23:41:08 -05:00
parent cc7620c431
commit 9500813df4
111 changed files with 2037 additions and 38 deletions

View File

@@ -18,6 +18,7 @@ namespace Soundings
public int[] ServicePrices;
public double FuelValue;
public List<Deck> Decks = new List<Deck>();
public CruiseItinerary Itinerary;
public HullSpec Hull => Market.Hulls[HullIndex];
public int Beds => Count(Facility.Cabin) * Market.Facilities[(int)Facility.Cabin].Capacity;
@@ -53,6 +54,7 @@ namespace Soundings
public int Origin, Destination, Miles, Days, Day, Fare, Guests, RoomDemand, Capacity, FuelBurn, Reserve,
TicketSales, OnboardSales, Crew, Catering, PortFees, FuelExpense, LoanInterest, Principal, ReputationChange;
public string ShipName;
public int ItineraryStartDay, ItineraryLeg, ItineraryLegs;
public OnboardReport Onboard;
public DeparturePlan Plan;
public WeatherCondition Weather;
@@ -64,7 +66,7 @@ namespace Soundings
}
[Serializable]
public sealed class Company
public sealed partial class Company
{
public const int SaveVersion = 1;
public const int MaxHistory = 30;
@@ -121,7 +123,7 @@ namespace Soundings
return false;
}
if (ship.Fuel > ship.Tank)
if (ship.Fuel > ship.Tank || !ValidSavedItinerary(ship))
return false;
}
@@ -318,8 +320,7 @@ namespace Soundings
PortSpec from = Market.Ports[ship.Port];
PortSpec to = Market.Ports[destination];
int days = 1 + (int)Math.Ceiling(miles / 415.0);
int fuel = (int)Math.Ceiling(ship.BurnPerMile * miles);
int reserve = Math.Max(6, (int)Math.Ceiling(fuel * .12));
var (fuel, reserve) = LegFuel(ship, miles);
double referenceFare = 330 + days * 88 + to.Appeal * 125;
double fareFactor = Math.Pow(referenceFare / ship.Fare, 1.55);
double season = 1 + .13 * Math.Cos((Day + destination * 13) * 2 * Math.PI / 112);
@@ -369,8 +370,10 @@ namespace Soundings
public string DepartureBlock(Ship ship, Voyage quote)
{
if (quote == null || quote.Destination == ship.Port)
if (ship == null || quote == null || quote.Origin != ship.Port || !Market.TryDistance(ship.Port, quote.Destination, out _))
return "Select a connected port from your itinerary.";
if (ship.Itinerary is { HasNext: true } itinerary && quote.Destination != itinerary.NextPort)
return $"This itinerary's next stop is {Market.Ports[itinerary.NextPort].Name}.";
if (!Permits[quote.Destination])
return "Obtain a destination permit in Ports.";
if (ship.HullIndex < Market.Ports[quote.Destination].MinimumHull)
@@ -393,8 +396,10 @@ namespace Soundings
public string Sail(Ship ship, int destination, OnboardSession live = null)
{
if (ship == null || !Fleet.Contains(ship))
return "Choose a ship in this fleet.";
Voyage quote = live?.Quote ?? Forecast(ship, destination);
if (live != null && (live.Ship != ship || quote.Origin != ship.Port || quote.Destination != destination))
if (live != null && (live.Ship != ship || quote.Origin != ship.Port || quote.Destination != destination || quote.Day <= Day))
return "This sailing has already been settled or belongs to another ship.";
string block = DepartureBlock(ship, quote);
if (block != null)
@@ -414,6 +419,7 @@ namespace Soundings
ship.FuelValue *= (double)(ship.Fuel - quote.FuelBurn) / ship.Fuel;
ship.Fuel -= quote.FuelBurn;
ship.Condition = Market.Clamp(ship.Condition - Math.Max(1, quote.Days / 2) + (quote.Onboard?.Repair ?? 0), 24, 100);
RecordItineraryArrival(ship, quote);
ship.Port = quote.Destination;
Day = quote.Day;
Cash += quote.CashChange;