Example #1
0
        public void MakeMap(string filename)
        {
            File = filename;
            MainForm.loadGameEvent();

            int col = GameModel.GetColumnCount();
            int row = GameModel.GetRowCount();

            Map = GameModel.MakeMap();
            View.MakeTable(col, row, Map);
        }
Example #2
0
        public void Save(string filename, GameNS.Game callMeBackforDetails)
        {
            int            rowMax      = callMeBackforDetails.GetRowCount();
            int            colMax      = callMeBackforDetails.GetColumnCount();
            List <MapItem> CurrentGame = callMeBackforDetails.GetMap().Items;
            List <char>    parts       = new List <char>();

            foreach (MapItem item in CurrentGame)
            {
                parts.Add(item.Sign);
            }
            char[] lines  = parts.ToArray();
            string result = "";

            if (!File.Exists(filename))
            {
                using (StreamWriter outputFile = new StreamWriter(filename))
                {
                    string str = "";
                    foreach (char line in lines)
                    {
                        result += line;
                    }
                    int chunkSize    = colMax;
                    int resultLength = result.Length;
                    for (int i = 0; i < resultLength; i += chunkSize)
                    {
                        str += result.Substring(i, chunkSize) + ",";
                    }
                    outputFile.WriteLine(str.TrimEnd(','));
                }
            }
        }
        public void Save(string filename, Game callMeBackforDetails)
        {
            int            rowSize     = callMeBackforDetails.GetRowCount();
            int            colSize     = callMeBackforDetails.GetColumnCount();
            List <MapItem> CurrentGame = callMeBackforDetails.GetMap().Items;
            List <char>    parts       = new List <char>();

            foreach (MapItem item in CurrentGame)
            {
                parts.Add(item.Sign);
            }

            char[] lines  = parts.ToArray();
            string result = "";

            SetSaveLocation(filename);
            using (StreamWriter outputFile = new StreamWriter(SaveLocation, false))
            {
                string str = "";
                foreach (char line in lines)
                {
                    result += line;
                }
                int chunkSize    = colSize;
                int resultLength = result.Length;
                for (int i = 0; i < resultLength; i += chunkSize)
                {
                    str += result.Substring(i, chunkSize) + ",";
                }
                outputFile.WriteLine(str.TrimEnd(','));
                string moveCount   = callMeBackforDetails.GetMoveCount().ToString();
                string moveHistory = callMeBackforDetails.GetMoveHistory();
                outputFile.WriteLine(moveCount);
                outputFile.WriteLine(moveHistory);
            }
        }