43 lines
1.6 KiB
C#
43 lines
1.6 KiB
C#
using System;
|
|
|
|
namespace BigShipTycoon
|
|
{
|
|
public sealed partial class OnboardSession
|
|
{
|
|
private int performanceStarted = -1;
|
|
private EntertainmentProgram BookedProgram => Quote.Plan?.Program ?? EntertainmentProgram.Shipboard;
|
|
private int PerformanceRounds => PortPlanning.ShowRounds(BookedProgram);
|
|
public bool PerformanceActive => performanceStarted >= 0 && tick < performanceStarted + PerformanceRounds;
|
|
internal bool CanAdvancePerformance => BookedProgram != EntertainmentProgram.Shipboard && performanceStarted < 0
|
|
&& tick + PerformanceRounds < ticks;
|
|
internal string PerformanceLabel
|
|
{
|
|
get
|
|
{
|
|
if (BookedProgram == EntertainmentProgram.Shipboard)
|
|
return "Shipboard sets";
|
|
string title = PortPlanning.ProgramLabel(BookedProgram);
|
|
if (PerformanceActive)
|
|
return $"{title} · now playing ({performanceStarted + PerformanceRounds - tick} rounds)";
|
|
return $"{title} · {(performanceStarted < 0 ? "up next" : "finished")}";
|
|
}
|
|
}
|
|
|
|
internal bool TryAdvancePerformance()
|
|
{
|
|
if (!CanAdvancePerformance)
|
|
return false;
|
|
performanceStarted = tick;
|
|
Measure(false);
|
|
return true;
|
|
}
|
|
|
|
private void AdvancePerformance()
|
|
{
|
|
if (BookedProgram != EntertainmentProgram.Shipboard && performanceStarted < 0
|
|
&& tick >= Math.Min(ticks - PerformanceRounds, ticks * PortPlanning.ShowTime(BookedProgram)))
|
|
performanceStarted = tick;
|
|
}
|
|
}
|
|
}
|