예제 #1
0
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)
예제 #2
0
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."
예제 #3
0
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."
예제 #4
0
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)