Initial commit

This commit is contained in:
MineRobber9000 2018-07-24 05:46:58 -04:00
commit f64cc54892
5 changed files with 165 additions and 0 deletions

104
.gitignore vendored Normal file
View File

@ -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/

2
README.md Normal file
View File

@ -0,0 +1,2 @@
# ccsave
A save editing library for Cookie Clicker. Shuld be compatible with version >= 2.0106.

41
ccsave.py Normal file
View File

@ -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

11
enum.py Normal file
View File

@ -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

7
test.py Normal file
View File

@ -0,0 +1,7 @@
import ccsave
g = ccsave.Game("Mi4wMTA2fHwxNTMyNDEzMTkwNzg4OzE1MzI0MTMxOTA3ODg7MTUzMjQyNDMxODAxNztNYWdpYyBCYWtlcjtjZWtqc3wxMTExMTExMTAwMTExMTExMHw2NTc3NzMuMTU1MzMzMzc0NjsyMDk0ODIwLjE1NTMzMzE3MDQ7NDYwNzsxOzQ0MDYyLjExMTk5OTk5OTY4OzI7MDswOzA7MDswOzA7MDswOzA7MTswOzA7MDswOzA7MDs7MDswOzA7MDswOzA7MDstMTstMTstMTstMTstMTswOzA7MDswOzUwOzA7MDstMTstMTsxNTMyNDEzMTkwNzg3OzA7MDt8MSwxMDQsNDQ2MjUsMDszMCwzMCw0MTQxMzAsMDsyMCwzMCw3MTAxODAsMDsxMCwxNCw3MzIwNzksMDsyLDQsMTQ5NzMyLDA7MCwwLDAsMDswLDAsMCwwOzAsMCwwLDA7MCwwLDAsMDswLDAsMCwwOzAsMCwwLDA7MCwwLDAsMDswLDAsMCwwOzAsMCwwLDA7MCwwLDAsMDt8MTExMTExMTEwMDAwMDAxMTExMTExMTExMDAxMDAwMDAxMTEwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAxMDAwMTAxMDEwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMD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