Add 'vw status' command
This commit is contained in:
parent
dae10022e0
commit
d839807148
|
@ -14,27 +14,31 @@ namespace LyokoCMD.CommandLine.Commands
|
|||
{
|
||||
public override string[] Names => new string[] { "vw" };
|
||||
|
||||
public override string Description => "Permet d'éxecuter des fonctions sur le monde virtuel.";
|
||||
public override string Description => "Contrôle du monde virtuel.";
|
||||
|
||||
public override string HelpText => "Usage : vw [command]\n\tsectors\tListe les territoires.\n\tshow [sector]\tAffiche le territoire passé en paramètre.";
|
||||
|
||||
public override void Run(CommandApp app, string[] args)
|
||||
{
|
||||
if (args.Length < 1) throw new ArgumentException(HelpText);
|
||||
|
||||
Supercomputer sc = Game.Objects.Get<Supercomputer>();
|
||||
if (!sc.Running)
|
||||
throw new InvalidOperationException("Impossible de se connecter au supercalculateur.");
|
||||
if (!sc.Workers.Get<VirtualWorldWorker>().Running && args[0].ToLower().Trim() != "start")
|
||||
throw new InvalidOperationException("Monde virtuel arrêté.");
|
||||
|
||||
VirtualWorldWorker worker = sc.Workers.Get<VirtualWorldWorker>();
|
||||
VirtualWorld vw = Game.Objects.Get<VirtualWorld>();
|
||||
switch (args[0].ToLower().Trim())
|
||||
{
|
||||
case "sectors":
|
||||
Console.WriteLine(Text.BuildTable(Game.Objects.Get<VirtualWorld>().Sectors));
|
||||
if (!worker.Running) throw new InvalidOperationException("Service de monde virtuel inactif.");
|
||||
Console.WriteLine(Text.BuildTable(vw.Sectors));
|
||||
break;
|
||||
case "show":
|
||||
if (args.Length < 2) throw new ArgumentException(HelpText);
|
||||
if (!worker.Running) throw new InvalidOperationException("Service de monde virtuel inactif.");
|
||||
new SectorMapApp(
|
||||
Game.Objects.Get<VirtualWorld>().Sectors.Find(
|
||||
vw.Sectors.Find(
|
||||
s => s.ShortName.Equals(args[1],
|
||||
StringComparison.CurrentCultureIgnoreCase
|
||||
)),
|
||||
|
@ -42,10 +46,17 @@ namespace LyokoCMD.CommandLine.Commands
|
|||
).Run();
|
||||
break;
|
||||
case "start":
|
||||
sc.Workers.Get<VirtualWorldWorker>().Start();
|
||||
worker.Start();
|
||||
break;
|
||||
case "stop":
|
||||
sc.Workers.Get<VirtualWorldWorker>().Stop();
|
||||
if (!worker.Running) throw new InvalidOperationException("Service de monde virtuel inactif.");
|
||||
worker.Stop();
|
||||
break;
|
||||
case "status":
|
||||
Console.WriteLine("État du service : " + (worker.Running ? "Actif" : "Inactif"));
|
||||
if(!worker.Running) break;
|
||||
Console.WriteLine($"Énergie utilisée : {worker.RequiredEnergy.ToString()}");
|
||||
Console.WriteLine($"{vw.Sectors.Count} territoires");
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException(HelpText);
|
||||
|
|
Reference in New Issue