Beispiel #1
0
def respin():
    verifiers = get_verifiers()
    yesterday = datetime.datetime.now() - datetime.timedelta(days=1)
    for verifier in verifiers:
        progression = verifier.progression
        progression.last_spin = yesterday
    db.session.commit()
Beispiel #2
0
def reset_weekly_challenge():
    verifiers = get_verifiers()
    best_verifier = sorted(verifiers,
                           key=lambda v: -v.progression.weekly_verifies)[0]

    # check for price and award
    coin_price, experience_price = 0, 0
    weekly_verifies = sum([v.progression.weekly_verifies for v in verifiers])
    weekly_params = app.config['ECONOMY']['weekly_Challenge']
    weekly_goal = weekly_params['goal']
    if weekly_verifies > weekly_goal:
        coin_price = weekly_params['coin_reward']
        experience_price = weekly_params['experience_reward']
        extra = int(
            (weekly_verifies - weekly_goal) / weekly_params['extra_interval'])
        coin_price += extra * weekly_params['extra_coin_reward']
        experience_price += extra * weekly_params['extra_experience_reward']

    # give prices and reset counters
    for verifier in verifiers:
        v_coin_price, v_experience_price = coin_price, experience_price
        if verifier.id == best_verifier.id:
            v_coin_price += weekly_params['best_coin_reward']
            v_experience_price += weekly_params['best_experience_reward']

        progression = verifier.progression
        progression.weekly_verifies = 0
        progression.lobe_coins += v_coin_price
        progression.experience += v_experience_price
        progression.weekly_coin_price = v_coin_price
        progression.weekly_experience_price = v_experience_price
        progression.has_seen_weekly_prices = False

    db.session.commit()
Beispiel #3
0
def give_all_coins():
    verifiers = get_verifiers()
    coins = int(input('amount: '))
    for verifier in verifiers:
        progression = verifier.progression
        progression.lobe_coins += coins
        db.session.commit()
Beispiel #4
0
def initialize_verifiers():
    add_progression_to_verifiers()
    verifiers = get_verifiers()
    for verifier in verifiers:
        progression = verifier.progression
        if progression.verification_level is None:
            progression.verification_level = 0
        if progression.spy_level is None:
            progression.spy_level = 0
        if progression.streak_level is None:
            progression.streak_level = 0
        if progression.num_verifies is None:
            progression.num_verifies = 0
        if progression.num_session_verifies is None:
            progression.num_session_verifies = 0
        if progression.num_invalid is None:
            progression.num_invalid = 0
        if progression.num_streak_days is None:
            progression.num_streak_days = 0
        if progression.lobe_coins is None:
            progression.lobe_coins = 0
        if progression.experience is None:
            progression.experience = 0
        if progression.weekly_verifies is None:
            progression.weekly_verifies = 0
        if progression.last_spin is None:
            progression.last_spin = db.func.current_timestamp()
        if progression.fire_sale is None:
            progression.fire_sale = False
        if progression.fire_sale_discount is None:
            progression.fire_sale_discount = 0.0
    db.session.commit()
Beispiel #5
0
def add_progression_to_verifiers():
    verifiers = get_verifiers()
    admins = get_admins()
    for verifier in verifiers + admins:
        if verifier.progression_id is None:
            progression = VerifierProgression()
            db.session.add(progression)
            db.session.flush()
            verifier.progression_id = progression.id
        db.session.commit()
Beispiel #6
0
def give_experience():
    verifiers = get_verifiers()
    print("Select a verifier id from the ones below:")
    for verifier in verifiers:
        print(f'{verifier.name} - [{verifier.id}]')
    user_id = int(input('user id: '))
    experience = int(input('amount: '))
    user = User.query.get(user_id)
    progression = user.progression
    progression.experience += experience
    db.session.commit()
Beispiel #7
0
def give_coins():
    verifiers = get_verifiers()
    print("Select a verifier id from the ones below:")
    for verifier in verifiers:
        print(f'{verifier.name} - [{verifier.id}]')
    user_id = int(input('user id: '))
    coins = int(input('amount: '))
    user = User.query.get(user_id)
    progression = user.progression
    progression.lobe_coins += coins
    db.session.commit()
Beispiel #8
0
def set_firesale():
    do_fire_sale = bool(int(input('Do 1 for firesale, 0 to deactivate: ')))
    if do_fire_sale:
        fire_sale_discount = \
            float(input('Select discount, e.g. 0.3 for 30 percent off: '))
    else:
        fire_sale_discount = 0.0

    verifiers = get_verifiers()
    for verifier in verifiers:
        progression = verifier.progression
        progression.fire_sale = do_fire_sale
        progression.fire_sale_discount = fire_sale_discount

    db.session.commit()
Beispiel #9
0
def delta_balance():
    verifiers = get_verifiers()
    print("Select a verifier id from the ones below:")
    for verifier in verifiers:
        print(f'{verifier.name} - [{verifier.id}]')
    user_id = int(input('user id: '))
    user = User.query.get(user_id)

    coins = int(input('coin amount: '))
    experience = int(input('exp amount: '))
    progression = user.progression
    progression.lobe_coins += coins
    progression.experience += experience

    db.session.commit()
Beispiel #10
0
def verify_index():
    '''
    Home screen of the verifiers
    '''
    verifiers = sorted(get_verifiers(),
                       key=lambda v: -v.progression.weekly_verifies)
    weekly_verifies = sum([v.progression.weekly_verifies for v in verifiers])
    if weekly_verifies < app.config['ECONOMY']['weekly_challenge']['goal']:
        weekly_progress = 100 *\
            ((weekly_verifies-current_user.progression.weekly_verifies) /
                app.config['ECONOMY']['weekly_challenge']['goal'])
    else:
        weekly_progress = 100 * (
            (weekly_verifies -
             app.config['ECONOMY']['weekly_challenge']['goal']) %
            app.config['ECONOMY']['weekly_challenge']['extra_interval'] /
            app.config['ECONOMY']['weekly_challenge']['extra_interval'])
    user_weekly_progress = 100 * (
        current_user.progression.weekly_verifies /
        app.config['ECONOMY']['weekly_challenge']['goal'])

    verification_progress = 0
    if current_user.progression.verification_level < \
            len(app.config['ECONOMY']['achievements']['verification'].keys()):
        verification_progress = 100 * (
            current_user.progression.num_verifies /
            app.config['ECONOMY']['achievements']['verification'][str(
                current_user.progression.verification_level)]['goal'])

    spy_progress = 0
    if current_user.progression.spy_level < \
            len(app.config['ECONOMY']['achievements']['spy'].keys()):
        spy_progress = 100 * (current_user.progression.num_invalid /
                              app.config['ECONOMY']['achievements']['spy'][str(
                                  current_user.progression.spy_level)]['goal'])

    streak_progress = 0

    show_weekly_prices, show_daily_spin = False, False
    daily_spin_form = DailySpinForm()
    if not current_user.progression.has_seen_weekly_prices:
        progression = current_user.progression
        progression.has_seen_weekly_prices = True
        db.session.commit()
        show_weekly_prices = True
    elif not current_user.progression.last_spin or current_user.progression.last_spin < datetime.combine(
            date.today(), datetime.min.time()):
        # we dont want to show weekly prizes and spins at the same time
        # last spin was not today
        show_daily_spin = True

    activity_days, activity_counts = activity(Verification)
    #show_weekly_prices, show_daily_spin = False, False #disable prizes when not in use

    # get the number of verifications per user
    return render_template('verify_index.jinja',
                           verifiers=verifiers,
                           weekly_verifies=weekly_verifies,
                           weekly_progress=weekly_progress,
                           user_weekly_progress=user_weekly_progress,
                           verification_progress=verification_progress,
                           spy_progress=spy_progress,
                           streak_progress=streak_progress,
                           daily_spin_form=daily_spin_form,
                           progression_view=True,
                           show_weekly_prices=show_weekly_prices,
                           show_daily_spin=show_daily_spin,
                           activity_days=activity_days,
                           activity_counts=activity_counts)