コード例 #1
0
 public void Reset()
 {
     GameModel.Restart();
     Map = GameModel.GetMap().Items;
     View.UpdateMap(Map);
     GameModel.GetMap().Updates = new List <MapItem>();
     View.GetGameStats(GameModel.GetMoveCount(), GameModel.GetMoveHistory());
 }
コード例 #2
0
        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);
            }
        }