Beispiel #1
0
 def SA(self):
     dirs = utils.Check()
     ann_num = [len(os.listdir('./Multi_Annotator/' + i)) for i in dirs]
     if len(set(ann_num)) != 1:
         tkinter.messagebox.showerror('错误', '标注者文件数目不同')
     # 不确定实体统计
     Annotator_num = len(dirs)
     File_num = list(ann_num)[0]
     result_matrix = np.ones((File_num + 1, Annotator_num + 1))
     for idy in range(Annotator_num):
         files = os.listdir('./Multi_Annotator/' + dirs[idy])
         for idx in range(len(files)):
             tmp1, tmp2 = utils.getNum(path='./Multi_Annotator/' +
                                       dirs[idy] + '/' + files[idx])
             # print('./Multi_Annotator/'+dirs[idy]+'/'+files[idx])
             # print(tmp1,tmp2)
             result_matrix[idx][idy] = tmp1
     # 统计sum
     for idy in range(Annotator_num):
         temp = 0
         for idx in range(File_num):
             temp += result_matrix[idx][idy]
         result_matrix[File_num][idy] = temp
     # 求mean
     for idx in range(File_num):
         temp = 0
         for idy in range(Annotator_num):
             temp += result_matrix[idx][idy]
         result_matrix[idx][Annotator_num] = int(temp / Annotator_num)
     file_list = os.listdir('./Multi_Annotator/' + dirs[0])
     list_matrix = utils.Matrix2List(result_matrix)
     self.ChildWindow(dirs, file_list, list_matrix)
async def pot(ctx, amount):
    allowance = not_allowed(ctx, pot.name, bot)
    if allowance[0]:
        await bot.say(f'acess denied,channel for ={pot.name} is {allowance[1]}'
                      )
        return

    if amount == 't':
        jackpot = game.jackpot(0, ctx)
        jackpot.time_delta()
        await bot.say(f'{round(40-jackpot.delta)} seconds left')
        return

    lev = level.Level(ctx)
    check = utils.Check(ctx)
    embed = check.embed

    balance = check.balance()
    amount = utils.Check.amount(amount, balance)

    if utils.Check.broke(amount, balance):
        await check.display(amount, balance, bot)
        return
    else:
        jackpot = game.jackpot(amount, ctx)
        jackpot.join(amount, ctx.message.channel.id)

        log = statistics.bet_log(ctx)

        log.update_count()

        chances = jackpot.chances()
        if jackpot.time_delta():
            winner = jackpot.get_winner()
            jackpot.update(winner, ctx)
            chance = [i for i in chances if winner[0][0] in i]

            await bot.say('AND THE WINNER IS.....')
            for i in range(0, 5):
                await bot.say('*drum rolls*')
                await asyncio.sleep(1)
            await bot.say(f'@{winner[0][0]} won with {chance[0][0]*100}%')
            lev.get_level()
            lev.evaluate(amount)
        else:
            vals = jackpot.get_stake_and_size()
            embed.add_field(name='POT SIZE', value=f'{vals[0]}/4')
            embed.add_field(name='POT STAKE', value=f'{vals[1]}')

            display = ''
            for i in chances:
                display += f'User: {i[1]} \nChance: {i[0]*100}% \n'
            embed.add_field(name='CHANCES', value=display + '\n')
            await bot.say(embed=embed)
            lev.get_level()
            lev.evaluate(amount)
Beispiel #3
0
 def Modify(self):
     dirs = utils.Check()
     self.win2 = Toplevel(self.parent_frame)
     self.win2.title("Uncertain Modification")
     # utils.setCenteredDisply(win2, 600, 300)
     Label(self.win2, text='Select Annotator:').grid(row=0, sticky=W + E)
     self.v_annotator = StringVar()
     self.ann_combobox = ttk.Combobox(self.win2,
                                      width=9,
                                      textvariable=self.v_annotator)
     # dirs表示标注者集合
     self.ann_combobox['values'] = dirs
     self.ann_combobox.grid(row=0, column=1, sticky=E + W)
     self.ann_combobox.current(0)
     Button(self.win2, text='Query', command=self.Query).grid(row=0,
                                                              column=2,
                                                              sticky=E + W)
async def Game(amount, bot, ctx, func):
    n = utils.Check(ctx)
    balance = n.balance()
    amount = utils.Check.amount(amount, balance)

    if utils.Check.broke(amount, balance):
        await n.display(amount, balance, bot)
        return
    else:
        await func(amount, balance)

    log = statistics.bet_log(ctx)
    log.update_count()

    lev = level.Level(ctx)
    lev.get_level()
    lev.evaluate(amount)
Beispiel #5
0
 def SA(self):
     dirs = apputils.Check()
     ann_num = [len(os.listdir('./Multi_Annotator/' + i)) for i in dirs]
     if len(set(ann_num)) != 1:
         tkinter.messagebox.showerror('错误', '标注者文件数目不同')
     # 不确定实体统计
     Annotator_num = len(dirs)
     File_num = list(ann_num)[0]
     uncertain_matrix = np.ones((File_num + 1, Annotator_num + 1))
     certain_matrix = np.ones((File_num + 1, Annotator_num + 1))
     for idy in range(Annotator_num):
         files = os.listdir('./Multi_Annotator/' + dirs[idy])
         for idx in range(len(files)):
             tmp1, tmp2 = apputils.getNum(path='./Multi_Annotator/' +
                                          dirs[idy] + '/' + files[idx])
             uncertain_matrix[idx][idy] = tmp1
             certain_matrix[idx][idy] = tmp2
     # 统计sum
     for idy in range(Annotator_num):
         temp1 = 0
         temp2 = 0
         for idx in range(File_num):
             temp1 += uncertain_matrix[idx][idy]
             temp2 += certain_matrix[idx][idy]
         uncertain_matrix[File_num][idy] = temp1
         certain_matrix[File_num][idy] = temp2
     # 求mean
     for idx in range(File_num):
         temp1 = 0
         temp2 = 0
         for idy in range(Annotator_num):
             temp1 += uncertain_matrix[idx][idy]
             temp2 += certain_matrix[idx][idy]
         uncertain_matrix[idx][Annotator_num] = int(temp1 / Annotator_num)
         certain_matrix[idx][Annotator_num] = int(temp2 / Annotator_num)
     file_list = os.listdir('./Multi_Annotator/' + dirs[0])
     un_list_matrix = apputils.Matrix2List(uncertain_matrix)
     cer_list_matrix = apputils.Matrix2List(certain_matrix)
     self.ChildWindow(dirs, file_list, un_list_matrix, cer_list_matrix)
async def slot(ctx, amount):
    allowance = not_allowed(ctx, slot.name, bot)
    if allowance[0]:
        await bot.say(
            f'acess denied,channel for ={slot.name} is {allowance[1]}')
        return

    db = utils.db(ctx)
    check = utils.Check(ctx)
    lev = level.Level(ctx)

    balance = check.balance()
    amount = utils.Check.amount(amount, balance)

    if utils.Check.broke(amount, balance):
        await check.display(amount, balance, bot)
        return
    else:
        Slot = game.slot(balance, amount, ctx)
        grid = Slot.generate()
        win = Slot.check_win(grid)
        if not win:
            balance = Slot.new_balance(win)
            check.embed.add_field(
                name=f'{db.userName} YOU LOST now you have {balance} left',
                value=Slot.display(grid))
        else:
            balance = Slot.new_balance(win)
            check.embed.add_field(
                name=f'{db.userName} YOU WON now you got {balance}',
                value=Slot.display(grid))
            lev.get_level()
            lev.evaluate(amount)
    db.updateBalance(balance)
    await bot.say(embed=check.embed)

    log = statistics.bet_log(ctx)
    log.update_count()
async def give(ctx, user: discord.Member, amount):
    allowance = not_allowed(ctx, give.name, bot)
    if allowance[0]:
        await bot.say(
            f'acess denied,channel for ={give.name} is {allowance[1]}')
        return

    if user == None:
        await bot.say('ENTER A USER, like this ->@User#1111')
        return
    elif user.id == ctx.message.author.id:
        await bot.say('You cant donate to yourself')
        return

    n = utils.Check(ctx)
    db = utils.db(ctx=ctx)
    user = utils.db(member=user)
    userQuery = user.query(user=True, server=True)
    donator = db.query(user=True, server=True)

    if len(userQuery) == 0 or len(donator) == 0:
        await bot.say(
            'The giving or receiving user needs to bet at least once!!')
        return

    balance = n.balance()
    amount = utils.Check.amount(amount, balance)

    if n.broke(amount, balance):
        await n.display(amount, balance, bot)
        return
    else:
        balance -= amount
        db.updateBalance(balance)
        don = userQuery[0][4]
        don = float(don) + amount
        user.updateBalance(don)
    await bot.say(f'{user.userName} got a donation of {amount}!!')
async def dice(ctx, range, amount):
    allowance = not_allowed(ctx, dice.name, bot)
    if allowance[0]:
        await bot.say(
            f'acess denied,channel for ={dice.name} is {allowance[1]}')
        return

    db = utils.db(ctx)
    check = utils.Check(ctx)
    lev = level.Level(ctx)
    balance = check.balance()
    amount = utils.Check.amount(amount, balance)

    if '-' not in range:
        await bot.say(f'add a - to your range like this -> 30-80')
        return

    if utils.Check.broke(amount, balance):
        await check.display(amount, balance, bot)
        return
    else:
        Dice = game.dice(range, amount, balance, ctx)
        Dice.update_balance()
        if Dice.win():
            check.embed.add_field(
                name=f'{ctx.message.author} you won it rolled {Dice.choice}!!!',
                value=f'New balance:{Dice.balance}')
        else:
            check.embed.add_field(
                name=
                f'{ctx.message.author} you LOST it rolled {Dice.choice}!!!',
                value=f'New balance:{Dice.balance}')

        log = statistics.bet_log(ctx)

        log.update_count()
        await bot.say(embed=check.embed)
async def gamble(ctx, amount):
    allowance = not_allowed(ctx, gamble.name, bot)
    if allowance[0]:
        await bot.say(
            f'acess denied, channel for ={gamble.name} is {allowance[1]}')
        return

    n = utils.Check(ctx)
    db = utils.db(ctx)
    lev = level.Level(ctx)

    balance = n.balance()
    amount = utils.Check.amount(amount, balance)

    if utils.Check.broke(amount, balance):
        await n.display(amount, balance, bot)
        return
    else:
        rn = random.randint(0, 1)
        if rn == 0:
            balance += amount
            n.embed.add_field(name=f'{n.info.userName} YOU WON!!!',
                              value=f'New balance: {balance}')
        if rn == 1:
            balance -= amount
            n.embed.add_field(name=f"{n.info.userName} YOU LOST",
                              value=f'New balance: {balance}')

        lev.get_level()
        lev.evaluate(amount)

    await bot.say(embed=n.embed)
    db.updateBalance(balance)

    log = statistics.bet_log(ctx)
    log.update_count()
async def roll(ctx, amount, choice):
    allowance = not_allowed(ctx, roll.name, bot)
    if allowance[0]:
        await bot.say(
            f'acess denied,channel for ={roll.name} is {allowance[1]}')
        return

    p = ['r', 'b', 'g']
    if choice != 'r' and choice != 'b' and choice != 'g':
        await bot.say(
            f'INVALID CHOICE,type {p[0]} for red,{p[1]} for black and {p[2]} for green'
        )
        return

    n = utils.Check(ctx)
    db = utils.db(ctx)
    lev = level.Level(ctx)

    balance = n.balance()
    amount = utils.Check.amount(amount, balance)

    emoji = {'r': ':red_circle:', 'b': ':black_circle:', 'g': ':green_apple:'}

    rn = random.randint(0, 16)
    display = ''
    win = ''

    if rn == 16:
        win = 'g'
    elif rn % 2 == 0:
        win = 'r'
    elif rn % 2 != 0:
        win = 'b'

    for i in range(0, 9):
        if rn == 16:
            display += emoji['g']
            rn = 0
        elif rn % 2 == 0:
            display += emoji['r']
            rn += 1
        else:
            display += emoji['b']
            rn += 1
    cursor = ':point_up:'

    if utils.Check.broke(amount, balance):
        await n.display(amount, balance, bot)
        return
    else:
        if win == choice:
            if choice == 'g':
                balance += amount * 14
                n.embed.add_field(
                    name=display + '\n' + cursor + '\n' +
                    f'{db.userName} you won,ON GREEN!!! balance->' +
                    str(balance),
                    value='--------------------')
            else:
                balance += amount
                n.embed.add_field(name=display + '\n' + cursor + '\n' +
                                  f'{db.userName} you won,new balance is ->' +
                                  str(balance),
                                  value='------------------')
        else:
            balance -= amount
            n.embed.add_field(name=display + '\n' + cursor + '\n' +
                              f'{db.userName} you lost,new balance is ->' +
                              str(balance),
                              value='----------------------')
        lev.get_level()
        lev.evaluate(amount)

    db.updateBalance(balance)
    await bot.say(embed=n.embed)

    log = statistics.bet_log(ctx)
    log.update_count()