Make voyages active with dockside orders, crew calls, and ship PA
This commit is contained in:
168
Assets/Soundings/Runtime/OnboardRounds.cs
Normal file
168
Assets/Soundings/Runtime/OnboardRounds.cs
Normal file
@@ -0,0 +1,168 @@
|
||||
using System;
|
||||
|
||||
namespace Soundings
|
||||
{
|
||||
public sealed partial class OnboardSession
|
||||
{
|
||||
private static readonly float[] CrewCallSchedule = { .12f, .43f, .71f };
|
||||
private readonly int[] stationReadyAt = new int[(int)StationKind.Pool + 1];
|
||||
private readonly int[] stationBoostUntil = new int[ServiceKinds];
|
||||
private int nextCrewCall, crewCallDeadline;
|
||||
|
||||
internal StationKind? CrewCall { get; private set; }
|
||||
internal int CrewRequestsCompleted { get; private set; }
|
||||
internal int CrewRoundsLeft => CrewCall == null ? 0 : crewCallDeadline - tick;
|
||||
private double CrewSurveyBonus => CrewRequestsCompleted * 1.6;
|
||||
|
||||
internal static string StationName(StationKind station) => station switch
|
||||
{
|
||||
StationKind.Helm => "Bridge helm",
|
||||
StationKind.Engine => "Engine control",
|
||||
StationKind.Galley => "Galley pass",
|
||||
StationKind.Stores => "Provision stores",
|
||||
StationKind.Maintenance => "Maintenance bench",
|
||||
StationKind.Water => "Freshwater pumps",
|
||||
StationKind.Waste => "Treatment plant",
|
||||
StationKind.Cabins => "Cabin service",
|
||||
StationKind.Dining => "Dining host",
|
||||
StationKind.Bar => "Bar counter",
|
||||
StationKind.Stage => "Show lounge",
|
||||
_ => "Pool terrace"
|
||||
};
|
||||
|
||||
internal string StationAction(StationKind station) => station switch
|
||||
{
|
||||
StationKind.Engine => $"Set {EngineOrderName(NextEngineOrder())} power",
|
||||
StationKind.Galley => $"Staff an extra shift · ${GalleyCost:N0}",
|
||||
StationKind.Stores => $"Release the reserve · ${StoreCost:N0}",
|
||||
StationKind.Maintenance => $"Service machinery · ${RepairCost:N0}",
|
||||
StationKind.Water => $"Boost pumps · ${PumpCost:N0}",
|
||||
StationKind.Waste => $"Start extra treatment · ${TreatmentCost:N0}",
|
||||
StationKind.Cabins => "Check in with guests",
|
||||
StationKind.Dining => $"Call an extra seating · ${GalleyCost:N0}",
|
||||
StationKind.Bar => "Start happy hour · 25% off",
|
||||
StationKind.Stage => CanAdvancePerformance ? "Call the booked act" : "Open overflow seating",
|
||||
StationKind.Pool => "Host a poolside game",
|
||||
_ => "Take the helm"
|
||||
};
|
||||
|
||||
internal string StationBlock(StationKind station)
|
||||
{
|
||||
if (tick >= ticks)
|
||||
return "Service has ended for this crossing";
|
||||
if (stationReadyAt[(int)station] > tick)
|
||||
return "The crew is handling this station";
|
||||
return station switch
|
||||
{
|
||||
StationKind.Galley or StationKind.Dining when GalleyBoost => "The extra shift is already running",
|
||||
StationKind.Galley or StationKind.Dining when !CanSpend(GalleyCost) => "No room in the operating budget",
|
||||
StationKind.Dining when ProvisionsRemaining < 12 => "Too little food in stores for another seating",
|
||||
StationKind.Stores when StoresOpened => "The reserve has already been released",
|
||||
StationKind.Stores when !CanOpenStores => "Reserve stock is unavailable at this level or budget",
|
||||
StationKind.Maintenance when Ship.Condition == 100 || RepairCredit > 0 => "Machinery is already serviced",
|
||||
StationKind.Maintenance when !CanSpend(RepairCost) => "No room in the operating budget",
|
||||
StationKind.Water when PumpsBoost => "The boost pumps are running",
|
||||
StationKind.Water when !CanSpend(PumpCost) => "No room in the operating budget",
|
||||
StationKind.Waste when TreatmentBoost => "Extra treatment is already running",
|
||||
StationKind.Waste when !CanSpend(TreatmentCost) => "No room in the operating budget",
|
||||
StationKind.Bar when DiscountTicks(OnboardService.Drinks) > 0 => "Happy hour is already underway",
|
||||
StationKind.Bar when GetPrice(OnboardService.Drinks) == 0 || capacity[(int)OnboardService.Drinks] == 0 => "There is no paid bar service to promote",
|
||||
StationKind.Stage when capacity[(int)OnboardService.Shows] == 0 => "No show lounge is fitted",
|
||||
StationKind.Pool when Quote.Weather == WeatherCondition.Storm => "The terrace is closed in this weather",
|
||||
StationKind.Pool when WaterPercent < 22 => "Freshwater is too low for pool operation",
|
||||
_ => null
|
||||
};
|
||||
}
|
||||
|
||||
internal bool TryWorkStation(StationKind station, out string result)
|
||||
{
|
||||
result = StationBlock(station);
|
||||
if (result != null || station == StationKind.Helm)
|
||||
return false;
|
||||
|
||||
switch (station)
|
||||
{
|
||||
case StationKind.Engine: SetEngineMode(NextEngineOrder()); break;
|
||||
case StationKind.Galley:
|
||||
case StationKind.Dining: ExtendGalley(); break;
|
||||
case StationKind.Stores: OpenStores(); break;
|
||||
case StationKind.Maintenance: ServiceMachinery(); break;
|
||||
case StationKind.Water: RunBoostPumps(); break;
|
||||
case StationKind.Waste: BoostTreatment(); break;
|
||||
case StationKind.Bar: StartSpecial(OnboardService.Drinks); break;
|
||||
case StationKind.Stage:
|
||||
if (!TryAdvancePerformance())
|
||||
stationBoostUntil[(int)OnboardService.Shows] = tick + 6;
|
||||
break;
|
||||
case StationKind.Pool: stationBoostUntil[(int)OnboardService.Amenities] = tick + 6; break;
|
||||
}
|
||||
stationReadyAt[(int)station] = tick + (station == StationKind.Engine ? 1 : 8);
|
||||
|
||||
bool answered = station == CrewCall;
|
||||
if (answered)
|
||||
{
|
||||
CrewRequestsCompleted++;
|
||||
CrewCall = null;
|
||||
}
|
||||
if (answered || station is StationKind.Cabins or StationKind.Pool or StationKind.Stage)
|
||||
satisfaction = Math.Min(100, satisfaction + (answered ? 4 : 2));
|
||||
Measure(false);
|
||||
result = answered ? "Crew call answered · Guest survey improved" : StationResult(station);
|
||||
return true;
|
||||
}
|
||||
|
||||
private string StationResult(StationKind station) => station switch
|
||||
{
|
||||
StationKind.Engine => $"Engine order acknowledged · {EngineOrderName(EngineMode)}",
|
||||
StationKind.Galley or StationKind.Dining => "Extra service is running",
|
||||
StationKind.Stores => $"Reserve delivered · {ProvisionsRemaining:N0} portions aboard",
|
||||
StationKind.Maintenance => "Service logged · Less wear on arrival",
|
||||
StationKind.Water => "Freshwater boost is running",
|
||||
StationKind.Waste => "Treatment boost is running",
|
||||
StationKind.Cabins => "Guest services checked in · Survey improved",
|
||||
StationKind.Bar => "Happy hour started · Drinks are 25% off",
|
||||
StationKind.Stage => "Show lounge ready for guests",
|
||||
_ => "Poolside game started · More terrace capacity"
|
||||
};
|
||||
|
||||
private int NextEngineOrder() => EngineMode == 2 || !CanSetEngineMode(EngineMode + 1) ? 0 : EngineMode + 1;
|
||||
private static string EngineOrderName(int mode) => mode == 0 ? "Economy" : mode == 1 ? "Cruise" : "Power";
|
||||
|
||||
private int CrewServiceBoost(int service) => stationBoostUntil[service] <= tick ? 0
|
||||
: service == (int)OnboardService.Shows ? 42 : 24;
|
||||
|
||||
private void AdvanceCrewRequest()
|
||||
{
|
||||
if (CrewCall != null && tick >= crewCallDeadline)
|
||||
CrewCall = null;
|
||||
if (CrewCall != null || nextCrewCall >= CrewCallSchedule.Length || tick < ticks * CrewCallSchedule[nextCrewCall])
|
||||
return;
|
||||
|
||||
StationKind station;
|
||||
switch (nextCrewCall++)
|
||||
{
|
||||
case 0:
|
||||
station = ProvisionsRemaining < Quote.Guests && StationBlock(StationKind.Stores) == null
|
||||
? StationKind.Stores : StationKind.Galley;
|
||||
break;
|
||||
case 1:
|
||||
station = capacity[(int)OnboardService.Shows] > 0 ? StationKind.Stage : StationKind.Cabins;
|
||||
break;
|
||||
default:
|
||||
if (WaterPercent < 33)
|
||||
station = StationKind.Water;
|
||||
else if (SewagePercent > 68)
|
||||
station = StationKind.Waste;
|
||||
else
|
||||
station = capacity[(int)OnboardService.Drinks] > 0 ? StationKind.Bar : StationKind.Maintenance;
|
||||
break;
|
||||
}
|
||||
if (StationBlock(station) != null)
|
||||
station = StationKind.Cabins;
|
||||
if (StationBlock(station) != null)
|
||||
return;
|
||||
CrewCall = station;
|
||||
crewCallDeadline = Math.Min(ticks, tick + Math.Max(6, ticks / 6));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user