List sectors

This commit is contained in:
Lucidiot 2018-08-22 00:22:09 +02:00
parent 4e6f064b1d
commit 275e1e99d1
No known key found for this signature in database
GPG Key ID: AE3F7205692FA205
2 changed files with 18 additions and 8 deletions

View File

@ -14,7 +14,7 @@ namespace LyokoCMD.Sim.Commands
public override string Description => "Permet d'éxecuter des fonctions sur le monde virtuel.";
public override string HelpText => "Usage : vw [command]\n\tshow [sector]\tAffiche le territoire passé en paramètre.";
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)
{
@ -22,12 +22,17 @@ namespace LyokoCMD.Sim.Commands
if (!sc.Running) throw new InvalidOperationException("Impossible de se connecter au supercalculateur.");
if (!sc.GetWorker("lyoko").Running) throw new InvalidOperationException("Monde virtuel arrêté.");
if (args.Length < 1) throw new ArgumentException(HelpText);
if (args[0] == "show")
{
if (args.Length < 2) throw new ArgumentException(HelpText);
ShowSector(Game.Objects.Get<VirtualWorld>().Sectors.Find(s => s.ShortName == args[1]));
switch(args[0]) {
case "sectors":
Console.WriteLine(Text.BuildTable(Game.Objects.Get<VirtualWorld>().Sectors));
break;
case "show":
if (args.Length < 2) throw new ArgumentException(HelpText);
ShowSector(Game.Objects.Get<VirtualWorld>().Sectors.Find(s => s.ShortName == args[1]));
break;
default:
throw new ArgumentException(HelpText);
}
throw new ArgumentException(HelpText);
}
private void ShowSector(Sector sector)

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DasConzoleCore.UI;
using LyokoCMD.Sim.Virtual;
using LyokoCMD.Sim.Virtual.Towers;
@ -10,7 +11,7 @@ namespace LyokoCMD.Sim.Virtual.World
/// <summary>
/// Décrit un territoire de Lyoko.
/// </summary>
public class Sector
public class Sector : ITableLineOutput
{
protected string _Name;
protected bool _Locked;
@ -23,10 +24,14 @@ namespace LyokoCMD.Sim.Virtual.World
public Sector(string Name, string shortName, bool locked = false)
{
this._Name = Name;
_ShortName = shortName;
this._ShortName = shortName;
this._Locked = locked;
}
public string[] GetColumnNames() => new [] {"ID", "Name", "Locked"};
public string[] GetLine() => new [] {this._ShortName, this._Name, this._Locked.ToString()};
public void CreateTowers(int count)
{
for (int i = 1; i <= count; i++) Objects.Add(new Tower());