public void ReadXml(System.Xml.XmlReader reader) { reader.MoveToContent(); this.Name = reader.GetAttribute("Name"); this.Won = bool.Parse(reader.GetAttribute("Won")); reader.ReadStartElement(); // players int playerCount = int.Parse(reader.GetAttribute("Count")); for (int i = 0; i < playerCount; i++) { // opponent if (i == 0) { reader.ReadStartElement(); } PlayerRecord player = new PlayerRecord(); this.Players.Add(player); player.Name = reader.GetAttribute("Name"); player.Score = int.Parse(reader.GetAttribute("Score")); // deck reader.ReadStartElement(); player.Deck = reader.ReadElementContentAsString(); reader.ReadEndElement(); } reader.ReadEndElement(); // turns int turnCount = int.Parse(reader.GetAttribute("Count")); reader.ReadStartElement(); for (int i = 0; i < turnCount; i++) { this.Log.Add(reader.ReadElementContentAsString()); } }
public GameRecord ToGameRecord(Player player) { GameRecord record = new GameRecord(); record.Name = player.Name; record.Won = this.ResultMap[player].Won; foreach (LogTurn turn in player.GameModel.TextLog.Turns) { foreach (string line in turn.Lines) { record.Log.Add(line.Trim()); } } foreach (Player p in player.GameModel.Players) { PlayerRecord playerRecord = new PlayerRecord(); playerRecord.Name = p.Name; playerRecord.Score = this.ResultMap[p].Score; playerRecord.Deck = Log.FormatSortedCards(p.AllCardsInDeck); record.Players.Add(playerRecord); } return record; }