Enable placeable sun deck attractions and finish project rebrand
This commit is contained in:
105
Assets/BigShipTycoon/Runtime/PortPlanning.cs
Normal file
105
Assets/BigShipTycoon/Runtime/PortPlanning.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
using System;
|
||||
|
||||
namespace BigShipTycoon
|
||||
{
|
||||
public enum EntertainmentProgram { Shipboard, LiveMusic, Headline }
|
||||
|
||||
[Serializable]
|
||||
public sealed class DeparturePlan
|
||||
{
|
||||
public int FoodUnits, FoodCost, ProgramCost;
|
||||
public EntertainmentProgram Program;
|
||||
}
|
||||
|
||||
public static class PortPlanning
|
||||
{
|
||||
private static readonly int[] FoodMarket =
|
||||
{
|
||||
462, 590, 477, 338, 423, 635, 514, 397, 452, 302, 350, 311, 475, 326, 539, 535, 658, 610, 496, 318, 372, 332
|
||||
};
|
||||
|
||||
public static int FoodPriceCents(int port, int day)
|
||||
{
|
||||
int market = port < FoodMarket.Length ? FoodMarket[port] : 460;
|
||||
return market + ((day / 7 * 17 + port * 23) % 37) - 18;
|
||||
}
|
||||
|
||||
public static int RecommendedFood(Ship ship, Voyage quote) =>
|
||||
Math.Min(ship.FoodCapacity, (int)Math.Ceiling(quote.Guests * quote.Days * 2.53));
|
||||
|
||||
public static int EstimatedFoodUse(Ship ship, Voyage quote) =>
|
||||
(int)Math.Ceiling(Math.Min(Math.Min(ship.Meals, ship.GalleyCapacity), quote.Guests * .71) * Math.Max(24, quote.Days * 8) * .26);
|
||||
|
||||
public static string ProgramLabel(EntertainmentProgram program) => program switch
|
||||
{
|
||||
EntertainmentProgram.LiveMusic => "Local musicians",
|
||||
EntertainmentProgram.Headline => "Headline revue",
|
||||
_ => "Shipboard sets"
|
||||
};
|
||||
|
||||
public static bool CanBook(Ship ship, EntertainmentProgram program) => program switch
|
||||
{
|
||||
EntertainmentProgram.Shipboard => true,
|
||||
EntertainmentProgram.LiveMusic => ship.Meals > 0 || ship.Entertainment > 0,
|
||||
EntertainmentProgram.Headline => ship.Entertainment > 0,
|
||||
_ => false
|
||||
};
|
||||
|
||||
public static int ProgramPrice(EntertainmentProgram program, Voyage quote, int day)
|
||||
{
|
||||
int market = FoodPriceCents(quote.Origin, day);
|
||||
return program switch
|
||||
{
|
||||
EntertainmentProgram.LiveMusic => 800 + market + 120 * quote.Days,
|
||||
EntertainmentProgram.Headline => 2000 + market * 2 + 250 * quote.Days,
|
||||
_ => 0
|
||||
};
|
||||
}
|
||||
|
||||
internal static int ShowSeats(EntertainmentProgram program) => program switch
|
||||
{
|
||||
EntertainmentProgram.LiveMusic => 48,
|
||||
EntertainmentProgram.Headline => 86,
|
||||
_ => 0
|
||||
};
|
||||
|
||||
internal static int ShowDemand(EntertainmentProgram program) => program switch
|
||||
{
|
||||
EntertainmentProgram.LiveMusic => 29,
|
||||
EntertainmentProgram.Headline => 57,
|
||||
_ => 0
|
||||
};
|
||||
|
||||
internal static int ShowRounds(EntertainmentProgram program) => program switch
|
||||
{
|
||||
EntertainmentProgram.LiveMusic => 7,
|
||||
EntertainmentProgram.Headline => 10,
|
||||
_ => 0
|
||||
};
|
||||
|
||||
internal static double ShowTime(EntertainmentProgram program) => program == EntertainmentProgram.LiveMusic ? .42 : .63;
|
||||
|
||||
public static void Apply(Ship ship, Voyage quote, int day, int? foodUnits, EntertainmentProgram program)
|
||||
{
|
||||
int ordered = Market.Clamp(foodUnits ?? RecommendedFood(ship, quote), 0, ship.FoodCapacity);
|
||||
if (!CanBook(ship, program))
|
||||
program = EntertainmentProgram.Shipboard;
|
||||
|
||||
quote.Plan = new DeparturePlan
|
||||
{
|
||||
FoodUnits = ordered,
|
||||
FoodCost = (ordered * FoodPriceCents(quote.Origin, day) + 50) / 100,
|
||||
Program = program,
|
||||
ProgramCost = ProgramPrice(program, quote, day)
|
||||
};
|
||||
|
||||
// The port invoice replaces the food share of baseline catering. Labor and other supplies still matter.
|
||||
quote.Catering = quote.Guests * quote.Days * 15;
|
||||
double shows = Math.Min(1, (double)ship.Entertainment / Math.Max(1, ship.Capacity));
|
||||
double provisionCoverage = Math.Min(1, (double)ordered / Math.Max(1, EstimatedFoodUse(ship, quote)));
|
||||
double baselineSales = quote.Guests * quote.Days * (6 + 7 * provisionCoverage + shows * 18);
|
||||
double bookedSales = Math.Min(quote.Guests, ShowSeats(program)) * ShowRounds(program) * 1.4;
|
||||
quote.OnboardSales = (int)Math.Round(baselineSales + bookedSales);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user