commit f64cc548922e927a324f923cfdb37417828913d9 Author: MineRobber9000 Date: Tue Jul 24 05:46:58 2018 -0400 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..894a44c --- /dev/null +++ b/.gitignore @@ -0,0 +1,104 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..6eb9326 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# ccsave +A save editing library for Cookie Clicker. Shuld be compatible with version >= 2.0106. diff --git a/ccsave.py b/ccsave.py new file mode 100644 index 0000000..1162cc2 --- /dev/null +++ b/ccsave.py @@ -0,0 +1,41 @@ +import enum,base64 + +def number(s): + try: + return int(s) + except: + try: + return float(s) + except: + return 0 + +class Settings(enum.Enum): + def __init__(self): + super(Settings, self).__init__(self) + +class Upgrades(enum.Enum): + pass + +class Achievements(enum.Enum): + pass + +class Game: + def __init__(self,save="",savefile=""): + if savefile and not save: + with open(savefile) as f: + save = f.read().strip() + elif not (savefile or save): + raise Exception("Either pass in a save or a save file!") + self.data = base64.b64decode(save).decode("utf-8").split("|") + self.version = self.data.pop(0) + self.reserved = self.data.pop(0) + startdata = self.data.pop(0).split(";") + self.session_start, self.legacy_start, self.save_tstamp = (int(x)/1000 for x in [startdata.pop(0) for y in range(3)]) + self.name = startdata.pop(0) + self.seed = startdata.pop(0) + self.preferences = self.data.pop(0) + self.cookie_data = self.data.pop(0) + self.building_data = self.data.pop(0) + self.upgrades = self.data.pop(0) + self.achievements = self.data.pop(0) + del self.data diff --git a/enum.py b/enum.py new file mode 100644 index 0000000..4ab8790 --- /dev/null +++ b/enum.py @@ -0,0 +1,11 @@ +class Enum: + def __init__(self): + self.v = 0 + self.defines = dict() + + def define(self,k): + if k in self.defines: + raise Exception(k+" is already defined!") + self.defines[k]=self.v + setattr(self,k,self.v) + self.v += 1 diff --git a/test.py b/test.py new file mode 100644 index 0000000..fd8b997 --- /dev/null +++ b/test.py @@ -0,0 +1,7 @@ +import ccsave + +g = ccsave.Game("Mi4wMTA2fHwxNTMyNDEzMTkwNzg4OzE1MzI0MTMxOTA3ODg7MTUzMjQyNDMxODAxNztNYWdpYyBCYWtlcjtjZWtqc3wxMTExMTExMTAwMTExMTExMHw2NTc3NzMuMTU1MzMzMzc0NjsyMDk0ODIwLjE1NTMzMzE3MDQ7NDYwNzsxOzQ0MDYyLjExMTk5OTk5OTY4OzI7MDswOzA7MDswOzA7MDswOzA7MTswOzA7MDswOzA7MDs7MDswOzA7MDswOzA7MDstMTstMTstMTstMTstMTswOzA7MDswOzUwOzA7MDstMTstMTsxNTMyNDEzMTkwNzg3OzA7MDt8MSwxMDQsNDQ2MjUsMDszMCwzMCw0MTQxMzAsMDsyMCwzMCw3MTAxODAsMDsxMCwxNCw3MzIwNzksM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