예제 #1
0
        public void Initialize(string _color, List <string> _allColors)
        {
            XElement InitXml = toXml.InitializetoXml(_color, _allColors);
            string   init    = toXml.FormatXml(InitXml);

            string response = WriteAndRead(init);
        }
예제 #2
0
        /*
         * returns an xml-string representing proper output
         * to the input xml
         */
        public (string, Boolean) ParseInput(string input)
        {
            XmlDocument document = new XmlDocument();

            document.LoadXml(input);

            string  message = document.FirstChild.Name;
            string  response;
            Boolean done = false;

            switch (message)
            {
            case "get-name":
                string name = player.GetName();
                response = ToXml.FormatXml(ToXml.NametoXml(name));

                break;

            case "initialize":
                (string, List <string>)init = Parser.InitializeParse(input);

                player.Initialize(init.Item1, init.Item2);

                response = ToXml.VoidtoXml();
                break;

            case "place-pawn":
                Board board = Parser.PlacePawnParse(input);

                Position initPosition = player.PlacePawn(board);

                response = ToXml.FormatXml(ToXml.PawnLoctoXml(initPosition));
                break;

            case "play-turn":
                (Board, List <Tile>, int)turnInput = Parser.PlayTurnParse(input);

                Tile playTile = player.PlayTurn(turnInput.Item1, turnInput.Item2, turnInput.Item3);

                response = ToXml.FormatXml(ToXml.TiletoXml(playTile));
                break;

            case "end-game":
                (Board, List <string>)endGame = Parser.EndGameParse(input);

                player.EndGame(endGame.Item1, endGame.Item2);

                response = ToXml.VoidtoXml();
                done     = true;
                break;

            default:
                throw new ArgumentException("invalid xml given");
            }

            return(response, done);
        }
예제 #3
0
        static string FormatXmlWrapper(XElement xElement)
        {
            ToXml toXml = new ToXml();

            return(toXml.FormatXml(xElement));
        }