Skip to content

Commit

Permalink
Remove interface, replace with CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarcederberg committed Jul 25, 2021
1 parent 01a96f5 commit 1ee8fb9
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 213 deletions.
5 changes: 0 additions & 5 deletions Class/ISpread.cs

This file was deleted.

7 changes: 0 additions & 7 deletions Class/IUserInterface.cs

This file was deleted.

173 changes: 0 additions & 173 deletions Class/MainUI.cs

This file was deleted.

23 changes: 0 additions & 23 deletions Class/SpreadUI.cs

This file was deleted.

51 changes: 46 additions & 5 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,55 @@
using System;
using System.Collections.Generic;
using CommandLine;

namespace tarot{
class Program{
static void Main(string[] args){
[Verb("get", HelpText = "Retrieve cards from the deck.")]
public class GetOptions{
[Value(0, MetaName = "amount", MetaValue = "int", Default = 1, HelpText = "Amount of cards to retrieve.")]
public uint Amount{get; set;}
}

[Verb("shuffle", HelpText = "Shuffle the deck")]
public class ShuffleOptions{
[Value(0, MetaName = "type", MetaValue = "string", Default = "riffle", HelpText = "What shuffle to perform.")]
public string Type{get; set;}
}

static int Main(string[] args){
Type[] types = {typeof(ShuffleOptions), typeof(GetOptions)};

Deck deck = new Deck();
deck.AddToDeck(Utilities.DeserializeMajorArcana(@"Data/base_majorarcana.json"));
deck.AddToDeck(Utilities.DeserializeMinorArcana(@"Data/base_minorarcana.json"));
MainUI ui = new MainUI(deck);
ui.Show();
}

return Parser.Default.ParseArguments(args, types)
.MapResult(
(GetOptions options) => {
options.Amount = Math.Max(1, options.Amount);
for (int i = 0; i < options.Amount; i++){
Console.WriteLine(deck.RequeueCard().ToString());
}
return 0;
},
(ShuffleOptions options) => {
switch(options.Type.ToLower()){
case "riffle":
deck.ShuffleDeck(ShuffleType.Riffle);
break;
case "overhand":
deck.ShuffleDeck(ShuffleType.Overhand);
break;
case "fisheryates" or "perfect":
deck.ShuffleDeck(ShuffleType.FisherYates);
break;
default:
Console.WriteLine("Unkown shuffletype: {0}", options.Type.ToLower());
return 1;
}
Console.WriteLine("Performed {0} shuffle", options.Type.ToLower());
return 0;
},
errors => 1);
}
}
}
1 change: 1 addition & 0 deletions tarot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.8.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

Expand Down

0 comments on commit 1ee8fb9

Please sign in to comment.