Exemplo n.º 1
0
 def post(self):
     new_character = Character()
     valid = new_character.create(request.json)
     if valid:
         response = hdb.insert(new_character)
         return {
             "id": new_character._id,
             "status": response,
             "character": new_character.payload,
         }
     else:
         return "Could not create Character", 400
Exemplo n.º 2
0
connect('gsbot_test')

if HAS_CLOUD_STORAGE:
    config(cloud_name=CLOUD_NAME,
           api_key=CLOUDINARY_API,
           api_secret=CLOUDINARY_SECRET)

## Test Characters Creation
char1 = Character.create({
    "rank": "Member",
    "fam_name": "Member1",
    "char_name": "Char1",
    "char_class": "wizard",
    "level": 60,
    "ap": 197,
    "aap": 197,
    "dp": 238,
    "gear_score": 435,
    "progress": 0.0,
    "gear_pic": "https://i.imgur.com/UFViCXj.jpg",
    "server": 1,
    "primary": False,
    "member": 1,
})

char2 = Character.create({
    "rank": "Member",
    "fam_name": "Member1",
    "char_name": "Char2",
    "char_class": "Musa",
    "level": 60,
    "ap": 197,
Exemplo n.º 3
0
    async def add(self,
                  ctx,
                  fam_name,
                  char_name,
                  level: int,
                  ap: int,
                  aap: int,
                  dp: int,
                  char_class,
                  user: discord.User = None):
        """Adds your primary character to the guild. This character is linked with your
        discord id and can only be updated by either that member or an officer.
        **Officers can add a user by tagging them at the end. eg @drawven**
        Note: Total gear score, renown score, and rank are auto calculated."""

        # Checks character name to make sure it is correct
        try:

            if not await check_character_name(self.bot, char_class):
                return
            author = ctx.message.author
            discord_server = ctx.message.server
            roles = [u.name for u in author.roles]
            rank, discord_user = await self.__get_rank_and_member(
                author, user, roles)
            server, member = self.__get_server_and_member(
                discord_server, discord_user)

            if rank is None or discord_user.id is None:
                return

            character = Character.primary_chars(member=discord_user.id).first()
            isPrimary = False if character else True

            character = Character.create({
                'rank':
                rank,
                'fam_name':
                fam_name.upper(),
                'char_name':
                char_name.upper(),
                'char_class':
                char_class.upper(),
                'server':
                discord_server.id,
                'level':
                level,
                'ap':
                ap,
                'aap':
                aap,
                'dp':
                dp,
                'gear_score':
                max(aap, ap) + dp,
                'renown_score':
                math.trunc((ap + aap) / 2 + dp),
                'primary':
                isPrimary,
                'member':
                discord_user.id,
            })
            member.characters.append(character)
            member.save()

            row = get_row([character], False)
            data = tabulate(row, HEADERS, 'simple')
            logActivity('{} has added a character'.format(character.fam_name),
                        user.name if user else author.name)
            await self.bot.say(
                codify("Success Adding Character for member {} :D\n\n".format(
                    discord_user.name.upper()) + data))

        except Exception as e:
            print_error(e)
            await self.bot.say("Something went horribly wrong")