Exemplo n.º 1
0
def new_user_boom(user_id, user_self_boom=0, group_id=''):
    """
    玩家开启数字炸弹,并且将boom设置为玩家定好的数字
    要是存在group_id,则随机设定boom
    同时设定boom_owner和boom_type
    :param user_id:
    :param user_self_boom:用户自定义boom
    :param group_id:
    :return:
    """
    global boom, boom_owner, boom_type
    user_self_boom = can_to_int(user_self_boom)
    if boom_type:
        return get_return('已经有游戏正在进行!')
    to_zero()
    if not 0 < user_self_boom < 100:
        return get_return('给爷爬!游戏范围都不知道了?')
    to_zero()
    boom = user_self_boom
    if group_id:
        boom = random.randint(1, 99)
    score = enough_score(user_id, USER_BOOM_PRICE)
    if not score:
        # 此处预留银行贷款功能,等银行写好后再补充
        return pa
    add_score(user_id, -USER_BOOM_PRICE)
    boom_owner = user_id
    boom_type = 2
    return get_return('创建成功')
Exemplo n.º 2
0
def draw_ten_card(user_id):
    """
    十连抽
    :param user_id:
    :return:
    """
    score = select_score(user_id)
    if score < CARD_PRICE * 9:
        return get_return('爬', code=1)
    add_score(user_id, -9 * CARD_PRICE)
    str1 = f'花费{CARD_PRICE * 9}积分。\n'
    n_NUM = 0
    lv_num = {'UR': 0, "SSR": 0, 'SR': 0, 'R': 0, 'N': 0}
    card_num = {'N': [], 'R': [], 'SR': [], "SSR": [], 'UR': []}
    imgs = {}
    for i in range(10):
        img, str2, lv = get_random_card()
        n_NUM += 1 if lv == 'N' else 0
        if n_NUM == 10:
            while lv == 'N':
                img, str2, lv = get_random_card()
                str1 += '触发保底:\n'
        lv_num[lv] += 1
        if imgs.get(img):
            imgs[img] += 1
        else:
            imgs[img] = 1
        card_num[lv].append(img)
        if str2:
            str1 += str2 + '\n'
    archive_cards(user_id, imgs, lv_num)
    return get_return(str1)
Exemplo n.º 3
0
def increase_score(user_id, score):
    """
    直接插入积分, 管理员专用
    :param user_id:
    :param score:
    :return:
    """
    add_score(user_id, score)
    return get_return('增加成功')
Exemplo n.º 4
0
def draw_card(user_id):
    """
    抽卡
    :param user_id:
    :return:
    """
    score = select_score(user_id)
    if score < CARD_PRICE:
        return get_return('爬', code=1)
    add_score(user_id, -CARD_PRICE)
    img, str1, lv = get_random_card()
    str1 = f'花费{CARD_PRICE}积分,获得{lv}卡:{img}。'
    archive_card(user_id, img, lv, 1)
    return get_return(str1, need={'card': img})
Exemplo n.º 5
0
def sell_card(user_id, card_name, nums=1):
    """
    售卖卡牌
    :param user_id:
    :param card_name: 卡牌名
    :param nums: 售卖的数量
    :return:
    """
    res = select_card(user_id, card_name)[0]
    if res < nums:
        return pa
    sell_score = RE_PRICE[level[card_name]] * nums
    add_score(user_id, sell_score)
    update_card({'user_id': user_id}, {card_name: res - nums})
Exemplo n.º 6
0
def boom_play(user_id, boom_num):
    """
    判断boom_num与boom的大小,并提示接下来的游戏范围,当一个人猜对时,置零所有参数
    time_start:开始游戏时的时间戳
    :param user_id:
    :param boom_num:
    :return:
    """
    global boom, left, right, boom_type, boom_consume
    boom_num = can_to_int(boom_num)
    res = is_not_continue(user_id)
    if res:
        return res
    boom_consume += BOOM_PRICE
    add_score(user_id, -BOOM_PRICE)
    if not left < boom_num < right:
        player.append({"user_id": user_id, "time": time.time()})
        return get_return(f'猜错了,接下请从[{left}-{right}]选择')
    if boom_num < boom:
        left = boom_num
        str1 = get_return(f'猜错了,接下请从[{left}-{right}]选择')
    elif boom_num > boom:
        right = boom_num
        str1 = get_return(f'猜错了,接下请从[{left}-{right}]选择')
    else:
        reward_score = get_reward_score(left, right)
        add_score(user_id, reward_score)
        if boom_type == 2:
            owner_score = USER_BOOM_PRICE + boom_consume - reward_score - USER_BOOM_TAX
            str1 = get_return(
                public_msg=f'恭喜你答对了, 获得积分{BOOM_SCORE}',
                private_msg=f'您做庄的数游戏已结束,扣除4积分启动分,玩家获胜分{reward_score}\n'
                f'玩家总参与积分{boom_consume}\n返还给您{owner_score}积分。',
                private_id=boom_owner)
            add_score(boom_owner, owner_score)
        else:
            str1 = get_return(public_msg=f'恭喜你答对了, 获得积分{BOOM_SCORE}')
        to_zero()
    player.append({"user_id": user_id, "time": time.time()})
    return str1