Exemple #1
0
def riddle_g_setting(user_name):
    if request.method == "POST":
        ## Redirect if game profile already exist
        profiles_data = helper.read_txt("data/profiles/all-profiles.txt")
        return redirect(f"/{user_name}/riddle-game")
    else:
        profiles_data = helper.read_txt("data/profiles/all-profiles.txt")
        return render_template("riddle-g-setting.html",
                               user_name=user_name,
                               page_title="Riddle Game Setting",
                               profiles=profiles_data)
Exemple #2
0
def get(user_name):
    profiles = helper.read_txt("data/profiles/all-profiles.txt")
    profile = user_name + "\n"
    if profile in profiles:
        return jsonify(helper.read_json(f"data/profiles/{user_name}/{user_name}.json"))
    else:
        return jsonify("no profile")
Exemple #3
0
def riddle_setting(user_name):
    ## If game profile already exist redirect user to the game
    riddle_profiles = helper.read_txt("data/riddle-game/all-players.txt")
    profile = user_name + "\n"
    print(profile, user_name)
    if profile in riddle_profiles:
        return redirect(f"/user/{user_name}/riddle-game")
    else:
        return riddle.riddle_g_setting(user_name)
Exemple #4
0
def parse_setting(user_name):
    data = request.get_json(force=True)
    profiles = helper.read_txt(
        f"data/profiles/{user_name}/riddle_game/riddle_profiles.txt")
    profile = data["riddle_game_data"]["riddle_profile_name"] + "\n"
    if profile in profiles:
        return jsonify(profile)
    # Create new game
    riddle.create_riddle_game(data)
    return jsonify(data)
Exemple #5
0
def profile_page(user_name):
    ## Get profile data
    profiles_data = helper.read_txt("data/profiles/all-profiles.txt")
    ## Check if there is more then one profile
    if len(profiles_data) > 0:
        return render_template("profile.html",
                               user_name=user_name,
                               page_title=f"{user_name}" + " profile",
                               profiles=profiles_data)
    ## Render default template
    return render_template("profile.html",
                           user_name=user_name,
                           page_title=f"{user_name}" + " profile")
Exemple #6
0
def get_results(user_name, riddle_profile):
    riddle_profiles = helper.read_txt(
        f"data/profiles/{user_name}/riddle_game/riddle_profiles.txt")
    profile = helper.read_json(helper.profile(user_name, riddle_profile))
    profile = profile["game"][0]
    if profile["mods"] == "limited":
        return render_template("riddle-game.html",
                               user_name=user_name,
                               riddle_profiles=riddle_profiles,
                               riddle_profile=riddle_profile,
                               tries=int(profile["tries"]),
                               page_title="Riddle Game")
    # Render riddle-game template by default
    return render_template("riddle-game.html",
                           user_name=user_name,
                           riddle_profiles=riddle_profiles,
                           riddle_profile=riddle_profile,
                           tries=int(0),
                           page_title="Riddle Game")
Exemple #7
0
    stock_movement = stock_movement.dropna(axis=0, how='any')
    print "shape of stock_movement after dropna: ", stock_movement.shape[0]

    stock_returns = stock_returns[stock_returns.index <= stock_movement.index[
        stock_movement.index.__len__() - 1]]
    stock_returns = stock_returns.tail(stock_movement.shape[0])
    stock_lag = stock_lag[stock_lag.index <= stock_movement.index[
        stock_movement.index.__len__() - 1]]
    stock_lag = stock_lag.tail(stock_movement.shape[0])

    return stock_data, stock_returns, stock_lag, stock_movement


if __name__ == "__main__":
    # Reads user parameters from text file
    stocks, period = read_txt('parameters.txt')

    # List of stocks to input
    ticker_arr = stocks

    # Number of days' price data used for training
    lag = 20
    # Forward prediction period
    pred_period = period

    # Start and end dates of stock data set queried
    # start_date = "Jun 1 2000"
    # end_date = get_curr_date()
    #print get_curr_date()
    start = datetime.datetime(2017, 6, 1)
    end = datetime.datetime(2018, 4, 1)
Exemple #8
0
def riddle_setting(user_name):
    riddle_profiles = helper.read_txt(
        f"data/profiles/{user_name}/riddle_game/riddle_profiles.txt")
    return render_template("riddle-g-setting.html",
                           user_name=user_name, riddle_profiles=riddle_profiles, page_title="Riddle Game Setting")
Exemple #9
0
def profile_page(user_name):
    riddle_profiles = helper.read_txt(
        f'data/profiles/{user_name}/riddle_game/riddle_profiles.txt')
    # Render default template
    return render_template("profile.html",
                           user_name=user_name, riddle_profiles=riddle_profiles, page_title=f"{user_name}" + " profile")
Exemple #10
0
def show_statistics(user_name):
	riddle_profiles = helper.read_txt(f"data/profiles/{user_name}/riddle_game/riddle_profiles.txt")
	return render_template("statistics.html",
                           user_name=user_name,
                           riddle_profiles=riddle_profiles,
                           page_title="Statistics")