def requestRank(): sendData = { 'sid': network.serialID, 'type': "requestRank", 'username': user.username } network.clientSend(sendData)
def userSignup(username, password): if len(username) == 0: game_controller.signUpResult("Username is empty!") return if len(password) == 0: game_controller.signUpResult("Password is empty!") return sendData = { 'sid': network.serialID, 'type': "signUp", 'username': username, 'password': password } network.clientSend(sendData)
def recordRecentData(self, recentScore): try: userData = self.file[self.username] userData['recentScore'] = recentScore self.file[self.username] = userData sendData = { 'sid': self.sid, 'type': "recentScore", 'username': self.username, 'score': recentScore # 'time' : int(time.time()-game_controller.startTime) } network.clientSend(sendData) except: game_controller.showContent("Record recent data Error! :(")
def recordFinalData(self): try: sendData = { 'sid': self.sid, 'type': "finalScore", 'username': self.username, 'score': self.file[self.username]['recentScore'], 'time': int(time.time() - game_controller.startTime), 'date': time.strftime('%Y-%m-%d', time.localtime(time.time())) } network.clientSend(sendData) return max(self.file[self.username]['bestScore'], self.file[self.username]['recentScore']) except: game_controller.showContent("Record final data Error! :(")
def requestRank(): sendData = {'sid': network.serialID, 'type': "requestRank"} network.clientSend(sendData)