예제 #1
0
파일: game.cs 프로젝트: joelong01/Catan
        static public OldCatanGame Deserialize(string savedGame)
        {
            OldCatanGame game = new OldCatanGame();

            game.Serializing = true;
            Dictionary <string, string> sections = null;

            try
            {
                sections = StaticHelpers.GetSections(savedGame);
                if (sections == null)
                {
                    game.Error = String.Format($"Error parsing the file into sections.\nThere are no sections.  Please load a valid .catangame file.");
                    return(game);
                }
            }
            catch (Exception e)
            {
                game.Error = e.Message;
                return(game);
            }

            StaticHelpers.DeserializeObject <OldCatanGame>(game, sections["View"], false);
            for (int groupCount = 0; groupCount < game.GroupCount; groupCount++)
            {
                TileGroup tg         = new TileGroup();
                string    tgAsString = sections[$"TileGroup {groupCount}"];
                tg.Deserialize(tgAsString, sections, groupCount);
                game.TileGroups.Add(tg);
            }
            game.Serializing = false;
            return(game);
        }
예제 #2
0
        public bool Deserialize(string s)
        {
            Dictionary <string, string> sections = StaticHelpers.GetSections(s);

            StaticHelpers.DeserializeObject <Settings>(this, sections["Settings"], "=", StaticHelpers.lineSeperator);
            string[] positions = sections["GridPositions"].Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
            GridPositions.Clear();
            foreach (string line in positions)
            {
                GridPosition gp = new GridPosition(line);
                GridPositions.Add(gp);
            }
            return(true);
        }
예제 #3
0
파일: game.cs 프로젝트: joelong01/Catan
        //
        //  this only deserializes the [View] section of the file, and in particular doesn't create any XAML objects..
        public bool FastDeserialize(string savedGame)
        {
            this.Serializing = true;


            try
            {
                this.Sections = StaticHelpers.GetSections(savedGame);
                if (this.Sections == null)
                {
                    this.Error = String.Format($"Error parsing the file into sections.\nThere are no sections.  Please load a valid .catangame file.");
                    return(false);
                }
            }
            catch (Exception e)
            {
                this.Error = e.Message;
                return(false);
            }

            StaticHelpers.DeserializeObject <OldCatanGame>(this, this.Sections["View"], false);
            this.Serializing = false;
            return(true);
        }
예제 #4
0
        public bool Deserialize(string s, Deck deck)
        {
            Dictionary <string, string> sections = StaticHelpers.GetSections(s);

            return(Deserialize(sections, deck));
        }