Files
cruiseSimulator/Assets/Soundings/Runtime/Market.cs

188 lines
9.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Collections.Generic;
namespace Soundings
{
public enum WeatherCondition { Calm, Swell, Storm }
public enum Facility { Empty, Cabin, Dining, Entertainment, Tank, Bar, Amenity, Galley, Stores, Water, Waste, Workshop }
public sealed class FacilitySpec
{
public readonly string Name, Mark, Details;
public readonly int Price, Capacity;
public FacilitySpec(string name, string mark, string details, int price, int capacity)
{
Name = name;
Mark = mark;
Details = details;
Price = price;
Capacity = capacity;
}
}
public sealed class HullSpec
{
public readonly string Name, Description;
public readonly int Columns, Rows, StarterDecks, MaxDecks, Price, Voyages, Reputation, Tank, CrewPerDay, HullWearCost;
public readonly float Length, Beam;
public readonly double TonsPerMile;
public HullSpec(string name, string description, int columns, int rows, int starterDecks, int maxDecks, int price,
int voyages, int reputation, int tank, double tonsPerMile, int crewPerDay, int hullWearCost, float length, float beam)
{
Name = name;
Description = description;
Columns = columns;
Rows = rows;
StarterDecks = starterDecks;
MaxDecks = maxDecks;
Price = price;
Voyages = voyages;
Reputation = reputation;
Tank = tank;
TonsPerMile = tonsPerMile;
CrewPerDay = crewPerDay;
HullWearCost = hullWearCost;
Length = length;
Beam = beam;
}
}
public sealed class PortSpec
{
public readonly string Name, Country, Region;
public readonly int FuelPrice, Fee, Permit, Reputation, MinimumHull;
public readonly double Appeal, MarketSize;
public readonly float MapX, MapY, Longitude, Latitude;
public PortSpec(string name, string country, string region, int fuelPrice, int fee, int permit,
int reputation, int minimumHull, double appeal, double marketSize, float mapX, float mapY, float longitude, float latitude)
{
Name = name;
Country = country;
Region = region;
FuelPrice = fuelPrice;
Fee = fee;
Permit = permit;
Reputation = reputation;
MinimumHull = minimumHull;
Appeal = appeal;
MarketSize = marketSize;
MapX = mapX;
MapY = mapY;
Longitude = longitude;
Latitude = latitude;
}
}
public readonly struct Lane
{
public readonly int A, B, Miles;
public Lane(int a, int b, int miles)
{
A = a;
B = b;
Miles = miles;
}
public int Other(int port) => port == A ? B : port == B ? A : -1;
}
public static class Market
{
public const int StarterPortCount = 8;
public static int UsedPrice(int hull) => hull == 0 ? 105000 : 245000;
public const int MaxFleet = 8;
public const int Ocean = 2;
public const int Bermuda = 5;
public const int Lisbon = 7;
public const int MinFare = 150;
public const int MaxFare = 4000;
public static readonly IReadOnlyList<FacilitySpec> Facilities = new[]
{
new FacilitySpec("Clear berth", "–", "Recover 25% of the build cost", 0, 0),
new FacilitySpec("Cabins", "CB", "32 guest berths", 8400, 32),
new FacilitySpec("Dining hall", "DH", "48 seats · 3 services", 11800, 48),
new FacilitySpec("Show lounge", "SL", "80 seats · improves demand", 15400, 80),
new FacilitySpec("Bunker tank", "BT", "+65 t of fuel capacity", 14200, 65),
new FacilitySpec("Bar", "BR", "72 drink orders per service", 14800, 72),
new FacilitySpec("Pool terrace", "PT", "64 amenity admissions per service", 18600, 64),
new FacilitySpec("Galley", "GY", "+96 meals per service window", 22100, 96),
new FacilitySpec("Stores", "ST", "+900 meal portions of storage", 17600, 900),
new FacilitySpec("Water plant", "WP", "+14,000 L storage and +6,000 L/day output", 25400, 14000),
new FacilitySpec("Sewage", "SW", "+10,000 L buffer and +7,000 L/day treatment", 19800, 10000),
new FacilitySpec("Workshop", "WS", "Increases the benefit of onboard servicing", 18700, 2)
};
public static readonly IReadOnlyList<HullSpec> Hulls = new[]
{
new HullSpec("Coastal", "A compact hull for short Caribbean crossings.", 6, 2, 2, 3, 210000, 0, 0, 74, .092, 7200, 1200, 72, 14),
new HullSpec("Regional", "More deck space and range for island chains.", 8, 3, 4, 5, 355000, 3, 24, 185, .121, 12800, 2300, 104, 19),
new HullSpec("Ocean Class", "A transatlantic hull for a world-class flagship.", 10, 3, 6, 8, 690000, 9, 42, 440, .152, 21800, 4700, 142, 25)
};
public static readonly IReadOnlyList<PortSpec> Ports = new[]
{
new PortSpec("Miami", "United States", "Florida", 685, 9200, 0, 0, 0, .94, 1.12, .14f, .63f, -80.2f, 25.8f),
new PortSpec("Nassau", "The Bahamas", "Caribbean", 825, 7600, 0, 0, 0, 1.14, .87, .24f, .67f, -77.4f, 25.1f),
new PortSpec("Key West", "United States", "Florida", 725, 5600, 14500, 15, 0, .91, .77, .11f, .78f, -81.8f, 24.6f),
new PortSpec("Cozumel", "Mexico", "Caribbean", 590, 8700, 21000, 21, 0, 1.10, .90, .06f, .94f, -87, 20.5f),
new PortSpec("San Juan", "Puerto Rico, U.S.", "Caribbean", 650, 10500, 34000, 25, 1, 1.17, 1.00, .39f, .86f, -66.1f, 18.5f),
new PortSpec("Bermuda", "United Kingdom", "North Atlantic", 910, 12100, 48000, 32, 1, 1.22, .83, .46f, .45f, -64.8f, 32.3f),
new PortSpec("Ponta Delgada", "Portugal", "Azores", 625, 9500, 57000, 42, 2, 1.20, .73, .69f, .42f, -25.7f, 37.7f),
new PortSpec("Lisbon", "Portugal", "Europe", 670, 14200, 71000, 45, 2, 1.37, 1.15, .87f, .26f, -9.1f, 38.7f),
new PortSpec("Barcelona", "Spain", "Mediterranean", 688, 16200, 37000, 46, 2, 1.33, 1.18, 0, 0, 2.2f, 41.4f),
new PortSpec("Port Said", "Egypt", "Mediterranean", 604, 19200, 33000, 48, 2, 1.20, .99, 0, 0, 32.3f, 31.3f),
new PortSpec("Salalah", "Oman", "Indian Ocean", 559, 11900, 31000, 48, 2, 1.25, .94, 0, 0, 54.1f, 17.0f),
new PortSpec("Mumbai", "India", "Indian Ocean", 588, 15100, 45000, 50, 2, 1.32, 1.19, 0, 0, 72.8f, 19.1f),
new PortSpec("Singapore", "Singapore", "Southeast Asia", 570, 16800, 52000, 52, 2, 1.37, 1.27, 0, 0, 103.8f, 1.3f),
new PortSpec("Benoa", "Indonesia", "Southeast Asia", 634, 12800, 42000, 52, 2, 1.35, 1.02, 0, 0, 115.2f, -8.7f),
new PortSpec("Sydney", "Australia", "Oceania", 740, 16700, 51000, 55, 2, 1.42, 1.20, 0, 0, 151.2f, -33.9f),
new PortSpec("Auckland", "New Zealand", "Oceania", 721, 13400, 46000, 55, 2, 1.36, 1.11, 0, 0, 174.8f, -36.8f),
new PortSpec("Papeete", "French Polynesia", "South Pacific", 771, 13800, 42000, 55, 2, 1.44, 1.12, 0, 0, -149.6f, -17.5f),
new PortSpec("Honolulu", "United States", "North Pacific", 757, 16200, 52000, 58, 2, 1.41, 1.16, 0, 0, -157.9f, 21.3f),
new PortSpec("San Diego", "United States", "Pacific Coast", 718, 15300, 51000, 58, 2, 1.35, 1.21, 0, 0, -117.2f, 32.7f),
new PortSpec("Puerto Vallarta", "Mexico", "Pacific Coast", 606, 11900, 36000, 58, 2, 1.29, 1.03, 0, 0, -105.2f, 20.7f),
new PortSpec("Balboa", "Panama", "Central America", 635, 22700, 43000, 58, 2, 1.26, 1.07, 0, 0, -79.6f, 8.9f),
new PortSpec("Cartagena", "Colombia", "South America", 599, 14600, 45000, 58, 2, 1.35, 1.12, 0, 0, -75.5f, 10.4f)
};
public static readonly IReadOnlyList<Lane> Lanes = new[]
{
new Lane(0, 1, 185), new Lane(0, 2, 150), new Lane(1, 2, 270), new Lane(2, 3, 455),
new Lane(0, 3, 590), new Lane(0, 4, 985), new Lane(1, 4, 735), new Lane(1, 5, 840),
new Lane(0, 5, 913), new Lane(4, 5, 865), new Lane(5, 6, 1920), new Lane(5, 7, 2790),
new Lane(6, 7, 815), new Lane(7, 8, 605), new Lane(8, 9, 1630), new Lane(9, 10, 1645),
new Lane(10, 11, 1160), new Lane(11, 12, 2510), new Lane(12, 13, 920), new Lane(13, 14, 2540),
new Lane(14, 15, 1165), new Lane(15, 16, 2250), new Lane(16, 17, 2380), new Lane(17, 18, 2270),
new Lane(18, 19, 1110), new Lane(19, 20, 1585), new Lane(20, 21, 265), new Lane(21, 0, 1080)
};
public static int FuelPrice(int port, int day)
{
int weeklyMove = ((day / 7 * 13 + port * 9) % 31) - 15;
return Ports[port].FuelPrice + weeklyMove;
}
public static bool TryDistance(int origin, int destination, out int miles)
{
foreach (Lane lane in Lanes)
{
if (lane.Other(origin) == destination && destination >= 0)
{
miles = lane.Miles;
return true;
}
}
miles = 0;
return false;
}
public static int Clamp(int value, int min, int max) => Math.Max(min, Math.Min(max, value));
}
}