Ejemplo n.º 1
0
 /// <summary>
 /// Will initialize a new student.
 /// </summary>
 public void Initialize(SaveCode saveCode)
 {
     BakeryName    = saveCode.BakeryName;
     GameVersion   = saveCode.GameVersion;
     GameStartTime = saveCode.StartTime;
     Active        = true;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Updates variables in object. Calls Archive() before running.
        /// </summary>
        /// <param name="_cookieCount"></param>
        /// <param name="_cookieCountAllTime"></param>
        /// <param name="_lastSaveCode"></param>
        /// <param name="_accessTimeStamp"></param>
        public void Update(SaveCode saveCode)
        {
            Archive();

            CookieCount        = saveCode.CookieCount;
            CookieCountAllTime = saveCode.CookieCountAllTime;
            GameSaveTime       = saveCode.SaveTime;
            LastSaveCode       = saveCode.LastSaveCode;
            AccessTimeStamp    = saveCode.AccessTimeStamp;
            AccessCount++;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a Student object in the database.
        /// </summary>
        /// <param name="_name"></param>
        /// <param name="_studentID"></param>
        public void Update(string _name, string _studentID, string _saveCode)
        {
            var name      = _name;
            var studentID = _studentID;

            SaveCode saveCode = SaveCode.Decode(_saveCode);

            IList <Student> databaseItems = (from items in documentSession.Query <Student>()
                                             where items.Name == name
                                             where items.StudentID == studentID
                                             select items).ToList();

            foreach (Student item in databaseItems)
            {
                item.Initialize(saveCode);
                item.Update(saveCode);
            }

            documentSession.SaveChanges();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Will decode a Cookie Clicker save code and return a SaveCode object.
        /// </summary>
        /// <param name="_saveCode"></param>
        /// <returns></returns>
        static public SaveCode Decode(string _saveCode)
        {
            var saveCode    = _saveCode;
            var decodedCode = saveCode.Replace("%2521END%2521", "").Replace("%253D", "=").Replace("%2F", @"/");

            decodedCode = decodedCode.Replace(@"%21END%21", "").Replace("%3D", "=");

            Console.WriteLine(decodedCode);
            var    saveObject = new SaveCode();
            string temp;
            string gameVersion;
            string startTime;
            string saveTime;
            string bakeryName;
            string cookieCount;
            string cookieCountAllTime;

            string[] decodedArray = Encoding.UTF8.GetString(Convert.FromBase64String(decodedCode)).Split(';');

            // Yum.
            // First off we're going to get the Game Version.
            temp        = decodedArray[0];
            gameVersion = temp.Substring(0, temp.IndexOf("|"));
            Console.WriteLine("GAME VERSION: " + gameVersion);

            // Starting time.
            startTime = temp.Substring(temp.IndexOf("|") + 2);
            startTime = FromUnixTime(Convert.ToDouble(startTime));
            Console.WriteLine("START TIME: " + startTime);

            // Save time.
            temp     = decodedArray[2];
            saveTime = FromUnixTime(Convert.ToDouble(temp));
            Console.WriteLine("SAVE TIME: " + saveTime);

            // Bakery name.
            temp       = decodedArray[3];
            bakeryName = temp.Substring(0, temp.IndexOf("|")) + "'s bakery";
            Console.WriteLine("BAKERY NAME: " + bakeryName);

            // Cookie count.
            temp        = decodedArray[3];
            cookieCount = temp.Substring(temp.IndexOf("|") + 1);
            cookieCount = cookieCount.Substring(cookieCount.IndexOf("|") + 1);

            if (!cookieCount.Contains("+"))
            {
                cookieCount = Math.Round(Convert.ToDecimal(cookieCount)).ToString();
            }

            Console.WriteLine("COOKIE COUNT: " + cookieCount);

            // Cookie count of all time.
            temp = decodedArray[4];
            cookieCountAllTime = temp.Substring(temp.IndexOf("|") + 1);

            if (!cookieCountAllTime.Contains("+"))
            {
                cookieCountAllTime = Math.Round(Convert.ToDecimal(cookieCountAllTime)).ToString();
            }

            Console.WriteLine("COOKIE COUNT ALL TIME: " + cookieCountAllTime);

            // Serialize into a SaveCode object.
            saveObject.GameVersion        = gameVersion;
            saveObject.StartTime          = startTime;
            saveObject.BakeryName         = bakeryName;
            saveObject.CookieCount        = cookieCount;
            saveObject.CookieCountAllTime = cookieCountAllTime;
            saveObject.LastSaveCode       = saveCode;
            saveObject.AccessTimeStamp    = DateTime.Now.ToString();
            saveObject.SaveTime           = saveTime;

            return(saveObject);
        }