diff --git a/Classes/ICard.cs b/Classes/ICard.cs deleted file mode 100644 index 68bffd4..0000000 --- a/Classes/ICard.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace tarot{ - public interface ICard{ - public String GetName(); - - public String GetKeywords(); - } -} \ No newline at end of file diff --git a/Classes/IDeck.cs b/Classes/IDeck.cs deleted file mode 100644 index 3f3dd1a..0000000 --- a/Classes/IDeck.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace tarot{ - public interface IDeck where T : ICard{ - public void DeserializeDeck(string filePath); - - public string SerializeDeck(); - - public T RequeueCard(); - - public void PrintDeck(); - - public void ShuffleDeck(ShuffleType shuffleType); - - public void SwapCards(int firstIndex, int secondIndex); - - public void MoveCard(int cardIndex, int newIndexx); - } -} \ No newline at end of file diff --git a/Classes/ISpread.cs b/Classes/ISpread.cs deleted file mode 100644 index 218113a..0000000 --- a/Classes/ISpread.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace tarot{ - public interface ISpread where T : IDeck where U : ICard { - public void EnqueueCards(T deck); - - public string SerializeSpread(); - - public string SerializeCards(); - - public void PrintSpread(); - - public void PrintPositions(); - - public int Length(); - } -} \ No newline at end of file diff --git a/Classes/TarotCard.cs b/Classes/TarotCard.cs index 471fced..b12528f 100644 --- a/Classes/TarotCard.cs +++ b/Classes/TarotCard.cs @@ -1,19 +1,30 @@ namespace tarot{ - public class TarotCard : ICard{ + public enum Orientation{ + Upright, + Reverse + } + + public class TarotCard{ public readonly string Name; - public readonly string Keywords; + public readonly string KeywordsUpright; + public readonly string KeywordsReverse; - public TarotCard(string name, string keywords){ + public TarotCard(string name, string keywordsUpright, string keywordsReverse){ this.Name = name; - this.Keywords = keywords; + this.KeywordsUpright = keywordsUpright; + this.KeywordsReverse = keywordsReverse; } public string GetName(){ return Name; } - public string GetKeywords(){ - return Keywords; + public string GetKeywords(Orientation orientation = Orientation.Upright){ + if(orientation is Orientation.Upright){ + return KeywordsUpright; + }else{ + return KeywordsReverse; + } } } } \ No newline at end of file diff --git a/Classes/TarotDeck.cs b/Classes/TarotDeck.cs index d905b46..9c902c5 100644 --- a/Classes/TarotDeck.cs +++ b/Classes/TarotDeck.cs @@ -8,7 +8,7 @@ public enum ShuffleType{ Riffle } - public class TarotDeck : IDeck{ + public class TarotDeck{ public readonly List Cards; public TarotDeck(){ diff --git a/Classes/TarotSpread.cs b/Classes/TarotSpread.cs index 9209329..52f4e2d 100644 --- a/Classes/TarotSpread.cs +++ b/Classes/TarotSpread.cs @@ -1,7 +1,7 @@ using System; namespace tarot{ - public class TarotSpread : ISpread{ + public class TarotSpread{ public readonly string[] Positions; private TarotCard[] _spread_cards; diff --git a/Data/default_cards.json b/Data/default_cards.json index 28ba368..2bfc481 100644 --- a/Data/default_cards.json +++ b/Data/default_cards.json @@ -1,318 +1,396 @@ [ { "Name": "0 The Fool", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "I The Magician", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "II The High Priestess", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "III The Empress", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "IV The Emperor", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "V The Hierophant", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "VI The Lovers", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "VII The Chariot", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "VIII Strength", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "IX The Hermit", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "X Wheel of Fortune", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "XI Justice", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "XII The Hanged Man", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "XIII Death", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "XIV Temperance", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "XV The Devil", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "XVI The Tower", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "XVII The Star", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "XVIII The Moon", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "XIX The Sun", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "XX Judgement", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "XXI The World", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Ace of Staffs", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Two of Staffs", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Three of Staffs", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Four of Staffs", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Five of Staffs", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Six of Staffs", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Seven of Staffs", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Eight of Staffs", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Nine of Staffs", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Ten of Staffs", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Page of Staffs", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Knight of Staffs", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Queen of Staffs", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "King of Staffs", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Ace of Cups", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Two of Cups", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Three of Cups", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Four of Cups", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Five of Cups", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Six of Cups", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Seven of Cups", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Eight of Cups", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Nine of Cups", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Ten of Cups", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Page of Cups", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Knight of Cups", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Queen of Cups", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "King of Cups", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Ace of Swords", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Two of Swords", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Three of Swords", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Four of Swords", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Five of Swords", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Six of Swords", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Seven of Swords", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Eight of Swords", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Nine of Swords", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Ten of Swords", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Page of Swords", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Knight of Swords", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Queen of Swords", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "King of Swords", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Ace of Pentacles", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Two of Pentacles", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Three of Pentacles", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Four of Pentacles", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Five of Pentacles", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Six of Pentacles", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Seven of Pentacles", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Eight of Pentacles", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Nine of Pentacles", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Ten of Pentacles", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Page of Pentacles", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Knight of Pentacles", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "Queen of Pentacles", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" }, { "Name": "King of Pentacles", - "Keywords": "" + "KeywordsUpright": "", + "KeywordReverse": "" } ] \ No newline at end of file diff --git a/Data/template_cards.json b/Data/template_cards.json index eb00baf..7cb2171 100644 --- a/Data/template_cards.json +++ b/Data/template_cards.json @@ -2,6 +2,10 @@ /* Add any amount of cards that should be added to the deck in the following format */ /* - {"Name": "Name of Card"} + { + "Name": "Name of Card" + "KeywordsUpright": "Keywords for card in upright position" + "KeywordsReverse": "Keywords for card in reverse position" + } */ ] \ No newline at end of file diff --git a/Options.cs b/Options.cs index ffbccac..eb07c43 100644 --- a/Options.cs +++ b/Options.cs @@ -6,6 +6,9 @@ public class GetOptions{ [Value(0, MetaName = "amount", MetaValue = "uint", Required = false, Default = 1u, HelpText = "Amount of cards to retrieve.")] public uint Amount{get; set;} + [Option('r',"randomize-orientation", Default = false, HelpText = "Randomize orientation of retrieved cards.")] + public bool RandomizeOrientation{get; set;} + [Option('k',"keywords", HelpText = "Print out keywords related to the retrieved cards.")] public bool Keywords{get; set;} } diff --git a/Program.cs b/Program.cs index af69643..e18eb28 100644 --- a/Program.cs +++ b/Program.cs @@ -85,10 +85,23 @@ static void SaveDeck(TarotDeck deck){ private static int Get(GetOptions options, TarotDeck deck){ options.Amount = Math.Max(1, options.Amount); + Random random = new Random(); + Array orientations = Enum.GetValues(typeof(Orientation)); + for (int i = 0; i < options.Amount; i++){ TarotCard card = deck.RequeueCard(); - Console.WriteLine(card.GetName()); - if(options.Keywords) Console.WriteLine($"\tKeywords: {card.GetKeywords()}"); + if(options.RandomizeOrientation){ + Orientation orientation = (Orientation)orientations.GetValue(random.Next(orientations.Length)); + if(orientation == Orientation.Upright){ + Console.WriteLine(card.GetName()); + }else{ + Console.WriteLine($"Reverse {card.GetName()}"); + } + if(options.Keywords) Console.WriteLine($"\tKeywords: {card.GetKeywords(orientation)}"); + }else{ + Console.WriteLine(card.GetName()); + if(options.Keywords) Console.WriteLine($"\tKeywords: {card.GetKeywords()}"); + } } SaveDeck(deck); return 0; @@ -182,7 +195,7 @@ private static int View(ViewOptions options, TarotDeck deck, TarotSpreads spread TarotCard card = deck.Cards.Find(c => c.Name.ToLower() == options.Name.ToLower()); if(card is not null){ - Console.WriteLine($"{card.GetName()}:\n\t{card.GetKeywords()}"); + Console.WriteLine($"{card.GetName()}: \n\tUpright: {card.GetKeywords(Orientation.Upright)}\n\tReverse: {card.GetKeywords(Orientation.Reverse)}"); }else{ Console.WriteLine("That card does not exist."); return 1; @@ -195,7 +208,7 @@ private static int View(ViewOptions options, TarotDeck deck, TarotSpreads spread for (int i = 0; i < cards_in_order.Count; i++){ TarotCard card = cards_in_order[i]; - Console.WriteLine($"{card.GetName()}:\n\tKeywords: {card.GetKeywords()}"); + Console.WriteLine($"{card.GetName()}: \n\tUpright: {card.GetKeywords(Orientation.Upright)}\n\tReverse: {card.GetKeywords(Orientation.Reverse)}"); } } }else if(options.Spread){ diff --git a/TODO.md b/TODO.md index e864b8d..fc58cf4 100644 --- a/TODO.md +++ b/TODO.md @@ -12,7 +12,6 @@ C# Tarot-reading application ### Todo - [ ] Flags for retrieving in .json-format. -- [ ] Add option for drawing reverse cards - [ ] ⚠️Switch uint arguments to int, handle out-of-range cases. - [ ] ⚠️Customize help. - [ ] ⚠️Refactor input-handling. @@ -25,6 +24,7 @@ C# Tarot-reading application ### Done ✓ +- [x] Add option for drawing reverse cards - [x] List cards in order - [x] Move listing spreads and viewing one single spread to a verb that also allows viewing a specific card or all cards - [x] Add tarot card meanings/keywords.