-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
01a96f5
commit 1ee8fb9
Showing
6 changed files
with
47 additions
and
213 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -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); | ||
} | ||
} | ||
} |
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