public MagicCard(UInt32 mId, String name, ManaCost cost, List<CardType> types, List<String> subtypes, List<String> text, List<String> flavour, String mark, String pow, String tough, String expansion, CardRarity rarity, Dictionary<String, UInt32> sets, Int16 num, String artist, Double rating, List<Ruling> rulings, String artUrl) { MultiverseId = mId; Name = name; Cost = cost; Types = types; SubTypes = subtypes; Text = text; FlavorText = flavour; Watermark = mark; Power = pow; Toughness = tough; Expansion = expansion; Rarity = rarity; Printings = sets; Artist = artist; CommunityRating = rating; CardNumber = num; Rulings = rulings; CardArtUrl = artUrl; }
protected static ManaCost ParseImgsToManaCost(HtmlNodeCollection nodes) { ManaCost cost = new ManaCost(); if (nodes == null) return cost; foreach (var imgNode in nodes) { #region Switch mana cost switch (imgNode.Attributes["alt"].Value) { // Basic mana types case "White": cost.White++; break; case "Black": cost.Black++; break; case "Green": cost.Green++; break; case "Blue": cost.Blue++; break; case "Red": cost.Red++; break; // "X" cost mana case "VariableColorless": cost.HasX = true; break; // Phyrexian mana types case "Phyrexian Red": cost.PhyrexianRed++; break; case "Phyrexian Blue": cost.PhyrexianBlue++; break; case "Phyrexian Green": cost.PhyrexianGreen++; break; case "Phyrexian White": cost.PhyrexianWhite++; break; case "Phyrexian Black": cost.PhyrexianBlack++; break; // Hybrid mana types case "Black or Green": cost.BlackGreen++; break; case "Black or Red": cost.BlackRed++; break; case "Blue or Black": cost.BlueBlack++; break; case "Blue or Red": cost.BlueRed++; break; case "Green or Blue": cost.GreenBlue++; break; case "Green or White": cost.GreenWhite++; break; case "Red or Green": cost.RedGreen++; break; case "Red or White": cost.RedWhite++; break; case "White or Black": cost.WhiteBlack++; break; case "White or Blue": cost.WhiteBlue++; break; case "Two or Black": cost.ColorlessBlack++; break; case "Two or Blue": cost.ColorlessBlue++; break; case "Two or Green": cost.ColorlessGreen++; break; case "Two or Red": cost.ColorlessRed++; break; case "Two or White": cost.ColorlessWhite++; break; // Colorless mana default: UInt16 colorless; if (UInt16.TryParse(imgNode.Attributes["alt"].Value, out colorless)) cost.Colorless = colorless; break; } #endregion } return cost; }
public static ManaCost Parse(string manaStr) { ManaCost cost = new ManaCost(); // Count basic mana costs MatchCollection matches = Regex.Matches(manaStr, "([0-9]|[XURGBW]|\\{[URGBW2]/[URGBW]\\}|\\{[URGBW]P\\})"); foreach (Match match in matches) { switch (match.Value) { // Coloured basic costs case "B": case "{B/B}": cost.Black++; break; case "U": case "{U/U}": cost.Blue++; break; case "G": case "{G/G}": cost.Green++; break; case "R": case "{R/R}": cost.Red++; break; case "W": case "{W/W}": cost.White++; break; case "X": cost.HasX = true; break; // Phyrexian mana case "{BP}": cost.PhyrexianBlack++; break; case "{UP}": cost.PhyrexianBlue++; break; case "{GP}": cost.PhyrexianGreen++; break; case "{RP}": cost.PhyrexianRed++; break; case "{WP}": cost.PhyrexianWhite++; break; // Hybrid mana case "{B/G}": case "{G/B}": cost.BlackGreen++; break; case "{B/R}": case "{R/B}": cost.BlackRed++; break; case "{U/B}": case "{B/U}": cost.BlueBlack++; break; case "{U/R}": case "{R/U}": cost.BlueRed++; break; case "{G/U}": case "{U/G}": cost.GreenBlue++; break; case "{G/W}": case "{W/G}": cost.GreenWhite++; break; case "{R/G}": case "{G/R}": cost.RedGreen++; break; case "{R/W}": case "{W/R}": cost.RedWhite++; break; case "{W/B}": case "{B/W}": cost.WhiteBlack++; break; case "{W/U}": case "{U/W}": cost.WhiteBlue++; break; case "{2/B}": cost.ColorlessBlack++; break; case "{2/U}": cost.ColorlessBlue++; break; case "{2/G}": cost.ColorlessGreen++; break; case "{2/R}": cost.ColorlessRed++; break; case "{2/W}": cost.ColorlessWhite++; break; // Colorless mana default: cost.Colorless += UInt16.Parse(match.Value); break; } } return cost; }