Exemplo n.º 1
0
 def finishGame(self, msg: Message):
     self.checkState(self.STATE_GAMING)
     self.state = self.STATE_GAME_END
     decoded = msg.getDecoded()
     self.gameResult = Base.GameResult()
     self.gameResult.enemyNum = decoded[self.KEY_GAME_END_ENEMY_NUM]
     self.gameResult.escapeTimes = decoded[self.KEY_GAME_END_ESCAPE_TIMES]
     self.gameResult.playerOLives = decoded[self.KEY_GAME_END_PLAYER_OLIVES]
     self.gameResult.result = decoded[self.KEY_GAME_END_RESULT]
     self.gameResult.bestPlayer = tuple(
         decoded[self.KEY_GAME_END_BEST_PLAYER])
     self.gameResult.endProcess = decoded[self.KEY_GAME_START_END_PROCESS]
     self.gameResult.reachedProcess = decoded[
         self.KEY_GAME_END_REACHED_PROCESS]
     self.gameResult.keepTime = decoded[self.KEY_GAME_END_KEEP_TIME]
     self.gameResult.playerList = decoded[self.KEY_GAME_END_PLAYER_LIST]
     self.gameResult.fps = decoded[self.KEY_GAME_END_FPS]
     self.gameResult.screenSize = tuple(
         decoded[self.KEY_GAME_END_SCREEN_SIZE])
Exemplo n.º 2
0
 def summonResult(self):
     result = Base.GameResult()
     if self.state == self.STATE_WIN:
         result.result = Const.WIN
     elif self.state == self.STATE_LOST:
         result.result = Const.LOST
     else:
         result = None
         return result
     result.bestPlayer = self.getBestPlayer()
     result.endProcess = self.endProcess
     result.enemyNum = self.originEnemyNum
     result.escapeTimes = sum([self.enemies[i].movetimes for i in range(self.enemyHandler.length)])
     result.fps = Con.FPS
     result.playerList = self.originPlayerList
     result.playerOLives = Con.Lives
     result.reachedProcess = self.process
     result.screenSize = Con.ScreenSize
     result.keepTime = Base.getTimeMil()
     return result