示例#1
0
def count_group_train_hero(hero_id, user, group_level):
    """计算训练所姬甲当前经验
    """
    hero = user.hero.heros[hero_id]
    tmp_exp = hero["exp"]
    max_exp = game_config.hero_level_exp_cfg.get(hero["level"]+1, None)
    if not max_exp:
        return tmp_exp

    # 经验已经最大,更新时间改为当前
    if hero["level"] >= user.game_info.role_level and tmp_exp >= max_exp:
        return tmp_exp
    else:
        now = int(time.time())
        gcfg = game_config.group_cfg.get(group_level, {})
        if not gcfg:
            return tmp_exp

        interval_minutes = int(now - user.group.train_dict[hero_id]) / 60
        # 读取别人帮我加速的次数
        express_times = GroupService.get_train_hero_times(user.sid, user.group.group_id, user.uid, hero_id)
        add_exp = (interval_minutes + int(express_times) * 30) * gcfg["train_exp"]

        if tmp_exp + add_exp > max_exp:
            tmp_exp = max_exp
        else:
            tmp_exp += add_exp

        return tmp_exp
示例#2
0
def count_group_train_hero(hero_id, user, group_level):
    """计算训练所姬甲当前经验
    """
    hero = user.hero.heros[hero_id]
    tmp_exp = hero["exp"]
    max_exp = game_config.hero_level_exp_cfg.get(hero["level"] + 1, None)
    if not max_exp:
        return tmp_exp

    # 经验已经最大,更新时间改为当前
    if hero["level"] >= user.game_info.role_level and tmp_exp >= max_exp:
        return tmp_exp
    else:
        now = int(time.time())
        gcfg = game_config.group_cfg.get(group_level, {})
        if not gcfg:
            return tmp_exp

        interval_minutes = int(now - user.group.train_dict[hero_id]) / 60
        # 读取别人帮我加速的次数
        express_times = GroupService.get_train_hero_times(
            user.sid, user.group.group_id, user.uid, hero_id)
        add_exp = (interval_minutes +
                   int(express_times) * 30) * gcfg["train_exp"]

        if tmp_exp + add_exp > max_exp:
            tmp_exp = max_exp
        else:
            tmp_exp += add_exp

        return tmp_exp
示例#3
0
def handle_group_train_heros(train_heros, user, exp_every_minutes):
    """每个心跳中结算公会训练所的姬甲数据
    """
    now = int(time.time())
    train_hero_exps = {}
    for hero_id in train_heros:
        hero = user.hero.heros[hero_id]
        tmp_exp = hero["exp"]
        max_exp = game_config.hero_level_exp_cfg.get(hero["level"] + 1, None)
        if not max_exp:
            continue

        # 经验已经最大,更新时间改为当前
        if hero["level"] >= user.game_info.role_level and tmp_exp >= max_exp:
            user.group.train_dict[hero_id] = now
        else:
            interval_minutes = int(now - user.group.train_dict[hero_id]) / 60
            # 读取别人帮我加速的次数
            express_times = GroupService.get_train_hero_times(
                user.sid, user.group.group_id, user.uid, hero_id)
            add_exp = (interval_minutes +
                       int(express_times) * 30) * exp_every_minutes
            user.group.train_dict[hero_id] += interval_minutes * 60  # 更新时间

            if tmp_exp + add_exp > max_exp:
                tmp_exp = max_exp
                user.group.train_dict[hero_id] = now
            else:
                tmp_exp += add_exp

            after_level = common_helper.get_level_by_exp(
                game_config.hero_exp_level_cfg, tmp_exp)
            user.hero.update_exp_level(
                hero_id, tmp_exp, min(user.game_info.role_level, after_level),
                False)

        train_hero_exps[hero_id] = add_exp

    user.hero.put()
    user.group.put()

    return train_hero_exps
示例#4
0
def handle_group_train_heros(train_heros, user, exp_every_minutes):
    """每个心跳中结算公会训练所的姬甲数据
    """
    now = int(time.time())
    train_hero_exps = {}
    for hero_id in train_heros:
        hero = user.hero.heros[hero_id]
        tmp_exp = hero["exp"]
        max_exp = game_config.hero_level_exp_cfg.get(hero["level"]+1, None)
        if not max_exp:
            continue

        # 经验已经最大,更新时间改为当前
        if hero["level"] >= user.game_info.role_level and tmp_exp >= max_exp:
            user.group.train_dict[hero_id] = now
        else:
            interval_minutes = int(now - user.group.train_dict[hero_id]) / 60
            # 读取别人帮我加速的次数
            express_times = GroupService.get_train_hero_times(user.sid, user.group.group_id, user.uid, hero_id)
            add_exp = (interval_minutes + int(express_times) * 30) * exp_every_minutes
            user.group.train_dict[hero_id] += interval_minutes * 60     # 更新时间

            if tmp_exp + add_exp > max_exp:
                tmp_exp = max_exp
                user.group.train_dict[hero_id] = now
            else:
                tmp_exp += add_exp

            after_level = common_helper.get_level_by_exp(game_config.hero_exp_level_cfg, tmp_exp)
            user.hero.update_exp_level(hero_id, tmp_exp, min(user.game_info.role_level, after_level), False)

        train_hero_exps[hero_id] = add_exp

    user.hero.put()
    user.group.put()

    return train_hero_exps