コード例 #1
0
ファイル: app.py プロジェクト: Zireael07/Flask-roguelike
def target_confirm(x=None, y=None):
    if not game.is_player_alive(game_vars.world):
        print("Abort early, player dead")
        # This is a crash in Flask code, but it doesn't matter as we're dead either way
        return

    cursor = None
    for ent, (player, cur) in game_vars.world.get_components(Player, CursorComponent):
        cursor = cur
    
    # if no cursor, we clicked it by mistake = ignore
    if cursor is not None:
        # get x,y from cursor
        x = cursor.x
        y = cursor.y
        print("Confirmed target: " + str(x) + " " + str(y))

        if cursor.item is not None:
            action = {'target': (int(x), int(y))}

        game.act_and_update(game_vars.world, action)
        data = data_to_redraw()

    return jsonify({'inven': render_template('inventory.html', inventory=data['inventory']),
    'data' : render_template('response.html', position=data['position'], console=data['console'], style=renderer_logic.map_style, messages=data['messages'], stats=data['fighter'])
    })
コード例 #2
0
ファイル: app.py プロジェクト: Zireael07/Flask-roguelike
def move(x=None, y=None):
    if not game.is_player_alive(game_vars.world):
        print("Abort early, player dead")
        # This is a crash in Flask code, but it doesn't matter as we're dead either way
        return
    print("Move: " + str(x) + " " + str(y)) 

    action = {'move': (int(x), int(y))}

    game.act_and_update(game_vars.world, action)
    data = data_to_redraw()

    return jsonify({'data': render_template('response.html', 
    position=data['position'], console=data['console'], style=renderer_logic.map_style, messages=data['messages'], stats=data['fighter'], look=data['look_list'], equipped=data['equipped'])})
コード例 #3
0
ファイル: app.py プロジェクト: Zireael07/Flask-roguelike
def look():
    if not game.is_player_alive(game_vars.world):
        print("Abort early, player dead")
        # This is a crash in Flask code, but it doesn't matter as we're dead either way
        return
    print("Look action!")

    action = {'look': True}

    game.act_and_update(game_vars.world, action)
    data = data_to_redraw()

    return jsonify({'inven': render_template('inventory.html', inventory=data['inventory']),
    'data' : render_template('response.html', position=data['position'], console=data['console'], style=renderer_logic.map_style, messages=data['messages'], stats=data['fighter'], look=data['look_list'])
    })
コード例 #4
0
ファイル: app.py プロジェクト: Zireael07/Flask-roguelike
def drop_item(id=None):
    if not game.is_player_alive(game_vars.world):
        print("Abort early, player dead")
        # This is a crash in Flask code, but it doesn't matter as we're dead either way
        return
    print("Drop action! - " + str(id))

    action = {'drop_item': int(id)}

    game.act_and_update(game_vars.world, action)
    data = data_to_redraw()

    return jsonify({'inven': render_template('inventory.html', inventory=data['inventory']),
    'data' : render_template('response.html', position=data['position'], console=data['console'], style=renderer_logic.map_style, messages=data['messages'], stats=data['fighter'], equipped=data['equipped'])
    })