Skip to content

Commit

Permalink
Change Card structure. Rename MenuCLI classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarcederberg committed Jul 26, 2021
1 parent 657b2c8 commit 37b8048
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 384 deletions.
14 changes: 0 additions & 14 deletions Class/CardMajorArcana.cs

This file was deleted.

16 changes: 0 additions & 16 deletions Class/CardMinorArcana.cs

This file was deleted.

4 changes: 2 additions & 2 deletions Class/Deck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public Deck(){
this._deck = new List<ICard>();
}

public void AddToDeck(IEnumerable<ICard> collection){
this._deck.AddRange(collection);
public void AddToDeck(string filePath){
_deck.AddRange(Utilities.Deserialize<List<TarotCard>>(filePath));
}

public ICard RequeueCard() {
Expand Down
4 changes: 2 additions & 2 deletions Class/MenuCLI/MenuEntryFunc.cs → Class/MenuCLI/FuncEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
using Subscription;

namespace MenuCLI{
public class MenuEntryFunc<T> : AbstractMenuEntry<T>{
public class FuncEntry<T> : MenuEntry<T>{
private Func<T> _func;

public MenuEntryFunc(string text, Func<T> func, ISubscriber<T> subscriber = null) : base(text, subscriber){
public FuncEntry(string text, Func<T> func, ISubscriber<T> subscriber = null) : base(text, subscriber){
this._func = func;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
using Subscription;

namespace MenuCLI{
public abstract class AbstractMenuEntry<T> : IMenuEntry, ISubscribable<T>{
public abstract class MenuEntry<T> : IMenuEntry, ISubscribable<T>{
protected string _text;
protected readonly List<ISubscriber<T>> _subscribers;

protected AbstractMenuEntry(string text, ISubscriber<T> subscriber = null){
protected MenuEntry(string text, ISubscriber<T> subscriber = null){
this._text = text;
this._subscribers = new List<ISubscriber<T>>();
if (subscriber is not null) _subscribers.Add(subscriber);
Expand Down
4 changes: 2 additions & 2 deletions Class/MenuCLI/ListMenu.cs → Class/MenuCLI/MenuList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
using tarot;

namespace MenuCLI{
public class ListMenu : IMenu{
public class MenuList : IMenu{
private IMenuEntry[] _entries;
private string _cursor;
private int _selection = 0;

public ListMenu(IMenuEntry[] entries, string cursor){
public MenuList(IMenuEntry[] entries, string cursor){
this._entries = entries;
this._cursor = cursor;
}
Expand Down
6 changes: 3 additions & 3 deletions Class/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
namespace tarot{
[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.")]
[Value(0, MetaName = "amount", MetaValue = "int", Required = false, 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.")]
[Value(0, MetaName = "type", MetaValue = "string", Required = false, Default = "riffle", HelpText = "What shuffle to perform.")]
public string Type{get; set;}
[Value(1, MetaName = "amount", MetaValue = "int", Default = 1, HelpText = "Number of shuffles to perform.")]
[Value(1, MetaName = "amount", MetaValue = "int", Required = false, Default = 1, HelpText = "Number of shuffles to perform.")]
public int Amount{get; set;}
[Option('q',"quiet", HelpText = "Suppress stdout.")]
public bool Quiet{get; set;}
Expand Down
12 changes: 12 additions & 0 deletions Class/TarotCard.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace tarot{
public class TarotCard : ICard{
private readonly string _name;
public TarotCard(int id, string name){
this._name = name;
}

public override string ToString(){
return this._name;
}
}
}
26 changes: 2 additions & 24 deletions Class/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,8 @@ public static class Utilities{
(100, "C"), (90, "XC"), (50, "L"), (40, "XL"), (10, "X"), (9, "IX"), (5, "V"), (4, "IV"), (1, "I")
};

public static List<CardMajorArcana> DeserializeMajorArcana(string file){
return JsonConvert.DeserializeObject<List<CardMajorArcana>>(File.ReadAllText(file));
}

public static List<CardMinorArcana> DeserializeMinorArcana(string file){
return JsonConvert.DeserializeObject<List<CardMinorArcana>>(File.ReadAllText(file));
}

public static string ToMinorArcanaValueNotation(int number){
number = Math.Max(Math.Min(number, 14), 1);
switch (number){
case 1:
return "Ace";
case 11:
return "Page";
case 12:
return "Knight";
case 13:
return "Queen";
case 14:
return "King";
default:
return ToRoman(number);
}
public static T Deserialize<T>(string filePath){
return JsonConvert.DeserializeObject<T>(File.ReadAllText(filePath));
}

public static string ToRoman(int number){
Expand Down
90 changes: 0 additions & 90 deletions Data/base_majorarcana.json

This file was deleted.

Loading

0 comments on commit 37b8048

Please sign in to comment.