Add port-specific shore excursions and deck stack
This commit is contained in:
@@ -18,7 +18,102 @@ namespace Soundings.Editor
|
||||
VerifyStormAndShipSystems();
|
||||
VerifyPortOrders();
|
||||
VerifyMultiStopItinerary();
|
||||
Debug.Log("Soundings economy verification passed for both starts, pricing, fuel, enlarged venues, fleet settlements, saves, weather, ship systems, port orders and multi-stop itineraries.");
|
||||
VerifyShoreExcursions();
|
||||
Debug.Log("Soundings economy verification passed for both starts, pricing, fuel, enlarged venues, fleet settlements, saves, weather, ship systems, port orders, multi-stop itineraries and shore excursions.");
|
||||
}
|
||||
|
||||
private static void VerifyShoreExcursions()
|
||||
{
|
||||
var names = new System.Collections.Generic.HashSet<string>();
|
||||
for (int i = 0; i < Market.Ports.Count; i++)
|
||||
{
|
||||
var tours = ShoreExcursions.Catalog(i);
|
||||
Require(tours.Count == 2, "two distinct local shore tours at " + Market.Ports[i].Name);
|
||||
foreach (ShoreTour tour in tours)
|
||||
Require(names.Add(tour.Name) && tour.MinPrice < tour.StandardPrice && tour.StandardPrice < tour.MaxPrice,
|
||||
"unique and priced shore tour " + tour.Name);
|
||||
}
|
||||
|
||||
Company company = Company.Start(false);
|
||||
Voyage quote = company.Forecast(company.ActiveShip, 1);
|
||||
var catalog = ShoreExcursions.Catalog(1);
|
||||
var offer = new ShoreOffer { Tour = 1, Price = catalog[1].StandardPrice, Capacity = catalog[1].MaxCapacity };
|
||||
ShoreOffer[] offers = { offer };
|
||||
Require(ShoreExcursions.Create(quote, null) == null, "shore excursions are optional");
|
||||
Require(!ShoreExcursions.ValidOffers(1, new[] { offer, offer }), "shore plans reject duplicate tours");
|
||||
ShoreBooking calm = ShoreExcursions.Forecast(quote, offers)[0];
|
||||
quote.Weather = WeatherCondition.Storm;
|
||||
ShoreBooking storm = ShoreExcursions.Forecast(quote, offers)[0];
|
||||
Require(storm.Demand < calm.Demand && storm.DelayRisk > calm.DelayRisk, "rough weather shifts shore demand and return risk");
|
||||
offer.Price = catalog[1].MaxPrice;
|
||||
Require(ShoreExcursions.Forecast(quote, offers)[0].Demand < storm.Demand, "higher shore prices reduce projected demand");
|
||||
offer.Price = catalog[1].MinPrice;
|
||||
offer.Capacity = 4;
|
||||
ShoreBooking limited = ShoreExcursions.Forecast(quote, offers)[0];
|
||||
Require(limited.Demand > limited.Guests && limited.Guests == 4 && limited.Revenue > limited.OperatorCost,
|
||||
"excursion seats limit sales and the price floor covers contracted operators");
|
||||
|
||||
offer.Capacity = catalog[1].MaxCapacity;
|
||||
var indoor = new ShoreOffer { Tour = 0, Price = catalog[0].MinPrice, Capacity = catalog[0].MaxCapacity };
|
||||
quote.Weather = WeatherCondition.Calm;
|
||||
int actualGuests = quote.Guests;
|
||||
quote.Guests = 75;
|
||||
ShoreBooking[] shared = ShoreExcursions.Forecast(quote, new[] { offer, indoor });
|
||||
Require(shared[0].Guests > 0 && shared[1].Guests > 0 && shared[0].Guests + shared[1].Guests <= quote.Guests,
|
||||
"multiple shore tours share a finite passenger pool");
|
||||
quote.Guests = actualGuests;
|
||||
|
||||
ShoreCall delayed = null, onTime = null;
|
||||
for (int tries = 0; tries < 150 && (delayed == null || onTime == null); tries++, quote.Day++)
|
||||
{
|
||||
ShoreCall call = ShoreExcursions.Create(quote, offers);
|
||||
if (call.LateGuests > 0)
|
||||
delayed = call;
|
||||
else
|
||||
onTime = call;
|
||||
}
|
||||
Require(delayed != null && onTime != null, "scheduled shore tours can arrive on time or run late");
|
||||
onTime.CallId = 1;
|
||||
Require(onTime.Advance(60) && onTime.Report().CanLoad(1, 1) && onTime.Report().Resolution == ShoreLateResolution.None,
|
||||
"an on-time tour settles without a departure decision");
|
||||
|
||||
delayed.CallId = 2;
|
||||
float fullDwell = delayed.RemainingSeconds;
|
||||
Require(!delayed.Advance(4) && delayed.RemainingSeconds < fullDwell, "tour group departure runs on the gameplay clock");
|
||||
delayed = JsonUtility.FromJson<ShoreCall>(JsonUtility.ToJson(delayed));
|
||||
Require(delayed.CanLoad(1) && delayed.Phase == ShorePhase.Touring && delayed.RemainingSeconds == fullDwell - 4,
|
||||
"shore groups and docking timer survive a save");
|
||||
Require(delayed.Advance(60) && delayed.Phase == ShorePhase.AwaitingDecision && delayed.LateGuests > 0
|
||||
&& !delayed.Advance(60) && delayed.Report() == null, "the departure decision waits for the player");
|
||||
var alternate = JsonUtility.FromJson<ShoreCall>(JsonUtility.ToJson(delayed));
|
||||
Require(delayed.ResolveLate(true) && delayed.CanLoad(1) && delayed.Phase == ShorePhase.Holding
|
||||
&& !delayed.ResolveLate(true), "holding persists and cannot be charged twice");
|
||||
Require(delayed.Advance(60) && delayed.Report().CanLoad(1, 2)
|
||||
&& delayed.Report().Resolution == ShoreLateResolution.Held && delayed.Report().NetIncome >= 0, "settle after holding the ship");
|
||||
Require(alternate.ResolveLate(false) && alternate.Report().CanLoad(1, 2)
|
||||
&& alternate.Report().Resolution == ShoreLateResolution.AlternateTransport && alternate.Report().NetIncome >= 0
|
||||
&& alternate.GuestImpact < delayed.GuestImpact && alternate.ReputationImpact < delayed.ReputationImpact,
|
||||
"alternate transport releases the berth immediately with worse guest feedback");
|
||||
|
||||
Ship ship = company.ActiveShip;
|
||||
quote = company.Forecast(ship, 1);
|
||||
quote.ShoreOffers = offers;
|
||||
Require(company.Sail(ship, 1, new OnboardSession(ship, quote)) == null && ship.ShoreCall?.CallId == 1
|
||||
&& company.History[0].ShoreCallId == ship.ShoreCall.CallId && company.History[0].ShoreReport == null,
|
||||
"an arrival books the excursion without settling it before guests return");
|
||||
Company resumed = JsonUtility.FromJson<Company>(JsonUtility.ToJson(company));
|
||||
Require(resumed.CanLoad() && resumed.ActiveShip.ShoreCall?.CallId == 1 && resumed.ActiveShip.ShoreCall.Phase == ShorePhase.Touring
|
||||
&& resumed.ActiveShip.ShoreCall.RemainingSeconds == ship.ShoreCall.RemainingSeconds && resumed.History[0].ShoreReport == null,
|
||||
"the career save restores an active shore call and its pending ledger entry");
|
||||
ShoreCall resumedCall = resumed.ActiveShip.ShoreCall;
|
||||
resumedCall.Advance(60);
|
||||
if (resumedCall.Phase == ShorePhase.AwaitingDecision)
|
||||
resumedCall.ResolveLate(false);
|
||||
resumed.ActiveShip.ShoreCall = null;
|
||||
resumed.History[0].ShoreReport = resumedCall.Report();
|
||||
resumed = JsonUtility.FromJson<Company>(JsonUtility.ToJson(resumed));
|
||||
Require(resumed.CanLoad() && resumed.ActiveShip.ShoreCall == null && resumed.History[0].ShoreReport?.CanLoad(1, 1) == true,
|
||||
"the career save restores the shore report after berth release");
|
||||
}
|
||||
|
||||
private static void VerifyUsedStartAndProfit()
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Soundings.Editor
|
||||
EditorBuildSettings.scenes = new[] { new EditorBuildSettingsScene(ScenePath, true) };
|
||||
PlayerSettings.companyName = "Soundings";
|
||||
PlayerSettings.productName = "Soundings";
|
||||
PlayerSettings.bundleVersion = "0.9.0";
|
||||
PlayerSettings.bundleVersion = "0.10.0";
|
||||
PlayerSettings.defaultScreenWidth = 1920;
|
||||
PlayerSettings.defaultScreenHeight = 1080;
|
||||
PlayerSettings.fullScreenMode = FullScreenMode.FullScreenWindow;
|
||||
|
||||
@@ -104,3 +104,4 @@
|
||||
.fleet-ship-status.fleet-ship-at-sea { color: #a5d9ed; }
|
||||
.fleet-ship-readout { padding-left: 8px; -unity-text-align: middle-right; }
|
||||
.fleet-empty { color: #a6c1bd; font-size: 13px; padding: 7px 0; }
|
||||
.fleet-ship-shore-alert { color: #efb983; }
|
||||
|
||||
@@ -140,7 +140,18 @@
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.voyage-deck-caption { margin-right: 8px; }
|
||||
.voyage-deck-stack {
|
||||
position: absolute;
|
||||
right: 30px;
|
||||
bottom: 137px;
|
||||
width: 89px;
|
||||
padding: 7px 6px 6px;
|
||||
background-color: rgba(8, 22, 29, .92);
|
||||
border-width: 1px;
|
||||
border-top-width: 2px;
|
||||
border-color: #927e5d;
|
||||
}
|
||||
.voyage-deck-caption { -unity-text-align: middle-center; margin: 1px 0 6px; }
|
||||
.action.voyage-view-button {
|
||||
background-color: rgba(10, 26, 35, .95);
|
||||
color: #e7d4a6;
|
||||
@@ -153,6 +164,8 @@
|
||||
}
|
||||
.action.voyage-view-button:hover, .action.voyage-view-button:focus { border-color: #e5c990; }
|
||||
.action.voyage-control-active { background-color: #d8b680; border-color: #e8c992; color: #1b302f; }
|
||||
.voyage-deck-stack .action.voyage-view-button { height: 26px; min-height: 26px; margin: 0 0 2px; }
|
||||
.voyage-deck-stack #passage-deck-all { margin-bottom: 6px; }
|
||||
.action.voyage-reset { margin-left: 7px; }
|
||||
.voyage-rail {
|
||||
min-height: 70px;
|
||||
@@ -181,7 +194,7 @@
|
||||
|
||||
.passage-helm {
|
||||
position: absolute;
|
||||
right: 30px;
|
||||
right: 133px;
|
||||
bottom: 151px;
|
||||
width: 280px;
|
||||
padding: 10px;
|
||||
|
||||
108
Assets/Soundings/Resources/ShoreExcursions.uss
Normal file
108
Assets/Soundings/Resources/ShoreExcursions.uss
Normal file
@@ -0,0 +1,108 @@
|
||||
.chart-forecast-tools { flex-direction: row; align-items: center; margin-top: 3px; }
|
||||
.action.shore-chart-link { flex-grow: 1; min-height: 25px; margin: 0 0 0 6px; padding: 3px 6px; font-size: 12px; }
|
||||
.voyage-business-opener.shore-passage-actions { flex-direction: row; align-items: flex-end; }
|
||||
.action.shore-passage-link {
|
||||
margin-left: 5px;
|
||||
min-height: 34px;
|
||||
padding: 4px 9px;
|
||||
color: #d9d8c5;
|
||||
background-color: rgba(10, 24, 32, .92);
|
||||
border-color: #627171;
|
||||
}
|
||||
.action.shore-passage-link:hover { background-color: #2a424b; border-color: #a48b61; }
|
||||
.action.shore-passage-link:focus { border-color: #e6c989; }
|
||||
|
||||
.shore-planning-overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background-color: rgba(3, 10, 16, .75);
|
||||
}
|
||||
.shore-planning-sheet {
|
||||
width: 680px;
|
||||
max-width: 88%;
|
||||
max-height: 88%;
|
||||
padding: 21px 26px 23px;
|
||||
background-color: #122832;
|
||||
border-width: 1px;
|
||||
border-color: #657675;
|
||||
border-top-width: 2px;
|
||||
border-top-color: #c2a676;
|
||||
border-radius: 3px;
|
||||
}
|
||||
.shore-planning-heading, .shore-tour-header, .shore-tour-controls, .shore-planning-footer {
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
.shore-planning-place, .shore-tour-description, .shore-planning-estimate { min-width: 0; flex-grow: 1; }
|
||||
.shore-planning-title { color: #f3e7cc; font-size: 42px; margin-top: 2px; }
|
||||
.shore-kicker { font-size: 10px; letter-spacing: 1.35px; color: #dfc490; -unity-font-style: bold; }
|
||||
.action.shore-planning-close { margin-left: 14px; min-height: 32px; }
|
||||
.shore-planning-intro { color: #bdcfcd; font-size: 14px; margin: 5px 0 13px; white-space: normal; }
|
||||
.shore-tour-list { flex-shrink: 1; min-height: 104px; }
|
||||
.shore-tour {
|
||||
padding: 11px 14px 12px;
|
||||
margin-bottom: 8px;
|
||||
background-color: #172f39;
|
||||
border-width: 1px;
|
||||
border-color: #4f676c;
|
||||
border-left-width: 2px;
|
||||
}
|
||||
.shore-tour.shore-tour-offered { border-left-color: #d4b77a; background-color: #1c3640; }
|
||||
.shore-tour-name { font-size: 24px; color: #f0e2c4; white-space: normal; }
|
||||
.shore-tour-facts { color: #aec8c5; font-size: 12px; margin: 3px 0 0; }
|
||||
.shore-tour-copy { color: #cfdbd7; font-size: 13px; margin: 6px 0 7px; white-space: normal; }
|
||||
.action.shore-offer { margin-left: 10px; padding: 4px 11px; min-height: 29px; font-size: 12px; }
|
||||
.shore-tour-offered .action.shore-offer { color: #e6d3a5; border-color: #927953; }
|
||||
.shore-tour-controls { justify-content: flex-start; }
|
||||
.field.shore-number { width: 153px; min-height: 31px; margin-right: 12px; }
|
||||
.shore-number .unity-base-field__label { min-width: 56px; color: #c1d5d2; font-size: 13px; }
|
||||
.field.shore-number .unity-base-field__input { min-height: 30px; padding-left: 7px; font-size: 14px; }
|
||||
.shore-number .unity-text-element { --unity-cursor-color: #f8eace; --unity-selection-color: #375560; }
|
||||
.shore-forecast { color: #c3d8d6; font-size: 12px; margin-top: 6px; white-space: normal; }
|
||||
.shore-tour-offered .shore-forecast { color: #b6dfca; }
|
||||
.shore-planning-footer {
|
||||
margin-top: 8px;
|
||||
padding-top: 11px;
|
||||
border-top-width: 1px;
|
||||
border-top-color: #65726b;
|
||||
}
|
||||
.shore-plan-total { color: #efdcab; font-size: 15px; white-space: normal; -unity-font-style: bold; }
|
||||
.shore-plan-total.loss, .shore-error { color: #f7b39f; }
|
||||
.shore-note { color: #a8c2c1; font-size: 12px; margin-top: 3px; white-space: normal; }
|
||||
.shore-error { font-size: 13px; margin-top: 9px; white-space: normal; }
|
||||
.action.shore-save-plan { margin-left: 13px; }
|
||||
|
||||
.shore-berth {
|
||||
position: absolute;
|
||||
left: 30px;
|
||||
bottom: 98px;
|
||||
width: 330px;
|
||||
max-width: 45%;
|
||||
padding: 13px 15px;
|
||||
background-color: rgba(11, 29, 38, .97);
|
||||
border-width: 1px;
|
||||
border-color: #68807f;
|
||||
border-top-width: 2px;
|
||||
border-top-color: #91bdb0;
|
||||
border-radius: 3px;
|
||||
}
|
||||
.shore-berth.shore-berth-decision { border-top-color: #e3bf7d; }
|
||||
.shore-berth-title { color: #f1e6cd; font-size: 29px; margin-top: 3px; white-space: normal; }
|
||||
.shore-berth-detail { color: #c6d8d4; font-size: 13px; margin: 5px 0 7px; white-space: normal; }
|
||||
.shore-berth-clock { color: #dbebd2; font-size: 16px; -unity-font-style: bold; }
|
||||
.action.shore-decision {
|
||||
align-items: flex-start;
|
||||
margin-top: 6px;
|
||||
min-height: 48px;
|
||||
padding: 6px 9px;
|
||||
}
|
||||
.action.shore-decision-hold { border-color: #a78b60; background-color: #36423a; }
|
||||
.action.shore-decision-hold:hover, .action.shore-decision-hold:focus { border-color: #d8b77c; background-color: #485344; }
|
||||
.shore-decision-title { color: #f5ddad; font-size: 13px; white-space: normal; }
|
||||
.shore-decision-detail { color: #c3d4d0; font-size: 11px; margin-top: 2px; white-space: normal; -unity-font-style: normal; }
|
||||
12
Assets/Soundings/Resources/ShoreExcursions.uss.meta
Normal file
12
Assets/Soundings/Resources/ShoreExcursions.uss.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e7b1070756c9360b99d1efdd9b21fac
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
|
||||
disableValidation: 0
|
||||
unsupportedSelectorAction: 0
|
||||
@@ -60,6 +60,7 @@ namespace Soundings
|
||||
if (!CanRestoreFleetPassages(saved.Company, saved.Passages))
|
||||
return false;
|
||||
|
||||
ResetShorePlanning();
|
||||
if (harbor.PortCinematicActive)
|
||||
harbor.EndPortCinematic();
|
||||
if (underway != null)
|
||||
@@ -142,7 +143,8 @@ namespace Soundings
|
||||
|
||||
private void AutosaveCareer()
|
||||
{
|
||||
if (!title && !paused && fleetPassages.Count > 0 && Time.unscaledTime >= nextCareerAutosave)
|
||||
if (!title && !paused && Time.unscaledTime >= nextCareerAutosave && company != null
|
||||
&& (fleetPassages.Count > 0 || company.Fleet.Exists(ship => ship.ShoreCall != null)))
|
||||
Save();
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace Soundings
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class Ship
|
||||
public sealed partial class Ship
|
||||
{
|
||||
public string Name;
|
||||
public int HullIndex, Port, Condition, Fare, Fuel;
|
||||
@@ -165,17 +165,23 @@ namespace Soundings
|
||||
public int ItineraryStartDay, ItineraryLeg, ItineraryLegs;
|
||||
public OnboardReport Onboard;
|
||||
public DeparturePlan Plan;
|
||||
public ShoreOffer[] ShoreOffers;
|
||||
public int ShoreCallId;
|
||||
[SerializeReference] public ShoreReport ShoreReport;
|
||||
public WeatherCondition Weather;
|
||||
public int OperatingCash => Crew + Catering + PortFees + (Plan == null ? 0 : Plan.FoodCost + Plan.ProgramCost)
|
||||
+ (Onboard?.Expenses ?? 0);
|
||||
public int NetIncome => TicketSales + OnboardSales - OperatingCash - FuelExpense - LoanInterest;
|
||||
public int CashChange => TicketSales + OnboardSales - OperatingCash - LoanInterest - Principal;
|
||||
public int NetIncome => TicketSales + OnboardSales - OperatingCash - FuelExpense - LoanInterest + (ShoreReport?.NetIncome ?? 0);
|
||||
public int CashChange => TicketSales + OnboardSales - OperatingCash - LoanInterest - Principal + (ShoreReport?.NetIncome ?? 0);
|
||||
public int RequiredFuel => FuelBurn + Reserve;
|
||||
|
||||
internal Voyage CopyForPassage(bool hasDeparturePlan)
|
||||
{
|
||||
var copy = (Voyage)MemberwiseClone();
|
||||
copy.Onboard = null;
|
||||
copy.ShoreOffers = ShorePortPlan.Copy(ShoreOffers);
|
||||
copy.ShoreCallId = 0;
|
||||
copy.ShoreReport = null;
|
||||
copy.Plan = hasDeparturePlan && Plan != null ? new DeparturePlan
|
||||
{
|
||||
FoodUnits = Plan.FoodUnits, FoodCost = Plan.FoodCost, Program = Plan.Program, ProgramCost = Plan.ProgramCost
|
||||
@@ -226,6 +232,7 @@ namespace Soundings
|
||||
|| (Fleet.Count == 0 ? SelectedShip != -1 : SelectedShip < 0 || SelectedShip >= Fleet.Count))
|
||||
return false;
|
||||
|
||||
var callIds = new HashSet<int>();
|
||||
foreach (Ship ship in Fleet)
|
||||
{
|
||||
if (ship == null || string.IsNullOrWhiteSpace(ship.Name) || ship.HullIndex < 0 || ship.HullIndex >= Market.Hulls.Count
|
||||
@@ -242,13 +249,20 @@ namespace Soundings
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ship.Fuel > ship.Tank || !ValidSavedItinerary(ship))
|
||||
if (ship.Fuel > ship.Tank || !ValidSavedItinerary(ship) || !ship.ValidShorePlans()
|
||||
|| ship.ShoreCall is ShoreCall call && (call.CallId < 1 || call.CallId > Voyages
|
||||
|| !callIds.Add(call.CallId) || !call.CanLoad(ship.Port)))
|
||||
return false;
|
||||
}
|
||||
|
||||
var recordedCalls = new HashSet<int>();
|
||||
foreach (Voyage voyage in History)
|
||||
if (voyage == null || voyage.Origin < 0 || voyage.Origin >= Permits.Length
|
||||
|| voyage.Destination < 0 || voyage.Destination >= Permits.Length)
|
||||
|| voyage.Destination < 0 || voyage.Destination >= Permits.Length
|
||||
|| voyage.ShoreCallId < 0 || voyage.ShoreCallId > Voyages
|
||||
|| voyage.ShoreCallId > 0 && !recordedCalls.Add(voyage.ShoreCallId)
|
||||
|| voyage.ShoreReport is ShoreReport report && (callIds.Contains(voyage.ShoreCallId)
|
||||
|| !report.CanLoad(voyage.Destination, voyage.ShoreCallId)))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@@ -507,6 +521,7 @@ namespace Soundings
|
||||
{
|
||||
Origin = ship.Port,
|
||||
Destination = destination,
|
||||
ShoreOffers = ship.ExcursionsFor(destination),
|
||||
ShipName = ship.Name,
|
||||
Day = Day + days,
|
||||
Days = days,
|
||||
@@ -536,6 +551,8 @@ namespace Soundings
|
||||
{
|
||||
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.ShoreCall != null)
|
||||
return "Clear the shore excursion groups before departure.";
|
||||
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])
|
||||
@@ -587,6 +604,7 @@ namespace Soundings
|
||||
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;
|
||||
BookShoreCall(ship, quote);
|
||||
Day = quote.Day;
|
||||
Cash += quote.CashChange;
|
||||
Debt -= quote.Principal;
|
||||
@@ -597,7 +615,11 @@ namespace Soundings
|
||||
&& quote.Origin == Market.Bermuda && quote.Destination == Market.Lisbon;
|
||||
History.Insert(0, quote);
|
||||
if (History.Count > MaxHistory)
|
||||
History.RemoveAt(MaxHistory);
|
||||
{
|
||||
int archivalRecord = History.FindLastIndex(voyage => voyage.ShoreCallId == 0
|
||||
|| !Fleet.Exists(vessel => vessel.ShoreCall?.CallId == voyage.ShoreCallId));
|
||||
History.RemoveAt(archivalRecord >= 0 ? archivalRecord : MaxHistory);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
91
Assets/Soundings/Runtime/CompanyExcursions.cs
Normal file
91
Assets/Soundings/Runtime/CompanyExcursions.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Soundings
|
||||
{
|
||||
[Serializable]
|
||||
internal sealed class ShorePortPlan
|
||||
{
|
||||
public int Port;
|
||||
public ShoreOffer[] Offers;
|
||||
|
||||
internal static ShoreOffer[] Copy(ShoreOffer[] offers)
|
||||
{
|
||||
if (offers == null || offers.Length == 0)
|
||||
return Array.Empty<ShoreOffer>();
|
||||
var copy = new ShoreOffer[offers.Length];
|
||||
for (int i = 0; i < offers.Length; i++)
|
||||
{
|
||||
ShoreOffer offer = offers[i];
|
||||
copy[i] = new ShoreOffer { Tour = offer.Tour, Price = offer.Price, Capacity = offer.Capacity };
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed partial class Ship
|
||||
{
|
||||
[SerializeField] private List<ShorePortPlan> shorePlans;
|
||||
[SerializeReference] public ShoreCall ShoreCall;
|
||||
|
||||
internal ShoreOffer[] ExcursionsFor(int port) => ShorePortPlan.Copy(shorePlans?.Find(plan => plan.Port == port)?.Offers);
|
||||
|
||||
internal void SetExcursions(int port, ShoreOffer[] offers)
|
||||
{
|
||||
shorePlans ??= new List<ShorePortPlan>();
|
||||
shorePlans.RemoveAll(plan => plan.Port == port);
|
||||
if (offers.Length > 0)
|
||||
shorePlans.Add(new ShorePortPlan { Port = port, Offers = ShorePortPlan.Copy(offers) });
|
||||
}
|
||||
|
||||
internal bool ValidShorePlans()
|
||||
{
|
||||
if (shorePlans == null)
|
||||
return true;
|
||||
var ports = new HashSet<int>();
|
||||
foreach (ShorePortPlan plan in shorePlans)
|
||||
{
|
||||
if (plan == null || !ports.Add(plan.Port) || plan.Offers == null || plan.Offers.Length == 0
|
||||
|| !ShoreExcursions.ValidOffers(plan.Port, plan.Offers))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed partial class Company
|
||||
{
|
||||
private void BookShoreCall(Ship ship, Voyage quote)
|
||||
{
|
||||
if (quote.ShoreOffers is not { Length: > 0 })
|
||||
return;
|
||||
ShoreCall call = ShoreExcursions.Create(quote, quote.ShoreOffers);
|
||||
if (call == null)
|
||||
return;
|
||||
call.CallId = quote.ShoreCallId = Voyages + 1;
|
||||
ship.ShoreCall = call;
|
||||
}
|
||||
|
||||
internal ShoreReport CompleteShoreCall(Ship ship)
|
||||
{
|
||||
ShoreReport report = ship.ShoreCall?.Report();
|
||||
if (report == null)
|
||||
return null;
|
||||
|
||||
ship.ShoreCall = null;
|
||||
Cash += report.NetIncome;
|
||||
LifetimeProfit += report.NetIncome;
|
||||
Reputation = Market.Clamp(Reputation + report.ReputationImpact, 0, 100);
|
||||
Voyage voyage = History.Find(item => item.ShoreCallId == report.CallId);
|
||||
if (voyage != null)
|
||||
{
|
||||
voyage.ShoreReport = report;
|
||||
if (voyage.Onboard != null)
|
||||
voyage.Onboard.Happiness = Market.Clamp(voyage.Onboard.Happiness + report.GuestImpact, 0, 100);
|
||||
voyage.ReputationChange += report.ReputationImpact;
|
||||
}
|
||||
return report;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Soundings/Runtime/CompanyExcursions.cs.meta
Normal file
2
Assets/Soundings/Runtime/CompanyExcursions.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 49b3540c5b656880fb97879de0c069a9
|
||||
@@ -50,7 +50,7 @@ namespace Soundings
|
||||
|
||||
var deckControls = Add(titleBar, "work-deck-controls");
|
||||
var selector = Add(deckControls, "work-deck-selector");
|
||||
for (int i = 0; i < ship.Decks.Count; i++)
|
||||
for (int i = ship.Decks.Count - 1; i >= 0; i--)
|
||||
{
|
||||
int floor = i;
|
||||
Button level = Action($"Deck {i + 1}", () =>
|
||||
|
||||
@@ -134,11 +134,17 @@ namespace Soundings
|
||||
}
|
||||
row.Control.EnableInClassList("fleet-roster-selected", row.Ship == Ship);
|
||||
row.Status.EnableInClassList("fleet-ship-at-sea", voyage != null);
|
||||
row.Status.EnableInClassList("fleet-ship-shore-alert", row.Ship.ShoreCall?.Phase == ShorePhase.AwaitingDecision);
|
||||
if (voyage == null)
|
||||
{
|
||||
docked[group]++;
|
||||
SetPassageText(row.Status, $"Docked at {Market.Ports[row.Ship.Port].Name}");
|
||||
SetPassageText(row.Readout, $"{row.Ship.Fuel:N0} / {row.Ship.Tank:N0} t fuel · {row.Ship.Condition}% condition");
|
||||
SetPassageText(row.Readout, row.Ship.ShoreCall is ShoreCall shore ? shore.Phase switch
|
||||
{
|
||||
ShorePhase.AwaitingDecision => $"{shore.LateGuests:N0} guests late · Departure decision needed",
|
||||
ShorePhase.Holding => $"Holding for {shore.LateGuests:N0} guests",
|
||||
_ => $"{shore.Guests:N0} guests on shore excursions"
|
||||
} : $"{row.Ship.Fuel:N0} / {row.Ship.Tank:N0} t fuel · {row.Ship.Condition}% condition");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -176,6 +176,7 @@ namespace Soundings
|
||||
|| (uint)voyage.Weather > (uint)WeatherCondition.Storm || voyage.Guests < 1 || voyage.Guests > voyage.Capacity
|
||||
|| voyage.RoomDemand < voyage.Guests || voyage.Fare < Market.MinFare || voyage.Fare > Market.MaxFare
|
||||
|| voyage.TicketSales < 0 || voyage.FuelBurn < 1 || voyage.Reserve < 0 || voyage.Crew < 0 || voyage.Catering < 0
|
||||
|| ship.ShoreCall != null || !ShoreExcursions.ValidOffers(voyage.Destination, voyage.ShoreOffers)
|
||||
|| voyage.PortFees < 0 || voyage.LoanInterest < 0 || voyage.Principal < 0)
|
||||
return false;
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace Soundings
|
||||
if (company == null || paused || harbor.PortCinematicActive || index < 0 || index >= company.Fleet.Count)
|
||||
return;
|
||||
|
||||
ResetShorePlanning();
|
||||
fleetOpen = shipActionsOpen = false;
|
||||
if (index == company.SelectedShip)
|
||||
{
|
||||
@@ -156,8 +157,10 @@ namespace Soundings
|
||||
Save();
|
||||
}
|
||||
RefreshFleetMetrics();
|
||||
ShowFleetArrivalNotice(failure == null ? $"{ship.Name} arrived in {Market.Ports[ship.Port].Name}." : $"{ship.Name} · {failure}",
|
||||
failure != null);
|
||||
string arrival = $"{ship.Name} arrived in {Market.Ports[ship.Port].Name}.";
|
||||
if (ship.ShoreCall is ShoreCall call)
|
||||
arrival += $" {call.Guests:N0} guests heading ashore.";
|
||||
ShowFleetArrivalNotice(failure ?? arrival, failure != null);
|
||||
}
|
||||
|
||||
if (docked && underway == null && !fleetOpen && !harbor.PortCinematicActive)
|
||||
|
||||
@@ -169,10 +169,23 @@ namespace Soundings
|
||||
LogLine(statement, "Fuel expense", Money(-trip.FuelExpense));
|
||||
LogLine(statement, "Loan interest", Money(-trip.LoanInterest));
|
||||
LogLine(statement, "Principal repaid", Money(-trip.Principal));
|
||||
if (trip.ShoreReport is ShoreReport shore)
|
||||
{
|
||||
LogLine(statement, $"Shore excursion sales · {shore.Guests:N0} guests", Money(shore.Revenue));
|
||||
LogLine(statement, "Local operators", Money(-shore.OperatorCost));
|
||||
if (shore.Resolution != ShoreLateResolution.None)
|
||||
{
|
||||
string response = shore.Resolution == ShoreLateResolution.Held ? "Held at berth" : "Onward transport";
|
||||
LogLine(statement, $"{response} · {shore.LateGuests:N0} guests", Money(-shore.ExtraCost));
|
||||
}
|
||||
}
|
||||
else if (trip.ShoreCallId > 0 && company.Fleet.Exists(ship => ship.ShoreCall?.CallId == trip.ShoreCallId))
|
||||
AddText(statement, "Shore excursion accounts are still open.", "log-secondary");
|
||||
|
||||
var balances = Add(leaf, "log-totals");
|
||||
LogLine(balances, "Net voyage profit", Money(trip.NetIncome), LogAmountColor(trip.NetIncome));
|
||||
LogLine(balances, "Cash change on arrival", Money(trip.CashChange), LogAmountColor(trip.CashChange));
|
||||
LogLine(balances, trip.ShoreReport != null ? "Cash change including shore call" : "Cash change on arrival",
|
||||
Money(trip.CashChange), LogAmountColor(trip.CashChange));
|
||||
}
|
||||
|
||||
private void DrawAccounts(VisualElement left, VisualElement right)
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace Soundings
|
||||
passageBusinessOpen = !passageBusinessOpen;
|
||||
Render();
|
||||
}, "voyage-drawer-toggle", "passage-business"));
|
||||
DrawShorePlanningLink(opener, underway, true);
|
||||
if (passageBusinessOpen)
|
||||
DrawPassageBusiness(left);
|
||||
else
|
||||
@@ -58,14 +59,17 @@ namespace Soundings
|
||||
passageEventAccept = null;
|
||||
passageEventResult = null;
|
||||
|
||||
var decks = Add(overlay, "voyage-deck-stack");
|
||||
decks.pickingMode = PickingMode.Ignore;
|
||||
AddText(decks, "DECK VIEW", "voyage-caption voyage-deck-caption");
|
||||
AddPassageDeckButton(decks, -1, "Exterior", "passage-deck-all");
|
||||
for (int i = Ship.Decks.Count - 1; i >= 0; i--)
|
||||
AddPassageDeckButton(decks, i, $"Deck {i + 1}", $"passage-deck-{i}");
|
||||
|
||||
var footer = Add(overlay, "voyage-footer");
|
||||
footer.pickingMode = PickingMode.Ignore;
|
||||
var controls = Add(footer, "voyage-deckbar");
|
||||
controls.pickingMode = PickingMode.Ignore;
|
||||
AddText(controls, "SHIP VIEW", "voyage-caption voyage-deck-caption");
|
||||
AddPassageDeckButton(controls, -1, "Exterior", "passage-deck-all");
|
||||
for (int i = 0; i < Ship.Decks.Count; i++)
|
||||
AddPassageDeckButton(controls, i, $"Deck {i + 1}", $"passage-deck-{i}");
|
||||
controls.Add(Action("Bridge", ViewPassageBridge, PassageViewClass(passageBridge), "passage-bridge"));
|
||||
controls.Add(Action("Explore", ExplorePassageDeck, PassageViewClass(passageExploring && passageServiceArea < 0), "passage-explore"));
|
||||
controls.Add(Action("Service deck", () => ExploreServiceArea(0), PassageViewClass(passageServiceArea >= 0), "passage-service"));
|
||||
|
||||
@@ -85,6 +85,7 @@ namespace Soundings
|
||||
picker.Add(choice);
|
||||
}
|
||||
|
||||
var tools = Add(parent, "chart-forecast-tools");
|
||||
Button live = Action(selection.Loading ? "Checking…" : "Fetch live", () =>
|
||||
{
|
||||
selection.Loading = true;
|
||||
@@ -98,7 +99,8 @@ namespace Soundings
|
||||
live.style.paddingLeft = 5;
|
||||
live.style.paddingRight = 5;
|
||||
live.style.minHeight = 25;
|
||||
picker.Add(live);
|
||||
tools.Add(live);
|
||||
DrawShorePlanningLink(tools, quote, false);
|
||||
|
||||
if (!string.IsNullOrEmpty(selection.Status))
|
||||
AddText(parent, selection.Status, "chart-paper-note");
|
||||
|
||||
77
Assets/Soundings/Runtime/ShoreCallOperations.cs
Normal file
77
Assets/Soundings/Runtime/ShoreCallOperations.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
namespace Soundings
|
||||
{
|
||||
public sealed partial class SoundingsApp
|
||||
{
|
||||
private ShoreOffer[] CurrentShoreOffers(Voyage quote) => ShorePortPlan.Copy(quote?.ShoreOffers);
|
||||
|
||||
private bool ApplyShoreOffers(Voyage quote, ShoreOffer[] offers)
|
||||
{
|
||||
Ship ship = Ship;
|
||||
if (ship == null || quote == null || quote.Origin != ship.Port || paused || harbor.PortCinematicActive
|
||||
|| (underway != null ? quote != underway : page != 3 || inspectedPort != quote.Destination)
|
||||
|| !ShoreExcursions.ValidOffers(quote.Destination, offers))
|
||||
return false;
|
||||
|
||||
quote.ShoreOffers = ShorePortPlan.Copy(offers);
|
||||
ship.SetExcursions(quote.Destination, quote.ShoreOffers);
|
||||
Save();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void AdvanceShoreCalls(float delta)
|
||||
{
|
||||
bool redraw = false;
|
||||
foreach (Ship ship in company.Fleet)
|
||||
{
|
||||
if (ship.ShoreCall is not ShoreCall call || (ship == Ship && harbor.PortCinematicActive))
|
||||
continue;
|
||||
|
||||
ShorePhase previous = call.Phase;
|
||||
call.Advance(delta);
|
||||
bool completed = call.Phase == ShorePhase.Complete;
|
||||
if (completed)
|
||||
SettleShoreCall(ship);
|
||||
if (!completed && call.Phase == previous)
|
||||
continue;
|
||||
|
||||
Save();
|
||||
if (call.Phase == ShorePhase.AwaitingDecision && ship != Ship)
|
||||
ShowFleetArrivalNotice($"{ship.Name} needs a departure decision in {Market.Ports[ship.Port].Name}.", false);
|
||||
redraw |= ship == Ship || completed && underway == null && !ShorePlanningOpen;
|
||||
}
|
||||
|
||||
if (redraw && !fleetOpen && !harbor.PortCinematicActive)
|
||||
Render();
|
||||
else
|
||||
RefreshBerthExcursions();
|
||||
}
|
||||
|
||||
private void DecideShoreDeparture(bool hold)
|
||||
{
|
||||
Ship ship = Ship;
|
||||
if (paused || underway != null || ship?.ShoreCall is not ShoreCall call || !call.ResolveLate(hold))
|
||||
return;
|
||||
|
||||
if (call.Phase == ShorePhase.Complete)
|
||||
SettleShoreCall(ship);
|
||||
else
|
||||
Notify("Departure held for the returning group.");
|
||||
Save();
|
||||
Render();
|
||||
}
|
||||
|
||||
private void SettleShoreCall(Ship ship)
|
||||
{
|
||||
ShoreReport report = company.CompleteShoreCall(ship);
|
||||
if (report == null)
|
||||
return;
|
||||
|
||||
RefreshFleetMetrics();
|
||||
string message = $"{ship.Name} cleared for departure · {Money(report.NetIncome)} net from shore excursions.";
|
||||
if (ship == Ship)
|
||||
Notify(message);
|
||||
else
|
||||
ShowFleetArrivalNotice(message, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Soundings/Runtime/ShoreCallOperations.cs.meta
Normal file
2
Assets/Soundings/Runtime/ShoreCallOperations.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 35d16e3746edfe947a5e6435db56a997
|
||||
226
Assets/Soundings/Runtime/ShoreExcursionInterface.cs
Normal file
226
Assets/Soundings/Runtime/ShoreExcursionInterface.cs
Normal file
@@ -0,0 +1,226 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace Soundings
|
||||
{
|
||||
public sealed partial class SoundingsApp
|
||||
{
|
||||
private Voyage shorePlanningQuote;
|
||||
private Ship shorePlanningShip;
|
||||
private ShoreOffer[] shoreDraft;
|
||||
private ShoreCall displayedShoreCall;
|
||||
private Label shoreReturnClock;
|
||||
private int displayedShoreSeconds = -1;
|
||||
|
||||
private bool ShorePlanningOpen => shorePlanningQuote != null;
|
||||
|
||||
private void DrawShorePlanningLink(VisualElement parent, Voyage quote, bool atSea)
|
||||
{
|
||||
if (quote == null || ShoreExcursions.Catalog(quote.Destination).Count == 0)
|
||||
return;
|
||||
if (atSea)
|
||||
parent.AddToClassList("shore-passage-actions");
|
||||
|
||||
int offers = CurrentShoreOffers(quote)?.Length ?? 0;
|
||||
string buttonText = atSea || offers == 0 ? "Shore excursions" : $"Shore excursions · {offers} offered";
|
||||
Button link = Action(buttonText, () => OpenShorePlanning(quote),
|
||||
atSea ? "shore-passage-link" : "chart-ink-button shore-chart-link", "shore-planning-open");
|
||||
link.tooltip = $"Set excursion prices and seats for {Market.Ports[quote.Destination].Name}";
|
||||
parent.Add(link);
|
||||
}
|
||||
|
||||
private void OpenShorePlanning(Voyage quote)
|
||||
{
|
||||
IReadOnlyList<ShoreTour> catalog = ShoreExcursions.Catalog(quote.Destination);
|
||||
shorePlanningQuote = quote;
|
||||
shorePlanningShip = Ship;
|
||||
shoreDraft = new ShoreOffer[catalog.Count];
|
||||
for (int i = 0; i < catalog.Count; i++)
|
||||
shoreDraft[i] = new ShoreOffer { Tour = i, Price = catalog[i].StandardPrice, Capacity = 0 };
|
||||
|
||||
ShoreOffer[] saved = CurrentShoreOffers(quote);
|
||||
if (saved != null)
|
||||
foreach (ShoreOffer offer in saved)
|
||||
shoreDraft[offer.Tour] = new ShoreOffer { Tour = offer.Tour, Price = offer.Price, Capacity = offer.Capacity };
|
||||
Render();
|
||||
}
|
||||
|
||||
private void ResetShorePlanning()
|
||||
{
|
||||
shorePlanningQuote = null;
|
||||
shorePlanningShip = null;
|
||||
shoreDraft = null;
|
||||
}
|
||||
|
||||
private void CloseShorePlanning()
|
||||
{
|
||||
ResetShorePlanning();
|
||||
Render();
|
||||
}
|
||||
|
||||
private void DrawShorePlanning(VisualElement parent)
|
||||
{
|
||||
Voyage quote = shorePlanningQuote;
|
||||
if (quote == null || Ship != shorePlanningShip)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < parent.childCount; i++)
|
||||
parent[i].SetEnabled(false);
|
||||
var overlay = Add(parent, "shore-planning-overlay");
|
||||
var sheet = Add(overlay, "shore-planning-sheet");
|
||||
sheet.name = "shore-planning";
|
||||
|
||||
var heading = Add(sheet, "shore-planning-heading");
|
||||
var place = Add(heading, "shore-planning-place");
|
||||
AddText(place, Market.Ports[quote.Destination].Name.ToUpperInvariant(), "shore-kicker");
|
||||
AddDisplay(place, "Shore excursions", "shore-planning-title");
|
||||
heading.Add(Action("Close Esc", CloseShorePlanning, "shore-planning-close", "shore-planning-close"));
|
||||
string passengers = quote == underway ? $"{quote.Guests:N0} guests aboard" : $"{quote.Guests:N0} guests expected";
|
||||
AddText(sheet, $"Set prices and seats before docking. {passengers} · {quote.Weather} forecast.", "shore-planning-intro");
|
||||
|
||||
var tours = new ScrollView(ScrollViewMode.Vertical) { horizontalScrollerVisibility = ScrollerVisibility.Hidden };
|
||||
tours.AddToClassList("shore-tour-list");
|
||||
sheet.Add(tours);
|
||||
IReadOnlyList<ShoreTour> catalog = ShoreExcursions.Catalog(quote.Destination);
|
||||
var forecasts = new Label[catalog.Count];
|
||||
var offerButtons = new Button[catalog.Count];
|
||||
var tourCards = new VisualElement[catalog.Count];
|
||||
Label forecastTotal = null;
|
||||
for (int i = 0; i < catalog.Count; i++)
|
||||
{
|
||||
int index = i;
|
||||
ShoreTour tour = catalog[index];
|
||||
var card = tourCards[index] = Add(tours, "shore-tour");
|
||||
var header = Add(card, "shore-tour-header");
|
||||
var description = Add(header, "shore-tour-description");
|
||||
AddDisplay(description, tour.Name, "shore-tour-name");
|
||||
AddText(description, $"{tour.Hours:0.#} hr · {(tour.Outdoor ? "Outdoors" : "Mostly indoors")}", "shore-tour-facts");
|
||||
offerButtons[index] = Action("", () =>
|
||||
{
|
||||
IntegerField seats = card.Q<IntegerField>($"shore-capacity-{index}");
|
||||
seats.value = shoreDraft[index].Capacity > 0 ? 0 : Math.Min(24, tour.MaxCapacity);
|
||||
}, "shore-offer", $"shore-offer-{index}");
|
||||
header.Add(offerButtons[index]);
|
||||
AddText(card, tour.Description, "shore-tour-copy");
|
||||
|
||||
var controls = Add(card, "shore-tour-controls");
|
||||
AddShoreNumber(controls, "Price ($)", $"shore-price-{index}", shoreDraft[index].Price, tour.MinPrice, tour.MaxPrice,
|
||||
price => { shoreDraft[index].Price = price; RefreshForecasts(); });
|
||||
AddShoreNumber(controls, "Seats", $"shore-capacity-{index}", shoreDraft[index].Capacity, 0, tour.MaxCapacity,
|
||||
seats => { shoreDraft[index].Capacity = seats; RefreshForecasts(); });
|
||||
forecasts[index] = AddText(card, "", "shore-forecast");
|
||||
}
|
||||
|
||||
var footer = Add(sheet, "shore-planning-footer");
|
||||
var estimate = Add(footer, "shore-planning-estimate");
|
||||
forecastTotal = AddText(estimate, "", "shore-plan-total");
|
||||
AddText(estimate, "Projected before any late return costs.", "shore-note");
|
||||
Label error = AddText(sheet, "", "shore-error");
|
||||
error.style.display = DisplayStyle.None;
|
||||
footer.Add(Action("Save excursion plan", () =>
|
||||
{
|
||||
if (ApplyShoreOffers(quote, ActiveShoreOffers()))
|
||||
CloseShorePlanning();
|
||||
else
|
||||
{
|
||||
error.text = "This excursion plan is no longer available.";
|
||||
error.style.display = DisplayStyle.Flex;
|
||||
}
|
||||
}, "primary shore-save-plan", "shore-plan-save"));
|
||||
RefreshForecasts();
|
||||
|
||||
void RefreshForecasts()
|
||||
{
|
||||
ShoreBooking[] bookings = ShoreExcursions.Forecast(quote, ActiveShoreOffers());
|
||||
int guests = 0, net = 0;
|
||||
for (int i = 0; i < forecasts.Length; i++)
|
||||
{
|
||||
tourCards[i].EnableInClassList("shore-tour-offered", shoreDraft[i].Capacity > 0);
|
||||
offerButtons[i].text = shoreDraft[i].Capacity > 0 ? "Remove offer" : "Offer tour";
|
||||
forecasts[i].text = shoreDraft[i].Capacity > 0 ? "No bookings expected." : $"Set seats to offer this tour · Up to {catalog[i].MaxCapacity:N0}";
|
||||
}
|
||||
foreach (ShoreBooking booking in bookings)
|
||||
{
|
||||
guests += booking.Guests;
|
||||
net += booking.Revenue - booking.OperatorCost;
|
||||
forecasts[booking.Tour].text = $"{booking.Guests:N0} booked / {booking.Demand:N0} interested · "
|
||||
+ $"{Money(booking.OperatorCost)} operator cost · {booking.DelayRisk}% late risk";
|
||||
}
|
||||
forecastTotal.text = $"{guests:N0} expected guests · {Money(net)} projected net";
|
||||
forecastTotal.EnableInClassList("loss", net < 0);
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddShoreNumber(VisualElement parent, string label, string id, int current, int minimum, int maximum,
|
||||
Action<int> apply)
|
||||
{
|
||||
var field = new IntegerField(label) { name = id, value = current, tooltip = $"{minimum:N0}–{maximum:N0}" };
|
||||
Classes(field, "field shore-number");
|
||||
field.RegisterValueChangedCallback(change => apply(Mathf.Clamp(change.newValue, minimum, maximum)));
|
||||
field.RegisterCallback<FocusOutEvent>(_ => field.SetValueWithoutNotify(Mathf.Clamp(field.value, minimum, maximum)));
|
||||
parent.Add(field);
|
||||
}
|
||||
|
||||
private ShoreOffer[] ActiveShoreOffers()
|
||||
{
|
||||
return Array.FindAll(shoreDraft, offer => offer.Capacity > 0);
|
||||
}
|
||||
|
||||
private void DrawBerthExcursions(VisualElement parent)
|
||||
{
|
||||
displayedShoreCall = Ship?.ShoreCall;
|
||||
shoreReturnClock = null;
|
||||
displayedShoreSeconds = -1;
|
||||
if (displayedShoreCall is not ShoreCall call || call.Phase == ShorePhase.Complete)
|
||||
return;
|
||||
|
||||
var card = Add(parent, "shore-berth");
|
||||
card.name = "shore-operations";
|
||||
AddText(card, $"{Market.Ports[call.Port].Name.ToUpperInvariant()} / SHORE OPERATIONS", "shore-kicker");
|
||||
if (call.Phase == ShorePhase.AwaitingDecision)
|
||||
{
|
||||
card.AddToClassList("shore-berth-decision");
|
||||
AddDisplay(card, "Late shore excursion", "shore-berth-title");
|
||||
ShoreTour tour = ShoreExcursions.Catalog(call.Port)[call.LateTour];
|
||||
AddText(card, $"{call.LateGuests:N0} guests are still ashore. The last group is returning from {tour.Name}.",
|
||||
"shore-berth-detail");
|
||||
AddShoreDecision(card, "Hold departure", $"{Money(call.HoldCost)} berth costs · About {call.HoldMinutes} min until the group boards.",
|
||||
true, "shore-departure-hold");
|
||||
AddShoreDecision(card, "Arrange transport and depart",
|
||||
$"{Money(call.TransportCost)} transfer cost · Guests are safely transferred and satisfaction falls.",
|
||||
false, "shore-departure-transport");
|
||||
return;
|
||||
}
|
||||
|
||||
bool held = call.Phase == ShorePhase.Holding;
|
||||
AddDisplay(card, held ? "Departure held" : "Guests ashore", "shore-berth-title");
|
||||
AddText(card, held ? $"Waiting for {call.LateGuests:N0} guests to return."
|
||||
: $"{call.Guests:N0} guests on shore excursions. Tours must clear before your next departure.", "shore-berth-detail");
|
||||
shoreReturnClock = AddText(card, "", "shore-berth-clock");
|
||||
RefreshBerthExcursions();
|
||||
}
|
||||
|
||||
private void AddShoreDecision(VisualElement parent, string name, string detail, bool hold, string id)
|
||||
{
|
||||
Button option = Action("", () => DecideShoreDeparture(hold), hold ? "shore-decision shore-decision-hold" : "shore-decision", id);
|
||||
AddText(option, name, "shore-decision-title");
|
||||
AddText(option, detail, "shore-decision-detail");
|
||||
parent.Add(option);
|
||||
}
|
||||
|
||||
private void RefreshBerthExcursions()
|
||||
{
|
||||
if (shoreReturnClock == null || displayedShoreCall == null || displayedShoreCall != Ship?.ShoreCall)
|
||||
return;
|
||||
|
||||
int seconds = Mathf.CeilToInt(displayedShoreCall.RemainingSeconds);
|
||||
if (seconds == displayedShoreSeconds)
|
||||
return;
|
||||
|
||||
displayedShoreSeconds = seconds;
|
||||
shoreReturnClock.text = $"Return in {seconds / 60}:{seconds % 60:00}";
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Soundings/Runtime/ShoreExcursionInterface.cs.meta
Normal file
2
Assets/Soundings/Runtime/ShoreExcursionInterface.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 853e5da38960efd0d91b1f963568ce3c
|
||||
425
Assets/Soundings/Runtime/ShoreExcursions.cs
Normal file
425
Assets/Soundings/Runtime/ShoreExcursions.cs
Normal file
@@ -0,0 +1,425 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Soundings
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class ShoreOffer
|
||||
{
|
||||
public int Tour, Price, Capacity;
|
||||
}
|
||||
|
||||
public sealed class ShoreTour
|
||||
{
|
||||
public readonly string Name, Description;
|
||||
public readonly int StandardPrice, MinPrice, MaxPrice, MaxCapacity;
|
||||
public readonly float Hours;
|
||||
public readonly bool Outdoor;
|
||||
internal readonly int OperatorRate, BaseRisk;
|
||||
internal readonly double Appeal;
|
||||
|
||||
internal ShoreTour(string name, string description, int price, int operatorRate, int capacity, float hours,
|
||||
double appeal, int risk, bool outdoor = false)
|
||||
{
|
||||
Name = name;
|
||||
Description = description;
|
||||
StandardPrice = price;
|
||||
MinPrice = operatorRate + 8;
|
||||
MaxPrice = price * 3;
|
||||
MaxCapacity = capacity;
|
||||
Hours = hours;
|
||||
Outdoor = outdoor;
|
||||
OperatorRate = operatorRate;
|
||||
BaseRisk = risk;
|
||||
Appeal = appeal;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class ShoreBooking
|
||||
{
|
||||
public int Tour, Price, Capacity, Demand, Guests, Revenue, OperatorCost, DelayRisk;
|
||||
}
|
||||
|
||||
public enum ShorePhase { Touring = 1, AwaitingDecision, Holding, Complete }
|
||||
|
||||
public enum ShoreLateResolution { None, Held, AlternateTransport }
|
||||
|
||||
[Serializable]
|
||||
public sealed class ShoreCall
|
||||
{
|
||||
public int CallId, Port, Guests, Revenue, OperatorCost, LateGuests, LateTour, HoldCost, TransportCost, ExtraCost;
|
||||
public int GuestImpact, ReputationImpact, HoldMinutes;
|
||||
public float RemainingSeconds;
|
||||
public ShorePhase Phase;
|
||||
public ShoreLateResolution Resolution;
|
||||
public ShoreBooking[] Bookings;
|
||||
|
||||
public int NetIncome => Revenue - OperatorCost - ExtraCost;
|
||||
|
||||
public bool Advance(float seconds)
|
||||
{
|
||||
if (Phase is not (ShorePhase.Touring or ShorePhase.Holding) || !(seconds > 0))
|
||||
return false;
|
||||
|
||||
RemainingSeconds = Math.Max(0, RemainingSeconds - seconds);
|
||||
if (RemainingSeconds > 0)
|
||||
return false;
|
||||
Phase = Phase == ShorePhase.Touring && LateGuests > 0 ? ShorePhase.AwaitingDecision : ShorePhase.Complete;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool ResolveLate(bool hold)
|
||||
{
|
||||
if (Phase != ShorePhase.AwaitingDecision)
|
||||
return false;
|
||||
|
||||
if (hold)
|
||||
{
|
||||
Resolution = ShoreLateResolution.Held;
|
||||
ExtraCost = HoldCost;
|
||||
GuestImpact = Math.Max(-4, GuestImpact - 1);
|
||||
Phase = ShorePhase.Holding;
|
||||
RemainingSeconds = 7 + HoldMinutes / 8f;
|
||||
}
|
||||
else
|
||||
{
|
||||
Resolution = ShoreLateResolution.AlternateTransport;
|
||||
ExtraCost = TransportCost;
|
||||
GuestImpact = Math.Max(-10, GuestImpact - 3 - Math.Min(4, LateGuests / 6));
|
||||
ReputationImpact = Math.Max(-3, ReputationImpact - 3);
|
||||
Phase = ShorePhase.Complete;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public ShoreReport Report() => Phase != ShorePhase.Complete ? null : new ShoreReport
|
||||
{
|
||||
CallId = CallId, Port = Port, Guests = Guests, Revenue = Revenue, OperatorCost = OperatorCost, ExtraCost = ExtraCost,
|
||||
GuestImpact = GuestImpact, ReputationImpact = ReputationImpact, LateGuests = LateGuests, Bookings = Bookings,
|
||||
Resolution = Resolution
|
||||
};
|
||||
|
||||
public bool CanLoad(int shipPort)
|
||||
{
|
||||
if (CallId < 1 || Port != shipPort || !ShoreExcursions.ValidReceipt(Port, Bookings, Guests, Revenue, OperatorCost,
|
||||
ExtraCost, GuestImpact, ReputationImpact, LateGuests, Resolution))
|
||||
return false;
|
||||
int margin = Revenue - OperatorCost;
|
||||
if (!(RemainingSeconds >= 0 && RemainingSeconds <= 60) || HoldCost < 0 || HoldCost > margin
|
||||
|| TransportCost < 0 || TransportCost > margin)
|
||||
return false;
|
||||
if (LateGuests == 0 ? LateTour != -1 || HoldMinutes != 0 || HoldCost != 0 || TransportCost != 0
|
||||
: (uint)LateTour >= (uint)ShoreExcursions.Catalog(Port).Count || HoldMinutes < 10 || HoldMinutes > 120)
|
||||
return false;
|
||||
|
||||
return Phase switch
|
||||
{
|
||||
ShorePhase.Touring => RemainingSeconds > 0 && Resolution == ShoreLateResolution.None && ExtraCost == 0,
|
||||
ShorePhase.AwaitingDecision => RemainingSeconds == 0 && LateGuests > 0 && Resolution == ShoreLateResolution.None && ExtraCost == 0,
|
||||
ShorePhase.Holding => RemainingSeconds > 0 && LateGuests > 0 && Resolution == ShoreLateResolution.Held && ExtraCost == HoldCost,
|
||||
ShorePhase.Complete => RemainingSeconds == 0 && (LateGuests == 0 ? ExtraCost == 0 && Resolution == ShoreLateResolution.None
|
||||
: Resolution == ShoreLateResolution.Held && ExtraCost == HoldCost || Resolution == ShoreLateResolution.AlternateTransport && ExtraCost == TransportCost),
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class ShoreReport
|
||||
{
|
||||
public int CallId, Port, Guests, Revenue, OperatorCost, ExtraCost, GuestImpact, ReputationImpact, LateGuests;
|
||||
public ShoreBooking[] Bookings;
|
||||
public ShoreLateResolution Resolution;
|
||||
|
||||
public int NetIncome => Revenue - OperatorCost - ExtraCost;
|
||||
|
||||
public bool CanLoad(int port, int callId) => Port == port && CallId == callId && CallId > 0
|
||||
&& (LateGuests > 0 ? Resolution != ShoreLateResolution.None : Resolution == ShoreLateResolution.None)
|
||||
&& ShoreExcursions.ValidReceipt(Port, Bookings, Guests, Revenue, OperatorCost, ExtraCost, GuestImpact,
|
||||
ReputationImpact, LateGuests, Resolution);
|
||||
}
|
||||
|
||||
public static class ShoreExcursions
|
||||
{
|
||||
private static readonly IReadOnlyList<ShoreTour>[] PortTours =
|
||||
{
|
||||
new ShoreTour[] // Miami
|
||||
{
|
||||
new("Little Havana tasting walk", "Cafecito, bakeries and neighborhood music", 50, 24, 104, 2.5f, .33, 15),
|
||||
new("Everglades boardwalk", "Wetland trail and wildlife lookout", 82, 39, 84, 4, .49, 30, true)
|
||||
},
|
||||
new ShoreTour[] // Nassau
|
||||
{
|
||||
new("Old Nassau food walk", "Market stalls, local kitchens and Bahamian sweets", 54, 28, 114, 2, .39, 12),
|
||||
new("Coral reef catamaran", "Sail out to the reef and snorkel with a local guide", 94, 47, 84, 4, .52, 34, true)
|
||||
},
|
||||
new ShoreTour[] // Key West
|
||||
{
|
||||
new("Old Town porches", "A guide through lanes and shaded historic homes", 44, 18, 92, 2, .37, 12),
|
||||
new("Mangrove kayak circuit", "Paddle the mangrove channels with a guide", 78, 34, 68, 3.5f, .44, 29, true)
|
||||
},
|
||||
new ShoreTour[] // Cozumel
|
||||
{
|
||||
new("Island cacao workshop", "Stone-ground chocolate and a guided tasting", 58, 28, 88, 2.5f, .38, 13),
|
||||
new("Reef and beach launch", "A small-boat reef trip and time on the beach", 98, 45, 118, 4.5f, .53, 39, true)
|
||||
},
|
||||
new ShoreTour[] // San Juan
|
||||
{
|
||||
new("Old San Juan courtyards", "Historic streets and a guided fort visit", 61, 26, 126, 3, .41, 15),
|
||||
new("Rainforest trails", "A coach transfer to forest trails and waterfalls", 104, 51, 104, 5, .53, 39, true)
|
||||
},
|
||||
new ShoreTour[] // Bermuda
|
||||
{
|
||||
new("Dockyard naval history", "Maritime collections and a dockyard guide", 59, 27, 136, 2.5f, .40, 12),
|
||||
new("Pink-sand coast", "Beach time and a coastal lookout", 85, 42, 116, 4, .56, 30, true)
|
||||
},
|
||||
new ShoreTour[] // Ponta Delgada
|
||||
{
|
||||
new("Azorean tea and pastries", "Tea tasting and a small bakery stop", 64, 28, 144, 3.5f, .41, 22),
|
||||
new("Sete Cidades overlooks", "Volcanic lakes and high viewpoints", 96, 42, 144, 4.5f, .54, 33, true)
|
||||
},
|
||||
new ShoreTour[] // Lisbon
|
||||
{
|
||||
new("Belém tile and pastry walk", "A guide through tilework, monuments and pastry shops", 65, 24, 150, 3, .45, 20),
|
||||
new("Tagus sail", "An open-air sailing circuit along the waterfront", 99, 47, 176, 4, .45, 35, true)
|
||||
},
|
||||
new ShoreTour[] // Barcelona
|
||||
{
|
||||
new("Modernist architecture route", "Architectural interiors and a guide to the city", 88, 40, 176, 3.5f, .52, 20),
|
||||
new("Montjuïc gardens", "Hilltop views, gardens and outdoor galleries", 73, 32, 148, 4, .37, 29, true)
|
||||
},
|
||||
new ShoreTour[] // Port Said
|
||||
{
|
||||
new("Canal quarter and market", "A dockside guide and a covered market visit", 57, 24, 148, 2.5f, .39, 13),
|
||||
new("Canal lookout circuit", "Coach transfer to waterfront and canal overlooks", 86, 41, 132, 4, .45, 30, true)
|
||||
},
|
||||
new ShoreTour[] // Salalah
|
||||
{
|
||||
new("Frankincense souk", "Resins, spices and a guided look at local trade", 61, 26, 132, 3, .41, 19),
|
||||
new("Wadi and coastal drive", "Mountain roads, a wadi stop and an ocean lookout", 101, 52, 115, 4.5f, .49, 37, true)
|
||||
},
|
||||
new ShoreTour[] // Mumbai
|
||||
{
|
||||
new("Market kitchens", "Street snacks and a small-group cookery stop", 66, 30, 132, 3.5f, .47, 24),
|
||||
new("Elephanta ferry visit", "An island ferry and a guided walk to cave temples", 106, 49, 170, 5, .59, 35, true)
|
||||
},
|
||||
new ShoreTour[] // Singapore
|
||||
{
|
||||
new("Hawker food circuit", "Covered food stalls and a tasting itinerary", 72, 32, 164, 3, .49, 15),
|
||||
new("Harbor gardens at dusk", "Open garden paths and skyline overlooks", 104, 48, 200, 4.5f, .55, 26, true)
|
||||
},
|
||||
new ShoreTour[] // Benoa
|
||||
{
|
||||
new("Balinese craft workshop", "Woodcarving and textile demonstrations", 78, 36, 144, 3.5f, .43, 21),
|
||||
new("Rice terrace footpaths", "A coach journey and guided terrace walk", 114, 55, 136, 5, .55, 42, true)
|
||||
},
|
||||
new ShoreTour[] // Sydney
|
||||
{
|
||||
new("Opera House backstage", "A guided look into waterfront performance spaces", 94, 45, 160, 3, .49, 15),
|
||||
new("Harbour headlands", "Outdoor footpaths and panoramic harbor views", 118, 50, 176, 4.5f, .51, 32, true)
|
||||
},
|
||||
new ShoreTour[] // Auckland
|
||||
{
|
||||
new("Waterfront museum", "A guided maritime history and design visit", 71, 31, 142, 3, .44, 14),
|
||||
new("Volcanic rim walk", "Hilltop tracks and views across the harbors", 105, 48, 136, 4.5f, .50, 32, true)
|
||||
},
|
||||
new ShoreTour[] // Papeete
|
||||
{
|
||||
new("Island market and pearl studio", "A covered market visit and a pearl workshop", 74, 34, 118, 2.5f, .44, 18),
|
||||
new("Lagoon outrigger", "Outrigger trip with a reef-side swim stop", 126, 58, 120, 4.5f, .58, 41, true)
|
||||
},
|
||||
new ShoreTour[] // Honolulu
|
||||
{
|
||||
new("Chinatown flavors", "Markets, neighborhood history and local food", 82, 35, 136, 3, .44, 18),
|
||||
new("Diamond Head walk", "A crater trail and a high coastal lookout", 116, 51, 172, 4.5f, .56, 34, true)
|
||||
},
|
||||
new ShoreTour[] // San Diego
|
||||
{
|
||||
new("Balboa Park collections", "A guided selection of museums and architecture", 69, 29, 160, 3, .43, 17),
|
||||
new("La Jolla coastal walk", "Clifftops, tidal pools and shoreline wildlife", 92, 41, 142, 4, .48, 34, true)
|
||||
},
|
||||
new ShoreTour[] // Puerto Vallarta
|
||||
{
|
||||
new("Old Town cooking school", "A market ingredient stop and a kitchen lesson", 72, 36, 126, 3.5f, .48, 18),
|
||||
new("Bay wildlife boat", "A guided boat trip along the bay and reefs", 110, 55, 156, 4.5f, .53, 39, true)
|
||||
},
|
||||
new ShoreTour[] // Balboa
|
||||
{
|
||||
new("Canal locks and exhibits", "A guide to ship traffic and the lock exhibits", 81, 36, 184, 3.5f, .55, 20),
|
||||
new("Rainforest canopy circuit", "Forest trails and a canopy viewing platform", 124, 54, 138, 5, .48, 40, true)
|
||||
},
|
||||
new ShoreTour[] // Cartagena
|
||||
{
|
||||
new("Walled city kitchens", "Market ingredients, courtyards and regional cooking", 63, 27, 144, 3, .48, 18),
|
||||
new("Island beach launch", "A boat transfer to an offshore beach stop", 102, 51, 140, 4.5f, .54, 39, true)
|
||||
}
|
||||
};
|
||||
|
||||
public static IReadOnlyList<ShoreTour> Catalog(int port) => (uint)port < (uint)PortTours.Length
|
||||
? PortTours[port] : Array.Empty<ShoreTour>();
|
||||
|
||||
public static bool ValidOffers(int port, IReadOnlyList<ShoreOffer> offers)
|
||||
{
|
||||
if (offers == null || offers.Count == 0)
|
||||
return true;
|
||||
IReadOnlyList<ShoreTour> catalog = Catalog(port);
|
||||
if (offers.Count > catalog.Count)
|
||||
return false;
|
||||
|
||||
int seen = 0;
|
||||
foreach (ShoreOffer offer in offers)
|
||||
{
|
||||
if (offer == null || (uint)offer.Tour >= (uint)catalog.Count || (seen & (1 << offer.Tour)) != 0)
|
||||
return false;
|
||||
ShoreTour tour = catalog[offer.Tour];
|
||||
if (offer.Capacity < 0 || offer.Capacity > tour.MaxCapacity
|
||||
|| offer.Capacity > 0 && (offer.Price < tour.MinPrice || offer.Price > tour.MaxPrice))
|
||||
return false;
|
||||
seen |= 1 << offer.Tour;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static ShoreBooking[] Forecast(Voyage quote, IReadOnlyList<ShoreOffer> offers)
|
||||
{
|
||||
if (quote == null || quote.Guests <= 0 || offers == null || offers.Count == 0 || !ValidOffers(quote.Destination, offers))
|
||||
return Array.Empty<ShoreBooking>();
|
||||
|
||||
IReadOnlyList<ShoreTour> catalog = Catalog(quote.Destination);
|
||||
var bookings = new List<ShoreBooking>(offers.Count);
|
||||
int total = 0;
|
||||
foreach (ShoreOffer offer in offers)
|
||||
{
|
||||
if (offer.Capacity == 0)
|
||||
continue;
|
||||
ShoreTour tour = catalog[offer.Tour];
|
||||
double priceAppeal = Math.Pow((tour.StandardPrice + 14.0) / (offer.Price + 14.0), 1.35);
|
||||
double weatherAppeal = tour.Outdoor ? quote.Weather switch { WeatherCondition.Swell => .82, WeatherCondition.Storm => .46, _ => 1 } : 1;
|
||||
int demand = Math.Min(quote.Guests, (int)Math.Round(quote.Guests * tour.Appeal * priceAppeal * weatherAppeal));
|
||||
int guests = Math.Min(demand, offer.Capacity);
|
||||
int trafficRisk = 9 * guests / tour.MaxCapacity;
|
||||
int weatherRisk = quote.Weather switch { WeatherCondition.Swell => tour.Outdoor ? 12 : 3, WeatherCondition.Storm => tour.Outdoor ? 26 : 9, _ => 0 };
|
||||
bookings.Add(new ShoreBooking
|
||||
{
|
||||
Tour = offer.Tour, Price = offer.Price, Capacity = offer.Capacity, Demand = demand, Guests = guests,
|
||||
DelayRisk = Math.Min(85, tour.BaseRisk + trafficRisk + weatherRisk)
|
||||
});
|
||||
total += guests;
|
||||
}
|
||||
|
||||
int guestsLeft = quote.Guests;
|
||||
int projectedLeft = total;
|
||||
foreach (ShoreBooking booking in bookings)
|
||||
{
|
||||
int projected = booking.Guests;
|
||||
if (projectedLeft > guestsLeft)
|
||||
booking.Guests = (int)Math.Round((double)projected * guestsLeft / projectedLeft);
|
||||
guestsLeft -= booking.Guests;
|
||||
projectedLeft -= projected;
|
||||
booking.Revenue = booking.Guests * booking.Price;
|
||||
booking.OperatorCost = booking.Guests * catalog[booking.Tour].OperatorRate;
|
||||
}
|
||||
return bookings.ToArray();
|
||||
}
|
||||
|
||||
public static ShoreCall Create(Voyage quote, IReadOnlyList<ShoreOffer> offers)
|
||||
{
|
||||
ShoreBooking[] bookings = Forecast(quote, offers);
|
||||
if (bookings.Length == 0)
|
||||
return null;
|
||||
|
||||
var call = new ShoreCall { Port = quote.Destination, Bookings = bookings, LateTour = -1, Phase = ShorePhase.Touring };
|
||||
IReadOnlyList<ShoreTour> catalog = Catalog(quote.Destination);
|
||||
float longest = 0;
|
||||
int longestDelay = 0;
|
||||
int value = 0;
|
||||
foreach (ShoreBooking booking in bookings)
|
||||
{
|
||||
if (booking.Guests == 0)
|
||||
continue;
|
||||
ShoreTour tour = catalog[booking.Tour];
|
||||
longest = Math.Max(longest, tour.Hours);
|
||||
call.Guests += booking.Guests;
|
||||
call.Revenue += booking.Revenue;
|
||||
call.OperatorCost += booking.OperatorCost;
|
||||
value += booking.Guests * Math.Max(0, 2 - booking.Price / tour.StandardPrice);
|
||||
uint roll = DelaySeed(quote, booking.Tour);
|
||||
if (roll % 100 >= booking.DelayRisk)
|
||||
continue;
|
||||
int late = Math.Min(booking.Guests, Math.Max(2, booking.Guests / 7) + (int)(roll / 100 % 5));
|
||||
int minutes = 18 + (int)(roll / 500 % 34) + (tour.Outdoor && quote.Weather != WeatherCondition.Calm ? 12 : 0);
|
||||
call.LateGuests += late;
|
||||
if (minutes > longestDelay)
|
||||
{
|
||||
longestDelay = minutes;
|
||||
call.LateTour = booking.Tour;
|
||||
}
|
||||
}
|
||||
if (call.Guests == 0)
|
||||
return null;
|
||||
|
||||
call.RemainingSeconds = 13 + longest * 5;
|
||||
call.GuestImpact = Market.Clamp(1 + (value * 3 + call.Guests) / quote.Guests, 1, 7);
|
||||
if (quote.Onboard?.Health is > 0 and < 70)
|
||||
call.GuestImpact = Math.Max(1, call.GuestImpact - 1);
|
||||
call.ReputationImpact = call.Guests >= quote.Guests / 4 ? 2 : 1;
|
||||
if (call.LateGuests > 0)
|
||||
{
|
||||
int margin = call.Revenue - call.OperatorCost;
|
||||
call.HoldMinutes = longestDelay;
|
||||
call.HoldCost = Math.Min(margin * 3 / 4, 145 + longestDelay * 16);
|
||||
call.TransportCost = Math.Min(margin * 45 / 100, 90 + call.LateGuests * 24);
|
||||
}
|
||||
return call;
|
||||
}
|
||||
|
||||
internal static bool ValidReceipt(int port, ShoreBooking[] bookings, int guests, int revenue, int operatorCost,
|
||||
int extras, int guestImpact, int reputationImpact, int lateGuests, ShoreLateResolution resolution)
|
||||
{
|
||||
IReadOnlyList<ShoreTour> catalog = Catalog(port);
|
||||
if (bookings == null || bookings.Length == 0 || bookings.Length > catalog.Count || guests <= 0
|
||||
|| extras < 0 || extras > revenue - operatorCost || guestImpact < -10 || guestImpact > 7
|
||||
|| reputationImpact < -3 || reputationImpact > 2 || lateGuests < 0 || lateGuests > guests
|
||||
|| (uint)resolution > (uint)ShoreLateResolution.AlternateTransport)
|
||||
return false;
|
||||
|
||||
int seen = 0;
|
||||
int countedGuests = 0, countedRevenue = 0, countedOperatorCost = 0;
|
||||
foreach (ShoreBooking booking in bookings)
|
||||
{
|
||||
if (booking == null || (uint)booking.Tour >= (uint)catalog.Count || (seen & (1 << booking.Tour)) != 0)
|
||||
return false;
|
||||
ShoreTour tour = catalog[booking.Tour];
|
||||
if (booking.Price < tour.MinPrice || booking.Price > tour.MaxPrice || booking.Capacity <= 0 || booking.Capacity > tour.MaxCapacity
|
||||
|| booking.Guests < 0 || booking.Guests > booking.Capacity || booking.Demand < booking.Guests
|
||||
|| booking.Revenue != booking.Guests * booking.Price || booking.OperatorCost != booking.Guests * tour.OperatorRate
|
||||
|| booking.DelayRisk is < 0 or > 85)
|
||||
return false;
|
||||
seen |= 1 << booking.Tour;
|
||||
countedGuests += booking.Guests;
|
||||
countedRevenue += booking.Revenue;
|
||||
countedOperatorCost += booking.OperatorCost;
|
||||
}
|
||||
return countedGuests == guests && countedRevenue == revenue && countedOperatorCost == operatorCost;
|
||||
}
|
||||
|
||||
private static uint DelaySeed(Voyage quote, int tour)
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
uint seed = 2166136261U;
|
||||
foreach (char character in quote.ShipName ?? "")
|
||||
seed = (seed ^ character) * 16777619;
|
||||
seed = (seed ^ (uint)quote.Day) * 16777619;
|
||||
seed = (seed ^ (uint)quote.Origin) * 16777619;
|
||||
seed = (seed ^ (uint)quote.Destination) * 16777619;
|
||||
seed = (seed ^ (uint)tour) * 16777619;
|
||||
seed ^= seed >> 16;
|
||||
seed *= 0x7FEB352D;
|
||||
seed ^= seed >> 15;
|
||||
return seed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Soundings/Runtime/ShoreExcursions.cs.meta
Normal file
2
Assets/Soundings/Runtime/ShoreExcursions.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 55276b65dd4718ba9a34e1f470a8768e
|
||||
@@ -61,7 +61,7 @@ namespace Soundings
|
||||
root = document.rootVisualElement;
|
||||
root.style.flexGrow = 1;
|
||||
root.style.unityFontDefinition = interfaceFont;
|
||||
foreach (string sheet in new[] { "Soundings", "Shipwork", "Ledger", "FirstVoyageGuide", "Passage", "ServiceControls", "FleetOverview", "Careers" })
|
||||
foreach (string sheet in new[] { "Soundings", "Shipwork", "Ledger", "FirstVoyageGuide", "Passage", "ServiceControls", "FleetOverview", "Careers", "ShoreExcursions" })
|
||||
{
|
||||
StyleSheet stylesheet = Resources.Load<StyleSheet>(sheet);
|
||||
if (stylesheet != null)
|
||||
@@ -77,6 +77,7 @@ namespace Soundings
|
||||
|
||||
private void StartCompany(bool financed, string name = null)
|
||||
{
|
||||
ResetShorePlanning();
|
||||
ResetFleetPassages();
|
||||
company = Company.Start(financed);
|
||||
careerId = Guid.NewGuid().ToString("N");
|
||||
@@ -143,6 +144,7 @@ namespace Soundings
|
||||
{
|
||||
if (underway != null || paused)
|
||||
return;
|
||||
ResetShorePlanning();
|
||||
page = next;
|
||||
fleetOpen = shipActionsOpen = false;
|
||||
if (destination < 0)
|
||||
@@ -183,6 +185,8 @@ namespace Soundings
|
||||
{
|
||||
RefreshGuide();
|
||||
DrawShell();
|
||||
if (ShorePlanningOpen)
|
||||
DrawShorePlanning(root);
|
||||
if (paused)
|
||||
DrawPause();
|
||||
}
|
||||
@@ -321,7 +325,11 @@ namespace Soundings
|
||||
fleet.tooltip = "Fleet overview (F2)";
|
||||
hudLeft.Add(fleet);
|
||||
if (underway == null)
|
||||
{
|
||||
DrawHotbar(shell).SetEnabled(!paused && !fleetOpen);
|
||||
if (!paused && !fleetOpen)
|
||||
DrawBerthExcursions(shell);
|
||||
}
|
||||
|
||||
if (!paused && !fleetOpen)
|
||||
DrawGuide(shell);
|
||||
|
||||
@@ -158,6 +158,9 @@ namespace Soundings
|
||||
if (!SubmitSmoke("passage-deck-1") || !CheckSmoke(passageDeck == 1, "Inspect the second guest deck"))
|
||||
yield break;
|
||||
yield return CaptureSmoke(directory, "06-guest-deck");
|
||||
if (!CheckSmoke(root.Q<Button>("passage-deck-1")?.worldBound.yMin < root.Q<Button>("passage-deck-0")?.worldBound.yMin,
|
||||
"The deck stack puts the upper deck above Deck 1"))
|
||||
yield break;
|
||||
if (!CheckSmoke(harbor.HasActiveGuest(GuestActivity.Drink) && harbor.HasActiveGuest(GuestActivity.TendBar)
|
||||
&& harbor.HasActiveGuest(GuestActivity.Dine) && harbor.HasActiveGuest(GuestActivity.Watch),
|
||||
"The fitted bar, dining room, and entertainment venue are active"))
|
||||
@@ -573,6 +576,114 @@ namespace Soundings
|
||||
&& fleetOpen && root.Q("fleet-overview") != null && !harbor.PortCinematicActive,
|
||||
"Same-day arrivals settle without interrupting the fleet overview"))
|
||||
yield break;
|
||||
|
||||
const int tourPort = 2;
|
||||
const int tourIndex = 1;
|
||||
var tour = ShoreExcursions.Catalog(tourPort)[tourIndex];
|
||||
if (!SubmitSmoke("fleet-close") || !SubmitSmoke("nav-3") || !SubmitSmoke($"port-{tourPort}")
|
||||
|| (!company.Permits[tourPort] && !SubmitSmoke("permit"))
|
||||
|| !CheckSmoke(company.Refuel(Ship, 80) == null && Ship.Port == 1,
|
||||
"Prepare the flagship's Nassau to Key West shore call")
|
||||
|| !SubmitSmoke("weather-calm") || !SubmitSmoke("shore-planning-open"))
|
||||
yield break;
|
||||
IntegerField tourPrice = root.Q<IntegerField>($"shore-price-{tourIndex}");
|
||||
IntegerField tourCapacity = root.Q<IntegerField>($"shore-capacity-{tourIndex}");
|
||||
if (!CheckSmoke(tourPrice != null && tourCapacity != null && tourCapacity.value == 0
|
||||
&& root.Q<Label>(className: "shore-tour-name")?.text == ShoreExcursions.Catalog(tourPort)[0].Name
|
||||
&& ShoreExcursions.Catalog(tourPort)[0].Name != ShoreExcursions.Catalog(1)[0].Name,
|
||||
"Chart opens port-specific optional shore offers"))
|
||||
yield break;
|
||||
int shorePrice = tour.MinPrice + 1;
|
||||
int shoreCapacity = Math.Min(tour.MaxCapacity, 24);
|
||||
tourPrice.value = shorePrice;
|
||||
tourCapacity.value = shoreCapacity;
|
||||
yield return CaptureSmoke(directory, "20-shore-excursion-planner");
|
||||
if (!SubmitSmoke("shore-plan-save") || !SubmitSmoke("dispatch") || !SubmitSmoke("port-cinematic-skip")
|
||||
|| !CheckSmoke(underway?.ShoreOffers is { Length: 1 } && underway.ShoreOffers[0].Price == shorePrice
|
||||
&& underway.ShoreOffers[0].Capacity == shoreCapacity, "Configured prices and capacity carry into the voyage")
|
||||
|| !SubmitSmoke("shore-planning-open"))
|
||||
yield break;
|
||||
tourPrice = root.Q<IntegerField>($"shore-price-{tourIndex}");
|
||||
tourCapacity = root.Q<IntegerField>($"shore-capacity-{tourIndex}");
|
||||
if (!CheckSmoke(tourPrice?.value == shorePrice && tourCapacity?.value == shoreCapacity,
|
||||
"Underway planning shows the current offer before docking"))
|
||||
yield break;
|
||||
tourPrice.value = --shorePrice;
|
||||
tourCapacity.value = --shoreCapacity;
|
||||
if (!SubmitSmoke("shore-plan-save")
|
||||
|| !CheckSmoke(underway.ShoreOffers[0].Price == shorePrice && underway.ShoreOffers[0].Capacity == shoreCapacity,
|
||||
"Adjust ticket price and capacity during the crossing"))
|
||||
yield break;
|
||||
Voyage crossingWithShorePlan = underway;
|
||||
if (!SubmitSmoke("company-menu") || !SubmitSmoke("career-save")
|
||||
|| !SubmitSmoke("career-load-open") || !SubmitSmoke("career-load-0")
|
||||
|| !CheckSmoke(underway != null && underway != crossingWithShorePlan
|
||||
&& underway.ShoreOffers is { Length: 1 } && underway.ShoreOffers[0].Price == shorePrice
|
||||
&& underway.ShoreOffers[0].Capacity == shoreCapacity,
|
||||
"A mid-voyage save resumes the updated excursion plan"))
|
||||
yield break;
|
||||
|
||||
int originalArrivalDay = underway.Day;
|
||||
while (!(ShoreExcursions.Create(underway, underway.ShoreOffers)?.LateGuests > 0)
|
||||
&& underway.Day < originalArrivalDay + 180)
|
||||
underway.Day++;
|
||||
if (!CheckSmoke(ShoreExcursions.Create(underway, underway.ShoreOffers)?.LateGuests > 0,
|
||||
"Find a deterministic late return for the smoke scenario")
|
||||
|| !SubmitSmoke("dock-now") || !SubmitSmoke("port-cinematic-skip")
|
||||
|| !CheckSmoke(Ship.Port == tourPort && Ship.ShoreCall?.Phase == ShorePhase.Touring
|
||||
&& root.Q("shore-operations") != null, "Docking begins the selected port's shore visit"))
|
||||
yield break;
|
||||
if (!SubmitSmoke("nav-3") || !SubmitSmoke("port-0")
|
||||
|| !CheckSmoke(root.Q<Button>("dispatch")?.enabledInHierarchy == false,
|
||||
"Next departure is blocked while excursion guests are ashore")
|
||||
|| !SubmitSmoke("nav-0") || !SubmitSmoke("company-menu") || !SubmitSmoke("career-save"))
|
||||
yield break;
|
||||
int shoreCash = company.Cash;
|
||||
int shoreVoyages = company.Voyages;
|
||||
int lateGuests = Ship.ShoreCall.LateGuests;
|
||||
float shoreTime = Ship.ShoreCall.RemainingSeconds;
|
||||
Company beforeShoreLoad = company;
|
||||
if (!SubmitSmoke("career-load-open") || !SubmitSmoke("career-load-0")
|
||||
|| !CheckSmoke(company != beforeShoreLoad && Ship.ShoreCall?.Phase == ShorePhase.Touring
|
||||
&& Ship.ShoreCall.LateGuests == lateGuests && Mathf.Abs(Ship.ShoreCall.RemainingSeconds - shoreTime) < .01f,
|
||||
"Loading restores the shore clock and the same delayed group"))
|
||||
yield break;
|
||||
AdvanceShoreCalls(120);
|
||||
if (!CheckSmoke(Ship.ShoreCall?.Phase == ShorePhase.AwaitingDecision,
|
||||
"Late returning guests require a decision before departure"))
|
||||
yield break;
|
||||
yield return CaptureSmoke(directory, "21-shore-departure-decision");
|
||||
if (!SubmitSmoke("shore-departure-hold")
|
||||
|| !CheckSmoke(Ship.ShoreCall?.Phase == ShorePhase.Holding && Ship.Port == tourPort,
|
||||
"Hold departure gives the late group time to return"))
|
||||
yield break;
|
||||
AdvanceShoreCalls(120);
|
||||
ShoreReport heldReport = company.History[0].ShoreReport;
|
||||
if (!CheckSmoke(Ship.ShoreCall == null && company.Voyages == shoreVoyages
|
||||
&& heldReport?.Resolution == ShoreLateResolution.Held && heldReport.LateGuests == lateGuests
|
||||
&& company.Cash == shoreCash + heldReport.NetIncome,
|
||||
"The completed shore call settles once in the voyage's logbook"))
|
||||
yield break;
|
||||
if (!SubmitSmoke("nav-4"))
|
||||
yield break;
|
||||
yield return CaptureSmoke(directory, "22-shore-excursion-settlement");
|
||||
if (!SubmitSmoke("company-menu") || !SubmitSmoke("career-load-open") || !SubmitSmoke("career-load-0"))
|
||||
yield break;
|
||||
AdvanceShoreCalls(120);
|
||||
if (!SubmitSmoke("shore-departure-transport"))
|
||||
yield break;
|
||||
ShoreReport transportReport = company.History[0].ShoreReport;
|
||||
if (!CheckSmoke(Ship.ShoreCall == null && company.Voyages == shoreVoyages
|
||||
&& transportReport?.Resolution == ShoreLateResolution.AlternateTransport
|
||||
&& transportReport.ExtraCost < heldReport.ExtraCost && transportReport.GuestImpact < heldReport.GuestImpact
|
||||
&& company.Cash == shoreCash + transportReport.NetIncome,
|
||||
"Arranging onward transport clears the call with cheaper costs and a worse guest survey"))
|
||||
yield break;
|
||||
if (!SubmitSmoke("nav-3") || !SubmitSmoke("port-0")
|
||||
|| !CheckSmoke(root.Q<Button>("dispatch")?.enabledInHierarchy == true,
|
||||
"Resolve the late group and clear the next departure"))
|
||||
yield break;
|
||||
|
||||
Debug.Log($"Soundings player smoke passed at {Screen.width} × {Screen.height}.");
|
||||
Application.Quit(0);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,10 @@ namespace Soundings
|
||||
if (harbor.PortCinematicActive)
|
||||
{
|
||||
if (!paused)
|
||||
{
|
||||
AdvanceShoreCalls(delta);
|
||||
UpdateBackgroundPassages(delta);
|
||||
}
|
||||
if (holdCinematicClock)
|
||||
return;
|
||||
if (Input.GetKeyDown(KeyCode.Escape))
|
||||
@@ -41,7 +44,9 @@ namespace Soundings
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Escape))
|
||||
{
|
||||
if (!paused && fleetOpen)
|
||||
if (ShorePlanningOpen)
|
||||
CloseShorePlanning();
|
||||
else if (!paused && fleetOpen)
|
||||
ToggleFleetOverview();
|
||||
else if (!paused && underway != null && voyageMapOpen)
|
||||
ToggleVoyageMap();
|
||||
@@ -60,8 +65,9 @@ namespace Soundings
|
||||
|
||||
if (!paused && !title)
|
||||
{
|
||||
if (!EditingText() && Input.GetKeyDown(KeyCode.F2))
|
||||
if (!ShorePlanningOpen && !EditingText() && Input.GetKeyDown(KeyCode.F2))
|
||||
ToggleFleetOverview();
|
||||
AdvanceShoreCalls(delta);
|
||||
UpdateBackgroundPassages(delta);
|
||||
}
|
||||
|
||||
@@ -76,7 +82,7 @@ namespace Soundings
|
||||
return;
|
||||
}
|
||||
|
||||
if (title || paused || fleetOpen || EditingText())
|
||||
if (title || paused || fleetOpen || ShorePlanningOpen || EditingText())
|
||||
return;
|
||||
|
||||
if (page == 1 && Input.GetKeyDown(KeyCode.R))
|
||||
@@ -105,7 +111,7 @@ namespace Soundings
|
||||
if (passageHelm.Manual)
|
||||
ReleaseHelm();
|
||||
}
|
||||
else
|
||||
else if (!ShorePlanningOpen)
|
||||
rudder = ReadNavigationControls();
|
||||
|
||||
passageHelm.Advance(delta * passageSpeed, rudder, livePassage.SpeedFactor, underway.Weather);
|
||||
@@ -123,7 +129,7 @@ namespace Soundings
|
||||
return;
|
||||
}
|
||||
|
||||
if (!fleetOpen)
|
||||
if (!fleetOpen && !ShorePlanningOpen)
|
||||
UpdatePassageView(delta);
|
||||
|
||||
UpdatePassageUi(progress);
|
||||
@@ -265,6 +271,7 @@ namespace Soundings
|
||||
}
|
||||
|
||||
var passage = new FleetPassage(ship, quote, company.Voyages < 3 && ship.HullIndex == 0);
|
||||
ResetShorePlanning();
|
||||
fleetPassages.Add(ship, passage);
|
||||
UpdateVoyageReserves();
|
||||
fleetOpen = shipActionsOpen = false;
|
||||
@@ -347,6 +354,7 @@ namespace Soundings
|
||||
{
|
||||
if (underway == null || paused || harbor.PortCinematicActive)
|
||||
return;
|
||||
ResetShorePlanning();
|
||||
Voyage voyage = underway;
|
||||
string failure = SettleFleetPassage(Ship, livePassage);
|
||||
if (failure != null)
|
||||
@@ -360,10 +368,12 @@ namespace Soundings
|
||||
selectedVoyage = 0;
|
||||
ledgerRecordOffset = 0;
|
||||
ledgerAccounts = false;
|
||||
page = 4;
|
||||
page = Ship.ShoreCall != null ? 0 : 4;
|
||||
ReviewGuideVoyage();
|
||||
string arrival = $"Arrived in {Market.Ports[voyage.Destination].Name}.";
|
||||
if (voyage.ItineraryLeg > 0)
|
||||
if (Ship.ShoreCall is ShoreCall call)
|
||||
arrival += $" {call.Guests:N0} guests heading ashore.";
|
||||
else if (voyage.ItineraryLeg > 0)
|
||||
arrival += Ship.Itinerary is { HasNext: true } itinerary
|
||||
? $" Next call is {Market.Ports[itinerary.NextPort].Name}."
|
||||
: " Itinerary complete.";
|
||||
|
||||
Reference in New Issue
Block a user