Rebrand as Big Ship Tycoon and add crew operations
This commit is contained in:
@@ -5,13 +5,17 @@ namespace Soundings
|
||||
public sealed partial class OnboardSession
|
||||
{
|
||||
private const double PortionPerMeal = .26;
|
||||
private const int WaterPerLaundryLoad = 10;
|
||||
private static readonly double[] FuelRates = { .78, 1, 1.22 };
|
||||
private static readonly float[] ShipSpeeds = { .82f, 1, 1.22f };
|
||||
private double provisions, water, waste, fuelIntegrated, health = 99, hydration = 1;
|
||||
private int galleyUntil, pumpsUntil, treatmentUntil;
|
||||
private double laundryBacklog, laundryCleaned;
|
||||
private int galleyUntil, pumpsUntil, treatmentUntil, laundryUntil;
|
||||
private int[] crewComplement;
|
||||
private readonly double[] crewCoverage = new double[CrewMarket.Roles.Count];
|
||||
public bool Assisted { get; set; } = true;
|
||||
public int EngineMode { get; private set; } = 1;
|
||||
public float SpeedFactor => ShipSpeeds[EngineMode];
|
||||
public float SpeedFactor => ShipSpeeds[EngineMode] * (float)(.86 + .14 * Coverage(CrewRole.Bridge));
|
||||
public int Health => (int)Math.Round(health);
|
||||
public int WaterPercent => (int)Math.Round(100 * water / Ship.WaterCapacity);
|
||||
public int SewagePercent => (int)Math.Round(100 * waste / Ship.WasteCapacity);
|
||||
@@ -22,17 +26,28 @@ namespace Soundings
|
||||
public bool GalleyBoost => galleyUntil > tick;
|
||||
public bool PumpsBoost => pumpsUntil > tick;
|
||||
public bool TreatmentBoost => treatmentUntil > tick;
|
||||
public bool LaundryBoost => laundryUntil > tick;
|
||||
public int LaundryDemand { get; private set; }
|
||||
public int LaundryCapacity => Math.Min(138 + Ship.HullIndex * 140, AssignedCrew(CrewRole.Laundry) * 22)
|
||||
+ (LaundryBoost ? Math.Min(58, AssignedCrew(CrewRole.Laundry) * 9) : 0);
|
||||
public int LaundryBacklog => (int)Math.Ceiling(laundryBacklog);
|
||||
public int LaundryCleaned => (int)Math.Floor(laundryCleaned);
|
||||
public int GalleyCost => 420 + Quote.Guests * 2;
|
||||
public int LaundryShiftCost => 180 + AssignedCrew(CrewRole.Laundry) * 18;
|
||||
public int StoreCost => 180 + Quote.Guests * 3;
|
||||
public int PumpCost => 410;
|
||||
public int TreatmentCost => 360;
|
||||
public int RepairCost => 780 + Ship.HullIndex * 490;
|
||||
public bool CanOpenStores => !StoresOpened && provisions < Ship.FoodCapacity * .85 && CanSpend(StoreCost);
|
||||
public bool CanExtendLaundry => !LaundryBoost && AssignedCrew(CrewRole.Laundry) > 0 && CanSpend(LaundryShiftCost);
|
||||
|
||||
public int AssignedCrew(CrewRole role) => CrewMarket.IsRole(role) ? crewComplement[(int)role] : 0;
|
||||
|
||||
public bool CanSpend(int cost) => tick < ticks && Expenses + cost <= Quote.TicketSales / 4;
|
||||
|
||||
public bool CanSetEngineMode(int mode) =>
|
||||
mode >= 0 && mode < FuelRates.Length && (mode < 2 || FuelForMode(mode) + Quote.Reserve <= Ship.Fuel);
|
||||
mode >= 0 && mode < FuelRates.Length
|
||||
&& (mode < 2 || (Coverage(CrewRole.Engineering) >= .85 && FuelForMode(mode) + Quote.Reserve <= Ship.Fuel));
|
||||
|
||||
public void SetEngineMode(int mode)
|
||||
{
|
||||
@@ -52,13 +67,21 @@ namespace Soundings
|
||||
|
||||
public void ExtendGalley()
|
||||
{
|
||||
if (GalleyBoost || !CanSpend(GalleyCost))
|
||||
if (GalleyBoost || AssignedCrew(CrewRole.Galley) == 0 || !CanSpend(GalleyCost))
|
||||
return;
|
||||
Expenses += GalleyCost;
|
||||
galleyUntil = tick + 7;
|
||||
Measure(false);
|
||||
}
|
||||
|
||||
public void ExtendLaundry()
|
||||
{
|
||||
if (!CanExtendLaundry)
|
||||
return;
|
||||
Expenses += LaundryShiftCost;
|
||||
laundryUntil = tick + 7;
|
||||
}
|
||||
|
||||
public void RunBoostPumps()
|
||||
{
|
||||
if (PumpsBoost || !CanSpend(PumpCost))
|
||||
@@ -85,10 +108,24 @@ namespace Soundings
|
||||
|
||||
private void InitializeSystems()
|
||||
{
|
||||
crewComplement = Quote.CrewAssigned is { Length: > 0 } ? (int[])Quote.CrewAssigned.Clone() : Ship.CaptureCrew();
|
||||
int totalCrew = 0;
|
||||
foreach (CrewRoleSpec department in CrewMarket.Roles)
|
||||
{
|
||||
CrewRole role = department.Role;
|
||||
int assigned = AssignedCrew(role);
|
||||
totalCrew += assigned;
|
||||
crewCoverage[(int)role] = Math.Min(1.35, (double)assigned / CrewMarket.Recommended(Ship, role));
|
||||
}
|
||||
LaundryDemand = (Quote.Guests + 2) / 3 + (totalCrew + 13) / 14;
|
||||
provisions = Math.Min(Ship.FoodCapacity, Quote.Plan == null ? Quote.Guests * Quote.Days * 2.53 : Quote.Plan.FoodUnits);
|
||||
water = Ship.WaterCapacity;
|
||||
}
|
||||
|
||||
private double Coverage(CrewRole role) => crewCoverage[(int)role];
|
||||
|
||||
private double LaundryServiceLoss => Math.Min(1, laundryBacklog / Math.Max(1, LaundryDemand * .80));
|
||||
|
||||
private int FuelForMode(int mode)
|
||||
{
|
||||
double expected = Quote.FuelBurn * (fuelIntegrated + (ticks - tick) * FuelRates[mode]) / ticks;
|
||||
@@ -109,34 +146,45 @@ namespace Soundings
|
||||
|
||||
fuelIntegrated += FuelRates[EngineMode];
|
||||
double portionOfDay = (double)Quote.Days / ticks;
|
||||
water = Math.Min(Ship.WaterCapacity, water + Ship.WaterProduction * (PumpsBoost ? 1.9 : 1) * portionOfDay);
|
||||
double engineering = .35 + .65 * Coverage(CrewRole.Engineering);
|
||||
water = Math.Min(Ship.WaterCapacity, water + Ship.WaterProduction * engineering * (PumpsBoost ? 1.9 : 1) * portionOfDay);
|
||||
double requested = (Quote.Guests * 54 + Get(OnboardService.Amenities).Served * 28) * portionOfDay;
|
||||
double delivered = Math.Min(water, requested);
|
||||
water -= delivered;
|
||||
hydration = requested <= 0 ? 1 : delivered / requested;
|
||||
laundryBacklog += LaundryDemand * portionOfDay;
|
||||
double cleaned = Math.Min(laundryBacklog, Math.Min(LaundryCapacity * portionOfDay, water / WaterPerLaundryLoad));
|
||||
double washingWater = cleaned * WaterPerLaundryLoad;
|
||||
laundryBacklog = Math.Max(0, laundryBacklog - cleaned);
|
||||
laundryCleaned += cleaned;
|
||||
water = Math.Max(0, water - washingWater);
|
||||
waste = Math.Min(Ship.WasteCapacity * 1.3, Math.Max(0,
|
||||
waste + delivered * .74 - Ship.WasteTreatment * (TreatmentBoost ? 2.3 : 1) * portionOfDay));
|
||||
waste + delivered * .74 + washingWater * .76
|
||||
- Ship.WasteTreatment * engineering * (TreatmentBoost ? 2.3 : 1) * portionOfDay));
|
||||
}
|
||||
|
||||
private double QuotaPerService() => Math.Min(Ship.GalleyCapacity, Quote.Guests) * PortionPerMeal;
|
||||
private int StaffedGalleyCapacity => (int)Math.Round(Ship.GalleyCapacity * Coverage(CrewRole.Galley));
|
||||
|
||||
private double QuotaPerService() => Math.Min(StaffedGalleyCapacity, Quote.Guests) * PortionPerMeal;
|
||||
|
||||
private int ServiceCapacity(int service, int venueCapacity)
|
||||
{
|
||||
if (service == (int)OnboardService.Meals)
|
||||
{
|
||||
int galley = Ship.GalleyCapacity + (GalleyBoost ? 85 : 0);
|
||||
int galley = StaffedGalleyCapacity + (GalleyBoost ? 85 : 0);
|
||||
int portions = (int)Math.Floor(provisions / PortionPerMeal);
|
||||
return Math.Min(venueCapacity, Math.Min(galley, portions));
|
||||
}
|
||||
if (service == (int)OnboardService.Amenities && WaterPercent < 22)
|
||||
return venueCapacity / 3;
|
||||
return venueCapacity;
|
||||
if (service == (int)OnboardService.Shows)
|
||||
return (int)Math.Round(venueCapacity * Math.Min(1, Coverage(CrewRole.Entertainment)));
|
||||
int staffed = (int)Math.Round(venueCapacity * Math.Min(1, Coverage(CrewRole.Housekeeping)));
|
||||
return service == (int)OnboardService.Amenities && WaterPercent < 22 ? staffed / 3 : staffed;
|
||||
}
|
||||
|
||||
private void UpdateHealth(double mealFulfillment)
|
||||
{
|
||||
double sanitation = 1 - Math.Min(.67, Math.Max(0, waste / Ship.WasteCapacity - .68));
|
||||
double target = 53 + mealFulfillment * 32 + hydration * 9 + sanitation * 6;
|
||||
double target = 53 + mealFulfillment * 32 + hydration * 9 + sanitation * 6 - LaundryServiceLoss * 3;
|
||||
health = health * .80 + target * .20;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user