Пример #1
0
    def detailed_mode(self, times, ten_times=False):
        operators = self.start_gacha(times)

        result = '阿米娅给博士扔来了%d张简历,博士细细地检阅着...\n\n【%s】\n\n' % (times,
                                                             self.pick_up_name)

        operators_data = database.operator.get_all_operator(
            [item['name'] for item in operators])
        operator_avatars = {
            item['operator_name']: item['operator_avatar']
            for item in operators_data
        }

        icons = []
        for index, item in enumerate(operators):
            star = '☆' if item['rarity'] < 5 else '★'
            result += '%s%s%s\n\n' % (' ' * 15,
                                      insert_empty(item['name'], 6, True),
                                      star * item['rarity'])

            if item['name'] in operator_avatars:
                avatar_path = '%s/%s.png' % (avatar_resource,
                                             operator_avatars[item['name']])
                if os.path.exists(avatar_path):
                    icons.append({
                        'path': avatar_path,
                        'size': (34, 34),
                        'pos': (10, 60 + 34 * index)
                    })

        result += '\n%s' % self.check_break_even()

        reply = [TextImage(result, icons)]
        if ten_times:
            operators_info = {
                item['operator_name']: {
                    'photo': item['operator_avatar'],
                    'rarity': item['operator_rarity'],
                    'class': class_index[item['operator_class']].lower()
                }
                for item in operators_data
            }
            result_list = []

            for item in operators:
                name = item['name']
                op_dt = None

                if name in operators_info:
                    op_dt = operators_info[name]
                elif name in self.temp_operator:
                    op_dt = self.temp_operator[name]

                result_list.append(op_dt)

            res_img = '%s/%s' % (gacha_result,
                                 create_gacha_result(result_list))
            reply.insert(0, Image(res_img))

        return reply
Пример #2
0
    def detailed_mode(self, times):
        operators = self.start_gacha(times)

        result = '阿米娅给博士扔来了%d张【%s】简历,博士细细地检阅着...\n\n' % (times,
                                                         self.pick_up_name)

        no_high_rarity = True
        six_rarity = 0

        text = ''
        hit = False

        for item in operators:
            star = '☆' if item['rarity'] < 5 else '★'
            result += '%s%s\n' % (insert_empty(item['name'], 5,
                                               True), star * item['rarity'])

            if item['rarity'] >= 5:
                no_high_rarity = False

            if item['rarity'] == 6:
                six_rarity += 1
                if 6 in self.pick_up:
                    if item['name'] in self.pick_up[6]:
                        text = '\n抽到UP的六星干员了,今天也是欧气满满的呀!'
                        hit = True
                    else:
                        if hit is False:
                            text = '\n抽到六星干员了,是不是博士想要的呢?'

        result += text

        if six_rarity:
            if six_rarity > 1:
                result += '\n博士,竟然有 %d 个六星干员!简直是太棒了!' % six_rarity
        else:
            if no_high_rarity:
                result += '\n啊这……博士,不管抽到什么干员,相信他们总有发光发热的一天的'
            else:
                result += '\n博士,资深干员们都有各自出色的地方,要善用他们哦'

        result += '\n%s' % self.check_break_even()

        return result
Пример #3
0
    def continuous_mode(self, times):
        operators = self.start_gacha(times)

        rarity_sum = [0, 0, 0, 0]
        pickup_hit = {5: 0, 6: 0}
        high_star = {5: {}, 6: {}}

        ten_gacha = []
        purple_pack = 0
        multiple_rainbow = {}

        result = '阿米娅给博士扔来了%d张【%s】简历,博士细细地检阅着...\n' % (times,
                                                       self.pick_up_name)

        for item in operators:
            rarity = item['rarity']
            name = item['name']

            # 记录抽到的各星级干员的数量
            rarity_sum[rarity - 3] += 1

            # 记录抽中的 pickup 干员数量
            if (rarity in self.pick_up) and (rarity in pickup_hit):
                if name in self.pick_up[rarity]:
                    pickup_hit[rarity] += 1

            # 记录抽中的高星干员
            if rarity >= 5:
                if name not in high_star[rarity]:
                    high_star[rarity][name] = 0
                high_star[rarity][name] += 1

            # 记录每十连的情况
            ten_gacha.append(rarity)
            if len(ten_gacha) >= 10:

                five = ten_gacha.count(5)
                six = ten_gacha.count(6)

                if five == 0 and six == 0:
                    purple_pack += 1

                if six > 1:
                    if six not in multiple_rainbow:
                        multiple_rainbow[six] = 0
                    multiple_rainbow[six] += 1
                ten_gacha = []

        for r in high_star:
            sd = high_star[r]
            if sd:
                result += '\n%s\n' % ('★' * r)
                operator_num = {}
                for i in sorted(sd, key=sd.__getitem__, reverse=True):
                    num = high_star[r][i]
                    if num not in operator_num:
                        operator_num[num] = []
                    operator_num[num].append(i)
                for num in operator_num:
                    result += '%s X %d\n' % ('、'.join(operator_num[num]), num)

        if rarity_sum[2] == 0 and rarity_sum[3] == 0:
            result += '\n然而并没有高星干员...'

        result += '\n三星:%s四星:%d\n五星:%s六星:%d\n' % (insert_empty(
            rarity_sum[0], 4), rarity_sum[1], insert_empty(rarity_sum[2],
                                                           4), rarity_sum[3])

        enter = True
        if purple_pack > 0:
            result += '\n'
            enter = False
            result += '出现了 %d 次十连紫气东来\n' % purple_pack
        for num in multiple_rainbow:
            if enter:
                result += '\n'
                enter = False
            result += '出现了 %d 次十连内 %d 个六星\n' % (multiple_rainbow[num], num)

        if pickup_hit[6] > 0:
            result += '\n抽到UP的六星干员了,今天也是欧气满满的呀!'
        else:
            if rarity_sum[3] > 0:
                result += '\n没有抽到UP的六星干员吗?不知道其他六星是不是博士想要的呢'
            else:
                result += '\n没有抽到六星干员吗?博士不要气馁,我们要一起氪服困难!'

        result += '\n%s' % self.check_break_even()

        return result
Пример #4
0
    def action(self, data, end=False):

        message = data['text']
        user_id = data['user_id']

        msg_words = posseg.lcut(message.replace('公招', ''))

        tags = []
        max_rarity = 5
        for item in msg_words:
            if item.word in self.tags:
                if item.word in ['资深', '资深干员'] and '资深干员' not in tags:
                    tags.append('资深干员')
                    continue
                if item.word in ['高资', '高级资深', '高级资深干员'
                                 ] and '高级资深干员' not in tags:
                    tags.append('高级资深干员')
                    max_rarity = 6
                    continue
                if item.word not in tags:
                    tags.append(item.word)

        if tags:
            result = database.operator.find_operator_tags_by_tags(
                tags, max_rarity=max_rarity)
            if result:
                operators = {}
                for item in result:
                    name = item['operator_name']
                    if name not in operators:
                        operators[name] = item
                    else:
                        operators[name]['operator_tags'] += item[
                            'operator_tags']

                text = ''
                for comb in [
                        tags
                ] if len(tags) == 1 else self.find_combinations(tags):
                    lst = []
                    for name, item in operators.items():
                        rarity = item['operator_rarity']
                        if all_item_in_text(item['operator_tags'], comb):
                            if rarity == 6 and '高级资深干员' not in comb:
                                continue
                            if rarity >= 4 or rarity == 1:
                                lst.append(item)
                            else:
                                break
                    else:
                        if lst:
                            text += '\n[%s]\n' % ','.join(comb)
                            if comb == ['高级资深干员']:
                                text += '[★★★★★★] 六星 %d 选 1\n' % len(lst)
                                continue
                            if comb == ['资深干员']:
                                text += '[★★★★★ ] 五星 %d 选 1\n' % len(lst)
                                continue
                            for item in lst:
                                rarity = item['operator_rarity']
                                star = '☆' if rarity < 5 else '★'
                                text += '[%s] %s\n' % (insert_empty(
                                    star * rarity, 6,
                                    True), item['operator_name'])

                if text:
                    text = '博士,根据标签已找到以下可以锁定稀有干员的组合\n' + text
                else:
                    text = '博士,没有找到可以锁定高星的组合'

                database.user.set_waiting(user_id, '')
                return Reply(text)

        database.user.set_waiting(user_id, '' if end else 'Recruit')

        wait = '' if end else ',请重新尝试或者发送图片试试吧\n阿米娅正在等待你发送图片...'

        return Reply('博士,没有检测到可以排列的组合%s' % wait)