Split out play resolution

This commit is contained in:
Andrew Cooper
2022-03-30 16:50:48 +11:00
parent 741b135d99
commit 1ba6dd48aa
5 changed files with 252 additions and 214 deletions

View File

@@ -0,0 +1,32 @@
using Basketball.Resources;
using Games.Common.IO;
namespace Basketball;
internal class Clock
{
private readonly IReadWrite _io;
private int time;
public Clock(IReadWrite io) => _io = io;
public bool IsHalfTime => time == 50;
public bool IsFullTime => time >= 100;
public bool TwoMinutesLeft => time == 92;
public void Increment(Scoreboard scoreboard)
{
time += 1;
if (IsHalfTime)
{
scoreboard.Display(Resource.Formats.EndOfFirstHalf);
// Loop back to center jump;
}
if (TwoMinutesLeft)
{
_io.Write(Resource.Streams.TwoMinutesLeft);
}
}
public void StartOvertime() => time = 93;
}