The server-side Python app is only some 200 lines which includes some shady security stuff, Google's database read/writes, a hand-made JSON writer (Python 2.5 in GAE has no built-in JSON support) and the no-longer working HTML interface. If it gets hacked I'll add HTTPS and challenge-response, but I suspect I'll have to make a good game first to attract some hackers, and it sure ain't gonna be Kill Cutie, since the iOS controls sucks ass.
This is the Python object to JSON writer (run with myjson.dumps(o)):
class myjson: @staticmethod def tostr(o): "Converts input object to string." if type(o) == dict: return '{' + ', '.join([myjson.tostr(k) + ':' + myjson.tostr(v) for k,v in o.items()]) + '}' elif type(o) == list: return '[' + ', '.join([myjson.tostr(e) for e in o]) + ']' elif type(o) == unicode: return repr(o)[1:] # Something along the lines of u'\xe5asdf\xe4\xf6\xe5' elif type(o) == long: return str(int(o)) # Typically 97L or so. elif type(o) == str: if len(o) < 2 or o[0] != '"' or o[-1] != '"': return '"' + o.replace('"', '\\"') + '"' return o else: return str(o); @staticmethod def dumps(o): "Tries to emulate json module in Python 2.5 and newer. Simple enough." return myjson.tostr(o).replace("'", '"')
On the client I do something like:
Cure::HiscoreAgent lHiscore(_T("gamehiscore.pixeldoctrine.com"), 80, _T("GameName")); lHiscore.StartDownloadingList(_T("Platform"), _T("Level"), _T("Avatar"), 0, 10); while (lHiscore.Poll() == Cure::RESOURCE_LOAD_IN_PROGRESS) ; Cure::HiscoreAgent::List lHiscoreList = lHiscore.GetDownloadedList(); lHiscoreList.mOffset; lHiscoreList.mTotalCount; lHiscoreList.mEntryList.size(); lHiscoreList.mEntryList[0].mName; lHiscoreList.mEntryList[0].mScore; lHiscoreList.mEntryList[1].mName; lHiscoreList.mEntryList[1].mScore; // or: lHiscore.StartUploadingScore(_T("Platform"), _T("Level"), _T("Avatar"), _T("me"), 1234); while (lHiscore.Poll() == Cure::RESOURCE_LOAD_IN_PROGRESS) ; int lMyPosition = lHiscore.GetUploadedPlace();