def start_battle(): challenger = get_current_user() target = User.query.filter_by(username=request.form['target']).one() battle = Battle(challenger=challenger, target=target) start = Event(battle=battle, type=BATTLE_START) firstplayer = Event(battle=battle, type=STARTING_PLAYER, extra_data=json.dumps(dict(player=random.choice([challenger.id, target.id])))) elixir_session.commit() return jsonify(battle=battle.id)
def register(): username = request.form['username'] password = request.form['password'] user = User.query.filter_by(username=username).first() if user: return "Username already registered.", 403 User(username=username, password=password) elixir_session.commit() return "registered successfully."
def start_battle(): challenger = get_current_user() target = User.query.filter_by(username=request.form['target']).one() battle = Battle(challenger=challenger, target=target) start = Event(battle=battle, type=BATTLE_START) firstplayer = Event( battle=battle, type=STARTING_PLAYER, extra_data=json.dumps( dict(player=random.choice([challenger.id, target.id])))) elixir_session.commit() return jsonify(battle=battle.id)