def game_end(): user_id = session.get('user_id', None) game_id = session.get('game_id', None) word_info = db_get_completed_game_sentences(game_id) game_info_ = db_get_game_info(user_id, game_id) return render_template('game/end.html', word_info=word_info, game_name=game_info_['game_name'], game_code=game_info_['game_code'])
def game_start(): game_id = session.get('game_id', None) user_id = session.get('user_id', None) game_info_ = db_get_game_info(user_id, game_id) is_creator = game_info_['is_creator'] game_code = game_info_['game_code'] if request.method == 'GET': return render_template('game/start.html', is_creator=is_creator, game_code=game_code) else: if is_creator: db_start_game(game_id) return jsonify({'status': 'success'}) return jsonify({'status': 'failure'})
def game_add_word(): game_id = session.get('game_id', None) user_id = session.get('user_id', None) new_word = request.form.get('next_word', None) if new_word is not None: new_word = new_word.strip() else: return jsonify({'status': 'failure'}) if not is_valid_word(new_word): return jsonify({'status': 'failure'}) game_info_ = db_get_game_info(user_id, game_id) if (game_info_['is_current_user'] and not game_info_['game_finished'] and game_info_['game_started']): db_add_game_word(new_word, game_id, user_id) return jsonify({'status': 'success'}) return jsonify({'status': 'failure'})
def game_info(): game_id = session.get('game_id', None) user_id = session.get('user_id', None) game_info_ = db_get_game_info(user_id, game_id) return jsonify(game_info_)
def game_on(): user_id = session.get('user_id', None) game_id = session.get('game_id', None) game_info_ = db_get_game_info(user_id, game_id) return render_template('game/on.html', game_name=game_info_['game_name'])