Example #1
0
 async def profile_on_message(self, message: Message):
     if message.author.bot:
         return
     if message.channel == None or not message.channel.guild.id in whitelist or message.author.bot:
         return
     if self.populateChannels(message, self.isTest):
         return
     if not self.channelAllowed(message.channel.id, self.isTest):
         return
     member: Member = self.db.get_member(message.author.id)
     if not member:
         self.db.add_member(message.author.id)
         member = self.db.get_member(message.author.id)
     increaseNumber = randint(10, 25)
     rank = self.db.increase_exp(message.channel.guild.id,
                                 message.channel.id, message.author.id,
                                 increaseNumber)
     assert rank > 0, 'method increase_xp should not retrun less than 1 in profile_on_message'
     if member.rank != rank:
         channel = ChannelUtil.getMessageChannelId(message.guild.id)
         if channel == None:
             channelToUse = message.channel
         else:
             channelToUse = message.guild.get_channel(channel)
         RPGCharacterUtil.levelUpCharacter(message.author.id, member.rank,
                                           rank)
         await channelToUse.send('恭喜<@{}> 等級提升至{}。'.format(
             message.author.id, rank))
         await self.updateUserKfpRoles(message, rank, channelToUse)
     self.db.increase_coin(message.guild.id, message.author.id,
                           increaseNumber)
Example #2
0
    def test_levelUpCharacter_success(self):
        member = self.database.add_member(100)
        rpg: RPGCharacterUtil = RPGCharacterUtil.createNewRPGCharacter(member)
        old_hp = rpg.hp_max 
        old_mp = rpg.mp_max
        old_atk = rpg.attack_basic
        old_def = rpg.defense_basic
        RPGCharacterUtil.levelUpCharacter(member.member_id, 1, 10)
        rpg: RPGCharacterUtil = RPGCharacterUtil.getRPGCharacter(member.member_id)

        assert rpg.hp_max > old_hp
        assert rpg.mp_max > old_mp
        assert rpg.attack_basic > old_atk
        assert rpg.defense_basic > old_def