Unlock expanded venues and manage concurrent fleet voyages
This commit is contained in:
@@ -8,7 +8,8 @@ namespace Soundings
|
||||
private static readonly (int HullIndex, bool Used)[] Offers =
|
||||
{ (0, true), (0, false), (1, true), (1, false), (2, false) };
|
||||
|
||||
private bool systemTools;
|
||||
private enum DeckTools { GuestFacilities, LargerVenues, ShipSystems }
|
||||
private DeckTools deckTools;
|
||||
|
||||
private static readonly Color DraftGrid = new Color(.37f, .62f, .65f, .19f);
|
||||
private static readonly Color DraftFine = new Color(.47f, .75f, .74f, .42f);
|
||||
@@ -58,7 +59,7 @@ namespace Soundings
|
||||
deckIndex = ship.Decks.Count - 1;
|
||||
Apply(failure, "New deck ready to fit out.");
|
||||
}, "work-deck-add", "add-deck");
|
||||
add.SetEnabled(ship.Decks.Count < ship.Hull.MaxDecks && company.Cash >= deckPrice);
|
||||
add.SetEnabled(ship.Decks.Count < ship.Hull.MaxDecks && company.AvailableCash >= deckPrice);
|
||||
deckControls.Add(add);
|
||||
|
||||
var board = Add(work, "work-draft");
|
||||
@@ -71,50 +72,13 @@ namespace Soundings
|
||||
|
||||
var layout = Add(board, "work-berth-grid");
|
||||
var placement = Add(board, "work-placement");
|
||||
var placementLabel = AddText(placement, PlacementInstruction(tool), "work-placement-text");
|
||||
for (int row = 0; row < ship.Hull.Rows; row++)
|
||||
{
|
||||
var strip = Add(layout, "work-berth-row");
|
||||
for (int column = 0; column < ship.Hull.Columns; column++)
|
||||
{
|
||||
int cell = row * ship.Hull.Columns + column;
|
||||
string berthName = $"{(char)('A' + row)}{column + 1}";
|
||||
Facility existing = ship.Decks[deckIndex].Cells[cell];
|
||||
FacilitySpec room = Market.Facilities[(int)existing];
|
||||
Button berth = Action("", () =>
|
||||
{
|
||||
Facility previous = ship.Decks[deckIndex].Cells[cell];
|
||||
string failure = company.Build(ship, deckIndex, cell, tool);
|
||||
if (failure == null && previous != tool)
|
||||
SetRecommendedFuel();
|
||||
string confirmation = tool == Facility.Empty
|
||||
? $"Cleared berth {berthName}."
|
||||
: $"Built {Market.Facilities[(int)tool].Name.ToLowerInvariant()} at {berthName}.";
|
||||
Apply(failure, previous == tool ? null : confirmation);
|
||||
}, "work-berth work-room-" + (int)existing, "berth-" + cell);
|
||||
string description = BerthDescription(berthName, existing, tool);
|
||||
berth.tooltip = description;
|
||||
berth.RegisterCallback<PointerEnterEvent>(_ => placementLabel.text = description);
|
||||
berth.RegisterCallback<PointerLeaveEvent>(_ => placementLabel.text = PlacementInstruction(tool));
|
||||
berth.RegisterCallback<FocusInEvent>(_ => placementLabel.text = description);
|
||||
berth.RegisterCallback<FocusOutEvent>(_ => placementLabel.text = PlacementInstruction(tool));
|
||||
AddText(berth, berthName, "work-berth-index");
|
||||
if (existing == Facility.Empty)
|
||||
AddText(berth, "+", "work-berth-open");
|
||||
else
|
||||
{
|
||||
var center = Add(berth, "work-berth-center");
|
||||
center.pickingMode = PickingMode.Ignore;
|
||||
AddFacilityMark(center, existing);
|
||||
AddText(center, room.Name, "work-berth-name");
|
||||
}
|
||||
strip.Add(berth);
|
||||
}
|
||||
}
|
||||
var placementLabel = AddText(placement, PlacementInstruction(ship, tool), "work-placement-text");
|
||||
placementLabel.name = "berth-placement";
|
||||
DrawBerthGrid(layout, placementLabel, ship);
|
||||
|
||||
var fittings = Add(work, "work-fittings");
|
||||
var gauges = Add(fittings, "work-capacity-strip");
|
||||
if (systemTools)
|
||||
if (deckTools == DeckTools.ShipSystems)
|
||||
{
|
||||
AddText(gauges, $"{ship.GalleyCapacity:N0} galley covers", "work-capacity");
|
||||
AddText(gauges, $"{ship.FoodCapacity:N0} stored portions", "work-capacity");
|
||||
@@ -123,23 +87,36 @@ namespace Soundings
|
||||
}
|
||||
else
|
||||
{
|
||||
AddText(gauges, $"{ship.Beds:N0} berths", "work-capacity");
|
||||
string rooms = ship.SuiteBerths == 0 ? $"{ship.Beds:N0} berths" : $"{ship.Beds:N0} berths · {ship.SuiteBerths:N0} in suites";
|
||||
AddText(gauges, rooms, "work-capacity");
|
||||
AddText(gauges, $"{ship.Meals:N0} meal covers", "work-capacity");
|
||||
AddText(gauges, $"{ship.Entertainment:N0} show seats", "work-capacity");
|
||||
AddText(gauges, $"{ship.Tank:N0} t bunker capacity", "work-capacity");
|
||||
if (deckTools == DeckTools.LargerVenues)
|
||||
{
|
||||
AddText(gauges, $"{ship.PoolCapacity:N0} pool admissions", "work-capacity");
|
||||
AddText(gauges, $"{ship.BarCapacity:N0} drink orders", "work-capacity");
|
||||
}
|
||||
else
|
||||
AddText(gauges, $"{ship.Tank:N0} t bunker capacity", "work-capacity");
|
||||
AddText(gauges, $"{ship.Capacity:N0} guests per sailing", "work-capacity work-capacity-emphasis");
|
||||
}
|
||||
|
||||
var toolMode = Add(fittings, "work-fit-modes");
|
||||
toolMode.Add(Action("Guest facilities", () => ChangeBuildTools(false), systemTools ? "" : "work-selected", "facility-guests"));
|
||||
toolMode.Add(Action("Ship systems", () => ChangeBuildTools(true), systemTools ? "work-selected" : "", "facility-systems"));
|
||||
AddBuildToolTab(toolMode, "Guest facilities", "facility-guests", DeckTools.GuestFacilities, Facility.Cabin);
|
||||
AddBuildToolTab(toolMode, "Larger venues", "facility-larger", DeckTools.LargerVenues, Facility.Suite);
|
||||
AddBuildToolTab(toolMode, "Ship systems", "facility-systems", DeckTools.ShipSystems, Facility.Galley);
|
||||
var tools = Add(fittings, "work-tool-tray");
|
||||
int start = systemTools ? (int)Facility.Galley : 1;
|
||||
int end = systemTools ? Market.Facilities.Count : (int)Facility.Galley;
|
||||
for (int i = start; i <= end; i++)
|
||||
var (start, end) = deckTools switch
|
||||
{
|
||||
Facility option = i == end ? Facility.Empty : (Facility)i;
|
||||
DeckTools.LargerVenues => (Facility.Suite, Facility.Extension),
|
||||
DeckTools.ShipSystems => (Facility.Galley, Facility.Suite),
|
||||
_ => (Facility.Cabin, Facility.Galley)
|
||||
};
|
||||
for (int i = (int)start; i <= (int)end; i++)
|
||||
{
|
||||
Facility option = i == (int)end ? Facility.Empty : (Facility)i;
|
||||
FacilitySpec spec = Market.Facilities[(int)option];
|
||||
bool locked = ship.HullIndex < spec.MinimumHull;
|
||||
Button button = Action("", () =>
|
||||
{
|
||||
tool = option;
|
||||
@@ -147,44 +124,191 @@ namespace Soundings
|
||||
Render();
|
||||
}, "work-tool work-tool-" + (int)option, "facility-" + (int)option);
|
||||
button.EnableInClassList("work-selected", option == tool);
|
||||
button.tooltip = spec.Details;
|
||||
button.EnableInClassList("work-tool-locked", locked);
|
||||
button.tooltip = locked ? VenueRequirement(spec) : spec.Details;
|
||||
AddFacilityMark(button, option);
|
||||
var copy = Add(button, "work-tool-copy");
|
||||
copy.pickingMode = PickingMode.Ignore;
|
||||
AddText(copy, spec.Name, "work-tool-name");
|
||||
AddText(copy, option == Facility.Empty ? "25% refund" : Money(spec.Price), "work-tool-cost");
|
||||
string price = option == Facility.Empty ? "25% refund" : Money(spec.Price);
|
||||
if (spec.Length > 1)
|
||||
{
|
||||
price = $"{spec.Length} bays · {price}";
|
||||
button.AddToClassList("work-tool-larger");
|
||||
}
|
||||
AddText(copy, price, "work-tool-cost");
|
||||
if (locked)
|
||||
AddText(copy, $"{Market.Hulls[spec.MinimumHull].Name} hull required", "work-tool-lock");
|
||||
tools.Add(button);
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeBuildTools(bool systems)
|
||||
private void DrawBerthGrid(VisualElement layout, Label instruction, Ship ship)
|
||||
{
|
||||
if (systemTools == systems)
|
||||
return;
|
||||
systemTools = systems;
|
||||
tool = systems ? Facility.Galley : Facility.Cabin;
|
||||
Notify(null);
|
||||
Render();
|
||||
Deck deck = ship.Decks[deckIndex];
|
||||
int columns = ship.Hull.Columns;
|
||||
var berths = new Button[deck.Cells.Length];
|
||||
int hovered = -1, focused = -1;
|
||||
|
||||
void UpdatePreview()
|
||||
{
|
||||
int selected = hovered >= 0 ? hovered : focused;
|
||||
for (int i = 0; i < berths.Length; i++)
|
||||
{
|
||||
berths[i].RemoveFromClassList("work-berth-preview");
|
||||
berths[i].RemoveFromClassList("work-berth-blocked");
|
||||
}
|
||||
if (selected < 0)
|
||||
{
|
||||
instruction.text = PlacementInstruction(ship, tool);
|
||||
return;
|
||||
}
|
||||
|
||||
Facility room = deck.FacilityAt(selected, columns);
|
||||
int anchor = room == Facility.Empty ? selected : deck.AnchorAt(selected, columns);
|
||||
Facility sizeOf = room == Facility.Empty ? tool : room;
|
||||
int span = Market.Facilities[(int)sizeOf].Length;
|
||||
string blocked = PlacementBlock(ship, selected, room);
|
||||
instruction.text = BerthDescription(deck, columns, selected, room, tool, blocked);
|
||||
int rowEnd = (anchor / columns + 1) * columns;
|
||||
for (int i = anchor; i < Mathf.Min(rowEnd, anchor + span); i++)
|
||||
berths[i].AddToClassList(blocked == null ? "work-berth-preview" : "work-berth-blocked");
|
||||
}
|
||||
|
||||
for (int row = 0; row < ship.Hull.Rows; row++)
|
||||
{
|
||||
var strip = Add(layout, "work-berth-row");
|
||||
for (int column = 0; column < columns; column++)
|
||||
{
|
||||
int cell = row * columns + column;
|
||||
int anchor = deck.AnchorAt(cell, columns);
|
||||
Facility existing = deck.FacilityAt(cell, columns);
|
||||
FacilitySpec room = Market.Facilities[(int)existing];
|
||||
var slot = Add(strip, "work-berth-slot");
|
||||
Button berth = Action("", () => BuildAtBerth(ship, deck, cell), "work-berth work-room-" + (int)existing, "berth-" + cell);
|
||||
berths[cell] = berth;
|
||||
slot.Add(berth);
|
||||
string blocked = PlacementBlock(ship, cell, existing);
|
||||
berth.tooltip = BerthDescription(deck, columns, cell, existing, tool, blocked);
|
||||
berth.RegisterCallback<PointerEnterEvent>(_ => { hovered = cell; UpdatePreview(); });
|
||||
berth.RegisterCallback<PointerLeaveEvent>(_ => { hovered = -1; UpdatePreview(); });
|
||||
berth.RegisterCallback<FocusInEvent>(_ => { focused = cell; UpdatePreview(); });
|
||||
berth.RegisterCallback<FocusOutEvent>(_ => { focused = -1; UpdatePreview(); });
|
||||
AddText(berth, BerthName(cell, columns), "work-berth-index");
|
||||
if (existing == Facility.Empty)
|
||||
AddText(berth, "+", "work-berth-open");
|
||||
else if (room.Length == 1)
|
||||
AddVenueLabel(berth, existing);
|
||||
else
|
||||
{
|
||||
berth.EnableInClassList("work-berth-join-left", anchor < cell);
|
||||
berth.EnableInClassList("work-berth-join-right", anchor + room.Length - 1 > cell);
|
||||
}
|
||||
}
|
||||
|
||||
for (int column = 0; column < columns; column++)
|
||||
{
|
||||
Facility room = deck.Cells[row * columns + column];
|
||||
int span = Market.Facilities[(int)room].Length;
|
||||
if (span <= 1)
|
||||
continue;
|
||||
var label = Add(strip, "work-span-caption");
|
||||
label.pickingMode = PickingMode.Ignore;
|
||||
label.style.left = Length.Percent(100f * column / columns);
|
||||
label.style.width = Length.Percent(100f * span / columns);
|
||||
AddVenueLabel(label, room);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string PlacementInstruction(Facility selected)
|
||||
private string PlacementBlock(Ship ship, int cell, Facility existing)
|
||||
{
|
||||
if (existing != Facility.Empty && tool != Facility.Empty)
|
||||
return null;
|
||||
FacilitySpec spec = Market.Facilities[(int)tool];
|
||||
return ship.HullIndex < spec.MinimumHull ? VenueRequirement(spec) : company.BuildBlock(ship, deckIndex, cell, tool);
|
||||
}
|
||||
|
||||
private void BuildAtBerth(Ship ship, Deck deck, int cell)
|
||||
{
|
||||
int columns = ship.Hull.Columns;
|
||||
int anchor = deck.AnchorAt(cell, columns);
|
||||
Facility previous = deck.FacilityAt(cell, columns);
|
||||
string failure = company.Build(ship, deckIndex, cell, tool);
|
||||
if (failure == null && previous != tool)
|
||||
SetRecommendedFuel();
|
||||
FacilitySpec room = Market.Facilities[(int)(tool == Facility.Empty ? previous : tool)];
|
||||
string area = BerthRange(tool == Facility.Empty ? anchor : cell, room.Length, columns);
|
||||
string confirmation = tool == Facility.Empty
|
||||
? $"Removed {room.Name.ToLowerInvariant()} from {area}."
|
||||
: $"Built {room.Name.ToLowerInvariant()} at {area}.";
|
||||
Apply(failure, previous == tool ? null : confirmation);
|
||||
}
|
||||
|
||||
private void AddBuildToolTab(VisualElement parent, string label, string id, DeckTools group, Facility initial)
|
||||
{
|
||||
Button tab = Action(label, () =>
|
||||
{
|
||||
if (deckTools == group)
|
||||
return;
|
||||
deckTools = group;
|
||||
tool = initial;
|
||||
Notify(null);
|
||||
Render();
|
||||
}, deckTools == group ? "work-selected" : "", id);
|
||||
parent.Add(tab);
|
||||
}
|
||||
|
||||
private static void AddVenueLabel(VisualElement parent, Facility facility)
|
||||
{
|
||||
var center = Add(parent, "work-berth-center");
|
||||
center.pickingMode = PickingMode.Ignore;
|
||||
AddFacilityMark(center, facility);
|
||||
AddText(center, Market.Facilities[(int)facility].Name, "work-berth-name").pickingMode = PickingMode.Ignore;
|
||||
}
|
||||
|
||||
private static string VenueRequirement(FacilitySpec spec)
|
||||
{
|
||||
HullSpec hull = Market.Hulls[spec.MinimumHull];
|
||||
return $"Requires a {hull.Name} hull. Unlock the hull with {hull.Voyages} completed voyages and {hull.Reputation} reputation.";
|
||||
}
|
||||
|
||||
private static string PlacementInstruction(Ship ship, Facility selected)
|
||||
{
|
||||
FacilitySpec spec = Market.Facilities[(int)selected];
|
||||
return selected == Facility.Empty
|
||||
? "Select a fitted berth to remove its facility and recover 25%."
|
||||
: $"Select an open berth to build {spec.Name.ToLowerInvariant()}. {spec.Details} · {Money(spec.Price)}";
|
||||
if (selected == Facility.Empty)
|
||||
return "Select any bay in a fitted room to remove it and recover 25%.";
|
||||
if (ship.HullIndex < spec.MinimumHull)
|
||||
return VenueRequirement(spec);
|
||||
string plan = spec.Length == 1 ? "Select an open bay" : $"Select the sternmost of {spec.Length} open bays in a row";
|
||||
return $"{plan} to build {spec.Name.ToLowerInvariant()}. {spec.Details} · {Money(spec.Price)}";
|
||||
}
|
||||
|
||||
private static string BerthDescription(string berth, Facility room, Facility selected)
|
||||
private static string BerthName(int cell, int columns) => $"{(char)('A' + cell / columns)}{cell % columns + 1}";
|
||||
|
||||
private static string BerthRange(int start, int span, int columns)
|
||||
{
|
||||
int end = Mathf.Min(start + span - 1, (start / columns + 1) * columns - 1);
|
||||
return end == start ? BerthName(start, columns) : $"{BerthName(start, columns)}–{BerthName(end, columns)}";
|
||||
}
|
||||
|
||||
private static string BerthDescription(Deck deck, int columns, int cell, Facility room, Facility selected, string blocked)
|
||||
{
|
||||
if (blocked != null)
|
||||
return $"{BerthName(cell, columns)} · {blocked}";
|
||||
FacilitySpec existing = Market.Facilities[(int)room];
|
||||
if (room == Facility.Empty)
|
||||
{
|
||||
FacilitySpec fitting = Market.Facilities[(int)selected];
|
||||
string location = BerthRange(cell, fitting.Length, columns);
|
||||
return selected == Facility.Empty
|
||||
? $"{berth} is already clear."
|
||||
: $"{berth} · Place {Market.Facilities[(int)selected].Name.ToLowerInvariant()}";
|
||||
? $"{location} is already clear."
|
||||
: $"{location} · {fitting.Name} · {fitting.Details} · {Money(fitting.Price)}";
|
||||
}
|
||||
string area = BerthRange(deck.AnchorAt(cell, columns), existing.Length, columns);
|
||||
return selected == Facility.Empty
|
||||
? $"{berth} · Remove {existing.Name.ToLowerInvariant()} and recover {Money(existing.Price / 4)}"
|
||||
: $"{berth} · {existing.Name} · {existing.Details}";
|
||||
? $"{area} · Remove {existing.Name.ToLowerInvariant()} and recover {Money(existing.Price / 4)}"
|
||||
: $"{area} · {existing.Name} · {existing.Details}";
|
||||
}
|
||||
|
||||
private static void AddFacilityMark(VisualElement parent, Facility facility)
|
||||
@@ -215,18 +339,22 @@ namespace Soundings
|
||||
switch (facility)
|
||||
{
|
||||
case Facility.Cabin:
|
||||
case Facility.Suite:
|
||||
case Facility.GrandSuite:
|
||||
Segment(3,18,3,6,5,6,5,12,20,12,20,18);
|
||||
Line(4,16,20,16);
|
||||
Segment(6,11,6,9,10,9,10,11);
|
||||
Segment(11,11,11,8,18,8,20,10,20,12);
|
||||
break;
|
||||
case Facility.Dining:
|
||||
case Facility.Restaurant:
|
||||
Segment(9,9,11,7,15,7,17,10,17,14,15,17,11,17,9,15,9,9);
|
||||
Segment(3,5,3,10,5,12,7,10,7,5);
|
||||
Line(5,11,5,19);
|
||||
Segment(21,5,19,8,19,12,21,12,21,19);
|
||||
break;
|
||||
case Facility.Entertainment:
|
||||
case Facility.GrandTheater:
|
||||
Segment(3,19,3,5,21,5,21,19);
|
||||
Segment(4,7,9,7,7,13,4,16);
|
||||
Segment(20,7,15,7,17,13,20,16);
|
||||
@@ -239,12 +367,14 @@ namespace Soundings
|
||||
Line(6,16,18,16);
|
||||
break;
|
||||
case Facility.Bar:
|
||||
case Facility.CocktailLounge:
|
||||
Segment(4,5,20,5,12,13,4,5);
|
||||
Segment(12,13,12,20,7,20);
|
||||
Line(12,20,17,20);
|
||||
Line(8,8,16,8);
|
||||
break;
|
||||
case Facility.Amenity:
|
||||
case Facility.ResortPool:
|
||||
Segment(4,11,6,7,10,5,14,5,18,7,20,11,4,11);
|
||||
Line(12,11,12,17);
|
||||
Segment(3,19,6,17,9,19,12,17,15,19,18,17,21,19);
|
||||
@@ -372,7 +502,7 @@ namespace Soundings
|
||||
SetRecommendedFuel();
|
||||
Apply(failure, "The ship has been restored to 100% condition.");
|
||||
}, "work-overhaul", "overhaul");
|
||||
overhaul.SetEnabled(price > 0 && company.Cash >= price);
|
||||
overhaul.SetEnabled(price > 0 && company.AvailableCash >= price);
|
||||
service.Add(overhaul);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user