-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
DataInterfaceConsole/Actions/LoadPredefinedOfflineVariant.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using FiveDChessDataInterface.Variants; | ||
using System; | ||
|
||
namespace DataInterfaceConsole.Actions | ||
{ | ||
class LoadPredefinedOfflineVariant : BaseAction | ||
{ | ||
public override string Name => "Load Predefined Variant [OFFLINE]"; | ||
|
||
protected override void Run() | ||
{ | ||
WaitForIngame(); | ||
var variants = GithubVariantGetter.GetAllVariants(true, true); | ||
|
||
WriteLineIndented("Select a variant from the following:"); | ||
for (int i = 0; i < variants.Length; i++) | ||
{ | ||
WriteLineIndented($"{(i + 1).ToString().PadLeft((int)Math.Ceiling(Math.Log10(variants.Length)))}. {variants[i].Name} by {variants[i].Author}"); | ||
} | ||
|
||
if (int.TryParse(Util.ConsoleReadLineWhile(() => this.di.IsValid()), out int input) && input > 0 && input <= variants.Length) | ||
{ | ||
var chosenVariant = variants[input - 1]; | ||
WriteLineIndented($"Loading variant '{chosenVariant.Name}'..."); | ||
var gb = chosenVariant.GetGameBuilder(); | ||
this.di.SetChessBoardArrayFromBuilder(gb); | ||
WriteLineIndented($"Variant loaded and written to memory."); | ||
} | ||
else | ||
{ | ||
WriteLineIndented("Invalid input. Not loading any variant."); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters