public static IEnumerable <CardDefinition> ParseSection(string s) { var list = new List <CardDefinition>(); foreach (Match match in cardRegex.Matches(s)) { int count = match.Groups["count"].Success ? int.Parse(match.Groups["count"].Value) : 1; var name = match.Groups["name"].Value.Trim(); if (name == string.Empty) { continue; } var cardDef = CardDefinition.Get(name); if (list.Contains(cardDef)) { throw new FormatException(string.Format("{0} listed on multiple lines.", cardDef)); } list.AddRange(Enumerable.Repeat(cardDef, count)); } return(list); }
public static int DisplayIndex(this CardDefinition a) { return(a.Types.Select(t => _formatOrder.IndexOf(t)).Min()); }
public static int DisplayCompare(this CardDefinition a, CardDefinition b) { return(a.DisplayIndex().CompareTo(b.DisplayIndex())); }
public Card(Player owner, CardDefinition definition) { this.Owner = owner; this.Definition = definition; this.FaceDown = false; }