示例#1
0
        public static async Task <bool> GiveExpToUser(CakeUser user, int expToGive)
        {
            user.TotalXp += expToGive;
            if (user.GetCurrentExp() >= user.GetNextLevelExp())
            {
                user.Level += 1;
                await UserQueries.Update(user);

                return(true);
            }
            await UserQueries.Update(user);

            return(false);
        }
示例#2
0
        public static async Task <CakeUser> DecreaseLevels(CakeUser user, int amount = 1)
        {
            for (int i = 0; i < amount; i++)
            {
                if (user.GetNextLevelExp() < user.GetCurrentExp())
                {
                    user.TotalXp -= user.GetNextLevelExp();
                    user.Level--;
                }
            }
            await UserQueries.Update(user);

            return(user);
        }