Make Soundings voyages playable with ship operations and guided tips
This commit is contained in:
@@ -15,6 +15,7 @@ namespace Soundings
|
||||
{
|
||||
public string Name;
|
||||
public int HullIndex, Port, Condition, Fare, Fuel;
|
||||
public int[] ServicePrices;
|
||||
public double FuelValue;
|
||||
public List<Deck> Decks = new List<Deck>();
|
||||
|
||||
@@ -23,6 +24,12 @@ namespace Soundings
|
||||
public int Meals => Count(Facility.Dining) * Market.Facilities[(int)Facility.Dining].Capacity * 3;
|
||||
public int Entertainment => Count(Facility.Entertainment) * Market.Facilities[(int)Facility.Entertainment].Capacity;
|
||||
public int Capacity => Math.Min(Beds, Meals);
|
||||
public int GalleyCapacity => 168 + HullIndex * 72 + Count(Facility.Galley) * Market.Facilities[(int)Facility.Galley].Capacity;
|
||||
public int FoodCapacity => 1500 + HullIndex * 640 + Count(Facility.Stores) * Market.Facilities[(int)Facility.Stores].Capacity;
|
||||
public int WaterCapacity => 16000 + HullIndex * 7600 + Count(Facility.Water) * Market.Facilities[(int)Facility.Water].Capacity;
|
||||
public int WaterProduction => 9000 + HullIndex * 3900 + Count(Facility.Water) * 6000;
|
||||
public int WasteCapacity => 12000 + HullIndex * 6800 + Count(Facility.Waste) * Market.Facilities[(int)Facility.Waste].Capacity;
|
||||
public int WasteTreatment => 5500 + HullIndex * 3400 + Count(Facility.Waste) * 7000;
|
||||
public int Tank => Hull.Tank + Count(Facility.Tank) * Market.Facilities[(int)Facility.Tank].Capacity;
|
||||
public double BurnPerMile => Hull.TonsPerMile * (1 + (100 - Condition) * .003);
|
||||
public int SafeRange => Math.Max(0, (int)Math.Floor(Math.Min(Fuel - 6, Fuel * 100 / 112) / BurnPerMile));
|
||||
@@ -41,10 +48,12 @@ namespace Soundings
|
||||
[Serializable]
|
||||
public sealed class Voyage
|
||||
{
|
||||
public int Origin, Destination, Miles, Days, Day, Fare, Guests, Capacity, FuelBurn, Reserve,
|
||||
public int Origin, Destination, Miles, Days, Day, Fare, Guests, RoomDemand, Capacity, FuelBurn, Reserve,
|
||||
TicketSales, OnboardSales, Crew, Catering, PortFees, FuelExpense, LoanInterest, Principal, ReputationChange;
|
||||
public string ShipName;
|
||||
public int OperatingCash => Crew + Catering + PortFees;
|
||||
public OnboardReport Onboard;
|
||||
public WeatherCondition Weather;
|
||||
public int OperatingCash => Crew + Catering + PortFees + (Onboard?.Expenses ?? 0);
|
||||
public int NetIncome => TicketSales + OnboardSales - OperatingCash - FuelExpense - LoanInterest;
|
||||
public int CashChange => TicketSales + OnboardSales - OperatingCash - LoanInterest - Principal;
|
||||
public int RequiredFuel => FuelBurn + Reserve;
|
||||
@@ -179,6 +188,8 @@ namespace Soundings
|
||||
ship.Decks[1].Cells[1] = Facility.Dining;
|
||||
ship.Decks[1].Cells[2] = Facility.Entertainment;
|
||||
ship.Decks[1].Cells[4] = Facility.Dining;
|
||||
ship.Decks[1].Cells[5] = Facility.Bar;
|
||||
ship.Decks[1].Cells[8] = Facility.Amenity;
|
||||
}
|
||||
return ship;
|
||||
}
|
||||
@@ -314,7 +325,8 @@ namespace Soundings
|
||||
double entertainment = Math.Min(1, (double)ship.Entertainment / Math.Max(1, ship.Capacity));
|
||||
double marketDemand = (150 + ship.Capacity * .50) * from.MarketSize * to.Appeal * season * saturation;
|
||||
double product = (.66 + Reputation * .006 + entertainment * .20) * (.8 + ship.Condition * .002);
|
||||
int guests = Market.Clamp((int)Math.Round(marketDemand * fareFactor * product), 0, ship.Capacity);
|
||||
int roomDemand = Math.Max(0, (int)Math.Round(marketDemand * fareFactor * product));
|
||||
int guests = Math.Min(roomDemand, ship.Capacity);
|
||||
double unitCost = ship.Fuel > 0 ? ship.FuelValue / ship.Fuel : Market.FuelPrice(ship.Port, Day);
|
||||
|
||||
return new Voyage
|
||||
@@ -327,6 +339,7 @@ namespace Soundings
|
||||
Miles = miles,
|
||||
Fare = ship.Fare,
|
||||
Guests = guests,
|
||||
RoomDemand = roomDemand,
|
||||
Capacity = ship.Capacity,
|
||||
FuelBurn = fuel,
|
||||
Reserve = reserve,
|
||||
@@ -366,16 +379,29 @@ namespace Soundings
|
||||
return null;
|
||||
}
|
||||
|
||||
public string Sail(Ship ship, int destination)
|
||||
public string Sail(Ship ship, int destination, OnboardSession live = null)
|
||||
{
|
||||
Voyage quote = Forecast(ship, destination);
|
||||
Voyage quote = live?.Quote ?? Forecast(ship, destination);
|
||||
if (live != null && (live.Ship != ship || quote.Origin != ship.Port || quote.Destination != destination))
|
||||
return "This sailing has already been settled or belongs to another ship.";
|
||||
string block = DepartureBlock(ship, quote);
|
||||
if (block != null)
|
||||
return block;
|
||||
|
||||
if (live != null)
|
||||
{
|
||||
live.AdvanceTo(1);
|
||||
quote.Onboard = live.Report();
|
||||
quote.OnboardSales = quote.Onboard.Revenue;
|
||||
quote.FuelBurn = quote.Onboard.FuelBurn;
|
||||
quote.FuelExpense = (int)Math.Round(quote.FuelBurn * ship.FuelValue / ship.Fuel);
|
||||
quote.ReputationChange += (int)Math.Round((quote.Onboard.Happiness - 74) / 10.0);
|
||||
live.SavePrices();
|
||||
}
|
||||
|
||||
ship.FuelValue *= (double)(ship.Fuel - quote.FuelBurn) / ship.Fuel;
|
||||
ship.Fuel -= quote.FuelBurn;
|
||||
ship.Condition = Math.Max(24, ship.Condition - Math.Max(1, quote.Days / 2));
|
||||
ship.Condition = Market.Clamp(ship.Condition - Math.Max(1, quote.Days / 2) + (quote.Onboard?.Repair ?? 0), 24, 100);
|
||||
ship.Port = quote.Destination;
|
||||
Day = quote.Day;
|
||||
Cash += quote.CashChange;
|
||||
|
||||
Reference in New Issue
Block a user