def delete(self, _id):
   try:
     game = Game.find_by_id(_id)
     if game:
       game.delete()
       return msg('Game {} deleted'.format(_id)), 200
     else:
       return msg('Game {} was already gone'.format(_id)), 400
   except:
     return msg('Error deleting game'), 500
 def post(self, _id):
     try:
         data = JoinGame.parser.parse_args()
         game = Game.find_by_id(_id)
         player = Player.find_by_id(data['player_id'])
         player_in_game = PlayerInstance.player_in_game(
             player_id=data['player_id'], game_id=_id)
         print('player in game yes or no come on', player_in_game)
         if player_in_game:
             return msg('Player {} has already joined game {}'.format(
                 data['player_id'], _id)), 200
         player_instance = PlayerInstance(player_id=data['player_id'],
                                          game_id=_id)
         player_instance.game = game
         player_instance.player = player
         player_instance.save_to_db()
         return msg('Player {} joined game {}'.format(
             data['player_id'], _id)), 201
     except:
         return msg('Player game join error'), 500
 def put(self, _id):
     game = Game.find_by_id(id=_id)
     game.date_started = datetime.utcnow()
     game.save_to_db()
 def get(self, _id):
   try:
     game = Game.find_by_id(_id)
     return { 'game': game.json('game_players') }
   except :
     return msg('There was an error fetching the game'), 500