Example #1
0
 def post(self):
     game = GameFromRequest(self.request).get_game()
     ai = User.get_by_id(AI_ID)
     if not ai:
         logging.info('Failed to retrieve AI user')
     if not game.userO:
         game.userO = User.get_by_id(AI_ID)
         game.put()
         GameUpdater(game).send_update()
Example #2
0
 def make_move(self, board_num, cell, user):
     """Get a move. If it's legal update the game state, save it, and send it to the client."""
     if self.game.move(board_num, cell, user):
         self.game.put() # Save the game state
         self.send_update() # Send it to the client
     if self.game.userO == User.get_by_id(AI_ID): # Check if player O is AI - need to fix the check
         board_num, cell = Ai.nextMove(self.game)
         if self.game.move(board_num, cell, self.game.userO):
             self.game.put()
             self.send_update()