Removed module projects because it can't work like that atm. Commented out package commands.
This commit is contained in:
26
NadekoBot.Core/Modules/Xp/Common/FullUserStats.cs
Normal file
26
NadekoBot.Core/Modules/Xp/Common/FullUserStats.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using NadekoBot.Core.Services.Database.Models;
|
||||
|
||||
namespace NadekoBot.Modules.Xp.Common
|
||||
{
|
||||
public class FullUserStats
|
||||
{
|
||||
public DiscordUser User { get; }
|
||||
public UserXpStats FullGuildStats { get; }
|
||||
public LevelStats Global { get; }
|
||||
public LevelStats Guild { get; }
|
||||
public int GlobalRanking { get; }
|
||||
public int GuildRanking { get; }
|
||||
|
||||
public FullUserStats(DiscordUser usr,
|
||||
UserXpStats fullGuildStats, LevelStats global,
|
||||
LevelStats guild, int globalRanking, int guildRanking)
|
||||
{
|
||||
this.User = usr;
|
||||
this.Global = global;
|
||||
this.Guild = guild;
|
||||
this.GlobalRanking = globalRanking;
|
||||
this.GuildRanking = guildRanking;
|
||||
this.FullGuildStats = fullGuildStats;
|
||||
}
|
||||
}
|
||||
}
|
43
NadekoBot.Core/Modules/Xp/Common/LevelStats.cs
Normal file
43
NadekoBot.Core/Modules/Xp/Common/LevelStats.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using NadekoBot.Modules.Xp.Services;
|
||||
using System;
|
||||
|
||||
namespace NadekoBot.Modules.Xp.Common
|
||||
{
|
||||
public class LevelStats
|
||||
{
|
||||
public int Level { get; }
|
||||
public int LevelXp { get; }
|
||||
public int RequiredXp { get; }
|
||||
public int TotalXp { get; }
|
||||
|
||||
public LevelStats(int xp)
|
||||
{
|
||||
if (xp < 0)
|
||||
xp = 0;
|
||||
|
||||
TotalXp = xp;
|
||||
|
||||
const int baseXp = XpService.XP_REQUIRED_LVL_1;
|
||||
|
||||
var required = baseXp;
|
||||
var totalXp = 0;
|
||||
var lvl = 1;
|
||||
while (true)
|
||||
{
|
||||
required = (int)(baseXp + baseXp / 4.0 * (lvl - 1));
|
||||
|
||||
if (required + totalXp > xp)
|
||||
break;
|
||||
|
||||
totalXp += required;
|
||||
lvl++;
|
||||
}
|
||||
|
||||
Level = lvl - 1;
|
||||
LevelXp = xp - totalXp;
|
||||
RequiredXp = required;
|
||||
}
|
||||
|
||||
public static LevelStats FromXp(int xp) => new LevelStats(xp);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user