/// <summary> /// Gets all the items in the card that will be loaded into the database. /// </summary> /// <param name="card">The card to parse.</param> /// <returns>A string for each column in the card table.</returns> private static List<string> GetPartsForCard(Card card) { string allSuperTypes = card.Supertypes != null ? string.Join(" ", card.Supertypes) : null; string allTypes = card.Types != null ? string.Join(" ", card.Types) : null; string allSubTypes = card.SubTypes != null ? string.Join(" ", card.SubTypes) : null; List<string> output = new List<string>(); output.Add(card.OracleID.ToString()); output.Add(card.Name); output.Add(card.ManaCost); output.Add(card.CMC.ToString()); output.Add(card.ColorFlags.ToString()); output.Add(card.ColorIdentityFlags.ToString()); output.Add(card.Colors != null ? card.Colors.Count.ToString() : "0"); output.Add(string.Join(" ", allSuperTypes, allTypes)); output.Add(allSubTypes); output.Add(card.Power); output.Add(card.NumPower.ToString()); output.Add(card.Toughness); output.Add(card.NumToughness.ToString()); output.Add(card.Loyalty); output.Add(card.Text != null ? card.Text.Replace('\n', '~') : null); return output; }
/// <summary> /// Serialises the card specific information. /// </summary> /// <param name="card">The card to serialise.</param> /// <returns>The serialised card information.</returns> public static string SerialiseCard(Card card) { var parts = GetPartsForCard(card); return JoinObjectParts(parts); }
/// <summary> /// Serialises the set specific information about a card. /// </summary> /// <param name="card">The card to serialise.</param> /// <param name="set">The set the card is from.</param> /// <param name="includeIdColumn">Whether to include the id column in the output.</param> /// <returns>The serialised card set information.</returns> public static string SerialiseCardSet(Card card, Set set, bool includeIdColumn) { var parts = GetPartsForCardSet(card, set, includeIdColumn); return JoinObjectParts(parts); }
/// <summary> /// Gets all the items in the card that are specific to the printing it is in. /// </summary> /// <param name="card">The card to parse.</param> /// <param name="set">The set the card is within.</param> /// <param name="includeIdColumn">Whether to include the id column in the output</param> /// <returns>The parts of the card.</returns> private static List<string> GetPartsForCardSet(Card card, Set set, bool includeIdColumn) { List<string> parts = new List<string>(); if (includeIdColumn) { // Set the id column to NULL so it is auto-incremented parts.Add(null); } parts.Add(card.OracleID.ToString()); parts.Add(set.Code); parts.Add(card.MultiverseID); parts.Add(card.Artist); parts.Add(card.Flavortext?.Replace("\n", "~")); Rarity rarity = RarityExtensions.GetRarityWithName(card.Rarity); parts.Add(rarity.GetSymbol().ToString()); parts.Add(card.Number); return parts; }