Exemplo n.º 1
0
 def Get(self):
     BaseGameAJAX.Get(self)
     movesFrom = int(self.request.get('moves_from'))
     game_key = self.request.get('game_key')
     game = Game.get(game_key)
     userPlayerNumber = self.getUserPlayerNumber(game)
     game_data_changed = False
     
     
     if self.isNextMoveOwnerAI(game):
         userPlayerNumber = self.getUserPlayerNumber(game)
         
         if self.getNextNonAIPlayer(game) == userPlayerNumber :
             
             while self.gameInServerState(game):
                 self.completeServerState(game)
                 game_data_changed = True
             
             while  self.isNextMoveOwnerAI(game):
                 self.completeAIMove(game)
                 game_data_changed = True
             
     if game_data_changed:
         game.put()
             
     self._returnResponse(game,movesFrom) 
Exemplo n.º 2
0
 def Put(self):
     move_num = int(self.request.get('move_num'))
     game_key = self.request.get('game_key')
     move_type = self.request.get('move_type')
     move_str = self.request.get('move_str')
     game = Game.get(game_key)
     movesSaved = game.moveData
     if(len(movesSaved) == move_num) :
         if move_type == "server": 
             if move_str == game.gameState and self.gameInServerState(game):
                 while self.gameInServerState(game):
                     self.completeServerState(game)
                 game.put()
         elif self.validateMove(game, move_num, move_type, move_str):
             self.userMove(game, move_type, move_str)
             game.put()
     
     self._returnResponse(game,move_num)
Exemplo n.º 3
0
 def get(self):
     template_values = self.getBaseTemplateVals()
     game_key = self.request.path.strip('/').split('/')[-1]
     game_data = Game.get(game_key)
     template_values['game_data'] = json.encode(game_data.to_game_dict())
     self.renderTemplate('game.html', template_values)