-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCloseRoute.cs
67 lines (50 loc) · 1.98 KB
/
CloseRoute.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System;
using System.Threading.Tasks;
namespace NuzlockeHelper
{
public class CloseRoute : Command
{
public Routes Routes { get; private set; }
public CloseRoute() : base("closeroute")
{
Routes = new Routes();
}
public override void RunCommand()
{
var firstRoute = Routes.allRoutes[0].RouteNumber;
var lastRoute = Routes.allRoutes[^1].RouteNumber;
SManager.ScreenInfo.ResetInfo();
SManager.ScreenInfo.AddInfo($"These are the routes you have already closed:");
for (byte i = 0; i < Routes.allRoutes.Length; i++)
{
if (Routes.allRoutes[i].IsClosed)
{
SManager.ScreenInfo.AddInfo($"Route {Routes.allRoutes[i].RouteNumber}");
}
}
SManager.ScreenInfo.AddInfo(" ");
SManager.ScreenInfo.AddInfo($"Which route would you like to close? {firstRoute}-{lastRoute}");
SManager.ScreenInfo.PrintInfo();
string command = Console.ReadLine();
bool isInt = int.TryParse(command, out var route);
if (isInt && route <= Routes.allRoutes.Length)
{
ConfirmChoice(route);
}
SManager.ScreenInfo.ResetInfo();
SManager.ScreenInfo.AddInfo(StageInfo.Messages[SManager.Stages.CurrentStage]);
}
private void ConfirmChoice(int route)
{
Console.WriteLine($"You have elected to close route {route}, press Y to confirm.");
var command = Console.ReadLine();
if (command == null || command.ToLower() != "y" || Routes.allRoutes[route - 1].IsClosed) return;
Routes.allRoutes[route-1].CloseRoute();
}
/*Methods related to saving Routes list info. */
public async Task SaveRoutes(StoreData data)
{
await data.CheckIfNoRoutesStored(Routes);
}
}
}