Example #1
0
        public override XElement GenerateXElement()
        {
            // Game
            XElement rootEl = new XElement("Game");

            // Current Player
            XElement currentPlayerEl = new XElement("CurrentPlayer", CurrentPlayer);

            rootEl.Add(currentPlayerEl);

            // RoundCounter
            XElement roundCounterEl = new XElement("RoundCounter", RoundCounter);

            rootEl.Add(roundCounterEl);

            // Phase
            XElement phaseEl = new XElement("Phase", Phase.ToString());

            rootEl.Add(phaseEl);

            // Player1
            XElement player1El = new XElement("Player1", Player1.GenerateXElement());

            rootEl.Add(player1El);

            // Player2
            XElement player2El = new XElement("Player2", Player2.GenerateXElement());

            rootEl.Add(player2El);

            // Player3
            XElement player3El = new XElement("Player3", Player3.GenerateXElement());

            rootEl.Add(player3El);

            // Player4
            XElement player4El = new XElement("Player4", Player4.GenerateXElement());

            rootEl.Add(player4El);

            // CurrentTrick
            XElement currentTrickEl = new XElement("CurrentTrick", (from item in currentTrick
                                                                    select item.GenerateXElement()).ToList());

            rootEl.Add(currentTrickEl);

            // TrickHistory
            XElement trickHistoryEl = new XElement("TrickHistory", (from trick in trickHistory
                                                                    select new XElement("Trick",
                                                                                        from item  in trick
                                                                                        select item.GenerateXElement())).ToList());

            rootEl.Add(trickHistoryEl);

            return(rootEl);
        }