def add_records(self, stock_historical):
        """
           This Function receives a historical dictionary, assign each element and finally add to a list.
        """
        for day in stock_historical:
            record = Historical(self.__symbol, day, stock_historical[ day ][ '1. open' ],
                                stock_historical[ day ][ '2. high' ], stock_historical[ day ][ '3. low' ],
                                stock_historical[ day ][ '4. close' ], stock_historical[ day ][ '5. volume' ])

            self.__records.append(record)
예제 #2
0
파일: update.py 프로젝트: matheus013/gsbot
 def __create_historical(self, character, date: datetime):
     update = Historical.create({
         'type': "update",
         'char_class':character.char_class.upper(),
         'timestamp': date,
         'level': float(str(character.level) + '.' + str(round(character.progress))) ,
         'ap': character.ap,
         'aap': character.aap,
         'dp': character.dp,
         'gear_score': character.gear_score,
         'renown_score': character.renown_score
     })
     return update
예제 #3
0
    async def reroll(self, ctx, new_char_name, level: int, ap: int, aap: int,
                     dp: int, new_char_class):
        """Just for someone special: Allows you to reroll your main character """

        author = ctx.message.author.id
        character = Character.primary_chars(member=author).first()
        date = datetime.now()
        if not character:
            await self.bot.say(
                "Can't reroll if you're not in the database :(, try adding a character first"
            )
            return

        if not await check_character_name(self.bot, new_char_class):
            return

        else:
            try:
                ## Adds historical data to database
                update = Historical.create({
                    'type':
                    "reroll",
                    'char_class':
                    character.char_class.upper(),
                    'timestamp':
                    date,
                    'level':
                    float(
                        str(character.level) + '.' +
                        str(round(character.progress))),
                    'ap':
                    character.ap,
                    'aap':
                    character.aap,
                    'dp':
                    character.dp,
                    'gear_score':
                    character.gear_score,
                    'renown_score':
                    character.renown_score,
                })

                historical_data = character.hist_data
                fame = character.fame or 0
                historical_data.append(update)

                character.update_attributes({
                    'char_name':
                    new_char_name.upper(),
                    'ap':
                    ap,
                    'aap':
                    aap,
                    'dp':
                    dp,
                    'level':
                    level,
                    'gear_score':
                    max(aap, ap) + dp,
                    'renown_score':
                    math.trunc((ap + aap) / 2 + dp) + fame,
                    'char_class':
                    new_char_class.upper(),
                    'updated':
                    date,
                    'hist_data':
                    historical_data
                })

                row = get_row([character], False)
                data = tabulate(row, HEADERS, 'simple')

                logActivity(
                    '{} has rerolled a character'.format(character.fam_name),
                    ctx.message.author.name)
                reminder = '\n\nRemember to add a new pic with gsbot attach_pic!'
                await self.bot.say(
                    codify("Success Rerolling\n\n" + data + reminder))

            except Exception as e:
                print_error(e)
                await self.bot.say("Could not reroll")