public void CommunityCardsIssueTest() { string handText = SampleHandHistoryRepository.GetHandExample(_format, Site, "ExtraHands", "CommunityCardsIssue"); var actualCommunityCards = GetParser().ParseCommunityCards(handText); var expected = BoardCards.Parse("Jd 7s 2c 2s 9d"); Assert.AreEqual(expected, actualCommunityCards); }
protected override PlayerList ParsePlayers(string[] handLines) { XDocument document = GetXDocumentFromLines(handLines); XElement gameElement = GetGameElementFromXDocument(document); XElement players = gameElement.Element("players"); PlayerList playerList = new PlayerList(); //Build a query for all cards elements which are "SHOWN" or "MUCKED" rather than "COMMUNITY" IEnumerable <XElement> cardElements = gameElement.Elements("round").Elements("cards").Where(element => element.Attribute("type").Value[0] != 'C').ToList(); foreach (XElement playerElement in players.Elements()) { //Player Element looks like: //<player seat="0" nickname="GODEXISTSJK" balance="$269.96" dealtin="true" /> decimal stack = decimal.Parse(playerElement.Attribute("balance").Value.Substring(1), System.Globalization.CultureInfo.InvariantCulture); string playerName = playerElement.Attribute("nickname").Value; int seat = Int32.Parse(playerElement.Attribute("seat").Value); Player player = new Player(playerName, stack, seat); bool dealtIn = bool.Parse(playerElement.Attribute("dealtin").Value); player.IsSittingOut = !dealtIn; //<cards type="SHOWN" cards="Ac,4c" player="7"/> XElement playerCardElement = cardElements.FirstOrDefault(card => Int32.Parse(card.Attribute("player").Value) == seat); if (playerCardElement != null) { string cardString = playerCardElement.Attribute("cards").Value; player.HoleCards = HoleCards.NoHolecards(); player.HoleCards.AddCards(BoardCards.Parse(cardString)); } playerList.Add(player); } return(playerList); }