Exemplo n.º 1
0
        public static string interpretString(string thestring, GameObject gameobj, GameTypeSettingsObj gamesetobj)
        {
            ///$gamename
            ///$plrnumber
            ///$password
            ///$turnnumber
            ///$savepath
            ///$modpath
            string fmt = "000#";
            thestring = thestring.Replace("$gamename", gameobj.GameName);
            thestring = thestring.Replace("$plrnumber", gameobj.GamePlrNumber.ToString(fmt));
            thestring = thestring.Replace("$password", gameobj.GamePlrEmpPassword);
            thestring = thestring.Replace("$turnnumber", gameobj.GameTurnNum.ToString());
            thestring = thestring.Replace("$savepath", gamesetobj.GameMods[gameobj.GameMod].ModSavePath);
            thestring = thestring.Replace("$modpath", gamesetobj.GameMods[gameobj.GameMod].ModPath);

            return thestring;
        }
Exemplo n.º 2
0
        /// <summary>
        /// turns game xml data from pbw, cuts it into seperate games and creates a gamesObject.
        /// </summary>
        /// <param name="xmlstring">xmlstring from PBW</param>
        /// <param name="dictionaryofgameobjects">dictionary of exsisting gameobjects</param>
        /// <returns>
        /// </returns>
        /// a dictionary of game objects.
        /// <remarks>
        /// 
        /// </remarks>
        public static Dictionary<string, GameObject> XmlToGameObj(string xmlstring, Dictionary<string, GameObject> dictionaryofgameobjects)
        {
            List<List<string>> listofgames = new List<List<string>>();

            string[] lines = xmlstring.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

            int boxindex = 0;
            bool dataIsGame = false;
            foreach (string line in lines)
            {
                //List<string> thisgame = new List<string>();
                string lineTrim = line.Trim();

                if (lineTrim == @"</game>")
                {
                    dataIsGame = false;
                    GameObject thisgameobj = new GameObject(listofgames[boxindex]);
                    if (dictionaryofgameobjects.ContainsKey(thisgameobj.GameName))
                    {
                        dictionaryofgameobjects[thisgameobj.GameName] = thisgameobj;
                    }
                    else
                    {
                        dictionaryofgameobjects.Add(thisgameobj.GameName, thisgameobj);
                    }
                    boxindex += 1;
                }
                if (dataIsGame)
                {
                    listofgames[boxindex].Add(lineTrim);
                }

                if (lineTrim == "<game>")
                {
                    dataIsGame = true;
                    listofgames.Add(new List<string>());
                }
            }
            return dictionaryofgameobjects;
        }
        private void xmlToGameObj(string xmlstring)
        {
            /// <summary>
            /// turns game xml data from pbw, cuts it into seperate games and creates a gamesObject.
            /// </summary>
            /// <param name="xmlstring">xmlstring from PBW</param>
            /// <returns>
            /// </returns>
            /// <remarks>
            ///
            /// </remarks>
            string[] lines = xmlstring.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            List<List<string>> listofgames = new List<List<string>>();
            int boxindex = 0;
            bool data_is_game = false;
            foreach (string line in lines)
            {
                //List<string> thisgame = new List<string>();
                string line_trim = line.Trim();

                if (line_trim == @"</game>")
                {
                    data_is_game = false;
                    GameObject thisgameobj = new GameObject(listofgames[boxindex]);
                    //if thisgameobj.GameName does not exsist in listofgameobjects... should listofgameobjects be a dictionary maybe?
                    listofgameobjects.Add(thisgameobj);
                    boxindex += 1;
                }
                if (data_is_game)
                {
                    listofgames[boxindex].Add(line_trim);
                }

                if (line_trim == "<game>")
                {
                    data_is_game = true;
                    listofgames.Add(new List<string>());
                }
            }
            showGames();
        }