示例#1
0
def step_game():
  """ Take one step through the game. """
  if 'player_id' not in session:
    return redirect(url_for('index'))
  game_engine = GameEngine(g.database_service, session['player_id'])
  if game_engine.game_is_over():
    return jsonify(prompt='You beat the game!')
  user_input = request.form['userInput']
  result = game_engine.step(user_input)
  if game_engine.game_is_over():
    return jsonify(prompt=result + '\nCongrats, you fulfilled the objective!')
  return jsonify(prompt=result)