mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-12 02:08:27 -04:00
Global usings and file scoped namespaces
This commit is contained in:
@@ -1,26 +1,25 @@
|
||||
using NadekoBot.Services.Database.Models;
|
||||
using NadekoBot.Db.Models;
|
||||
|
||||
namespace NadekoBot.Modules.Xp
|
||||
{
|
||||
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; }
|
||||
namespace NadekoBot.Modules.Xp;
|
||||
|
||||
public FullUserStats(DiscordUser usr, UserXpStats fullGuildStats, LevelStats global,
|
||||
LevelStats guild, int globalRanking, int guildRanking)
|
||||
{
|
||||
User = usr;
|
||||
Global = global;
|
||||
Guild = guild;
|
||||
GlobalRanking = globalRanking;
|
||||
GuildRanking = guildRanking;
|
||||
FullGuildStats = fullGuildStats;
|
||||
}
|
||||
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)
|
||||
{
|
||||
User = usr;
|
||||
Global = global;
|
||||
Guild = guild;
|
||||
GlobalRanking = globalRanking;
|
||||
GuildRanking = guildRanking;
|
||||
FullGuildStats = fullGuildStats;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,40 +1,39 @@
|
||||
using NadekoBot.Modules.Xp.Services;
|
||||
|
||||
namespace NadekoBot.Modules.Xp
|
||||
namespace NadekoBot.Modules.Xp;
|
||||
|
||||
public class LevelStats
|
||||
{
|
||||
public class LevelStats
|
||||
public int Level { get; }
|
||||
public int LevelXp { get; }
|
||||
public int RequiredXp { get; }
|
||||
public int TotalXp { get; }
|
||||
|
||||
public LevelStats(int xp)
|
||||
{
|
||||
public int Level { get; }
|
||||
public int LevelXp { get; }
|
||||
public int RequiredXp { get; }
|
||||
public int TotalXp { get; }
|
||||
if (xp < 0)
|
||||
xp = 0;
|
||||
|
||||
public LevelStats(int xp)
|
||||
TotalXp = xp;
|
||||
|
||||
const int baseXp = XpService.XP_REQUIRED_LVL_1;
|
||||
|
||||
var required = baseXp;
|
||||
var totalXp = 0;
|
||||
var lvl = 1;
|
||||
while (true)
|
||||
{
|
||||
if (xp < 0)
|
||||
xp = 0;
|
||||
required = (int)(baseXp + baseXp / 4.0 * (lvl - 1));
|
||||
|
||||
TotalXp = xp;
|
||||
if (required + totalXp > xp)
|
||||
break;
|
||||
|
||||
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;
|
||||
totalXp += required;
|
||||
lvl++;
|
||||
}
|
||||
|
||||
Level = lvl - 1;
|
||||
LevelXp = xp - totalXp;
|
||||
RequiredXp = required;
|
||||
}
|
||||
}
|
||||
}
|
@@ -2,27 +2,26 @@
|
||||
using NadekoBot.Common;
|
||||
using NadekoBot.Common.Yml;
|
||||
|
||||
namespace NadekoBot.Modules.Xp
|
||||
namespace NadekoBot.Modules.Xp;
|
||||
|
||||
[Cloneable]
|
||||
public sealed partial class XpConfig : ICloneable<XpConfig>
|
||||
{
|
||||
[Cloneable]
|
||||
public sealed partial class XpConfig : ICloneable<XpConfig>
|
||||
{
|
||||
[Comment(@"DO NOT CHANGE")]
|
||||
public int Version { get; set; } = 2;
|
||||
[Comment(@"DO NOT CHANGE")]
|
||||
public int Version { get; set; } = 2;
|
||||
|
||||
[Comment(@"How much XP will the users receive per message")]
|
||||
public int XpPerMessage { get; set; } = 3;
|
||||
[Comment(@"How much XP will the users receive per message")]
|
||||
public int XpPerMessage { get; set; } = 3;
|
||||
|
||||
[Comment(@"How often can the users receive XP in minutes")]
|
||||
public int MessageXpCooldown { get; set; } = 5;
|
||||
[Comment(@"How often can the users receive XP in minutes")]
|
||||
public int MessageXpCooldown { get; set; } = 5;
|
||||
|
||||
[Comment(@"Amount of xp users gain from posting an image")]
|
||||
public int XpFromImage { get; set; } = 0;
|
||||
[Comment(@"Amount of xp users gain from posting an image")]
|
||||
public int XpFromImage { get; set; } = 0;
|
||||
|
||||
[Comment(@"Average amount of xp earned per minute in VC")]
|
||||
public double VoiceXpPerMinute { get; set; } = 0;
|
||||
[Comment(@"Average amount of xp earned per minute in VC")]
|
||||
public double VoiceXpPerMinute { get; set; } = 0;
|
||||
|
||||
[Comment(@"The maximum amount of minutes the bot will keep track of a user in a voice channel")]
|
||||
public int VoiceMaxMinutes { get; set; } = 720;
|
||||
}
|
||||
[Comment(@"The maximum amount of minutes the bot will keep track of a user in a voice channel")]
|
||||
public int VoiceMaxMinutes { get; set; } = 720;
|
||||
}
|
@@ -1,297 +1,295 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
|
||||
namespace NadekoBot.Modules.Xp
|
||||
namespace NadekoBot.Modules.Xp;
|
||||
|
||||
public class XpTemplate
|
||||
{
|
||||
public class XpTemplate
|
||||
[JsonProperty("output_size")]
|
||||
public XpTemplatePos OutputSize { get; set; } = new XpTemplatePos
|
||||
{
|
||||
[JsonProperty("output_size")]
|
||||
public XpTemplatePos OutputSize { get; set; } = new XpTemplatePos
|
||||
X = 450,
|
||||
Y = 220,
|
||||
};
|
||||
public XpTemplateUser User { get; set; } = new XpTemplateUser
|
||||
{
|
||||
Name = new XpTemplateText
|
||||
{
|
||||
X = 450,
|
||||
Y = 220,
|
||||
};
|
||||
public XpTemplateUser User { get; set; } = new XpTemplateUser
|
||||
FontSize = 50,
|
||||
Show = true,
|
||||
Pos = new XpTemplatePos
|
||||
{
|
||||
X = 130,
|
||||
Y = 17,
|
||||
}
|
||||
},
|
||||
Icon = new XpTemplateIcon
|
||||
{
|
||||
Name = new XpTemplateText
|
||||
Show = true,
|
||||
Pos = new XpTemplatePos
|
||||
{
|
||||
FontSize = 50,
|
||||
X = 32,
|
||||
Y = 10,
|
||||
},
|
||||
Size = new XpTemplatePos
|
||||
{
|
||||
X = 69,
|
||||
Y = 70,
|
||||
}
|
||||
},
|
||||
GuildLevel = new XpTemplateText
|
||||
{
|
||||
Show = true,
|
||||
FontSize = 45,
|
||||
Pos = new XpTemplatePos
|
||||
{
|
||||
X = 47,
|
||||
Y = 297,
|
||||
}
|
||||
},
|
||||
GlobalLevel = new XpTemplateText
|
||||
{
|
||||
Show = true,
|
||||
FontSize = 45,
|
||||
Pos = new XpTemplatePos
|
||||
{
|
||||
X = 47,
|
||||
Y = 149,
|
||||
}
|
||||
},
|
||||
GuildRank = new XpTemplateText
|
||||
{
|
||||
Show = true,
|
||||
FontSize = 30,
|
||||
Pos = new XpTemplatePos
|
||||
{
|
||||
X = 148,
|
||||
Y = 326,
|
||||
}
|
||||
},
|
||||
GlobalRank = new XpTemplateText
|
||||
{
|
||||
Show = true,
|
||||
FontSize = 30,
|
||||
Pos = new XpTemplatePos
|
||||
{
|
||||
X = 148,
|
||||
Y = 179,
|
||||
}
|
||||
},
|
||||
TimeOnLevel = new XpTemplateTimeOnLevel
|
||||
{
|
||||
Format = "{0}d{1}h{2}m",
|
||||
Global = new XpTemplateText
|
||||
{
|
||||
FontSize = 20,
|
||||
Show = true,
|
||||
Pos = new XpTemplatePos
|
||||
{
|
||||
X = 130,
|
||||
Y = 17,
|
||||
X = 50,
|
||||
Y = 204
|
||||
}
|
||||
},
|
||||
Icon = new XpTemplateIcon
|
||||
Guild = new XpTemplateText
|
||||
{
|
||||
FontSize = 20,
|
||||
Show = true,
|
||||
Pos = new XpTemplatePos
|
||||
{
|
||||
X = 32,
|
||||
Y = 10,
|
||||
},
|
||||
Size = new XpTemplatePos
|
||||
{
|
||||
X = 69,
|
||||
Y = 70,
|
||||
X = 50,
|
||||
Y = 351
|
||||
}
|
||||
},
|
||||
GuildLevel = new XpTemplateText
|
||||
}
|
||||
},
|
||||
Xp = new XpTemplateXP
|
||||
{
|
||||
Bar = new XpTemplateXpBar
|
||||
{
|
||||
Show = true,
|
||||
FontSize = 45,
|
||||
Pos = new XpTemplatePos
|
||||
Global = new XpBar
|
||||
{
|
||||
X = 47,
|
||||
Y = 297,
|
||||
}
|
||||
},
|
||||
GlobalLevel = new XpTemplateText
|
||||
{
|
||||
Show = true,
|
||||
FontSize = 45,
|
||||
Pos = new XpTemplatePos
|
||||
{
|
||||
X = 47,
|
||||
Y = 149,
|
||||
}
|
||||
},
|
||||
GuildRank = new XpTemplateText
|
||||
{
|
||||
Show = true,
|
||||
FontSize = 30,
|
||||
Pos = new XpTemplatePos
|
||||
{
|
||||
X = 148,
|
||||
Y = 326,
|
||||
}
|
||||
},
|
||||
GlobalRank = new XpTemplateText
|
||||
{
|
||||
Show = true,
|
||||
FontSize = 30,
|
||||
Pos = new XpTemplatePos
|
||||
{
|
||||
X = 148,
|
||||
Y = 179,
|
||||
}
|
||||
},
|
||||
TimeOnLevel = new XpTemplateTimeOnLevel
|
||||
{
|
||||
Format = "{0}d{1}h{2}m",
|
||||
Global = new XpTemplateText
|
||||
{
|
||||
FontSize = 20,
|
||||
Show = true,
|
||||
Pos = new XpTemplatePos
|
||||
Direction = XpTemplateDirection.Right,
|
||||
Length = 450,
|
||||
Color = new Rgba32(0, 0, 0, 0.4f),
|
||||
PointA = new XpTemplatePos
|
||||
{
|
||||
X = 50,
|
||||
Y = 204
|
||||
}
|
||||
},
|
||||
Guild = new XpTemplateText
|
||||
{
|
||||
FontSize = 20,
|
||||
Show = true,
|
||||
Pos = new XpTemplatePos
|
||||
{
|
||||
X = 50,
|
||||
Y = 351
|
||||
}
|
||||
}
|
||||
},
|
||||
Xp = new XpTemplateXP
|
||||
{
|
||||
Bar = new XpTemplateXpBar
|
||||
{
|
||||
Show = true,
|
||||
Global = new XpBar
|
||||
{
|
||||
Direction = XpTemplateDirection.Right,
|
||||
Length = 450,
|
||||
Color = new Rgba32(0, 0, 0, 0.4f),
|
||||
PointA = new XpTemplatePos
|
||||
{
|
||||
X = 321,
|
||||
Y = 104
|
||||
},
|
||||
PointB = new XpTemplatePos
|
||||
{
|
||||
X = 286,
|
||||
Y = 235
|
||||
}
|
||||
X = 321,
|
||||
Y = 104
|
||||
},
|
||||
Guild = new XpBar
|
||||
PointB = new XpTemplatePos
|
||||
{
|
||||
Direction = XpTemplateDirection.Right,
|
||||
Length = 450,
|
||||
Color = new Rgba32(0, 0, 0, 0.4f),
|
||||
PointA = new XpTemplatePos
|
||||
{
|
||||
X = 282,
|
||||
Y = 248
|
||||
},
|
||||
PointB = new XpTemplatePos
|
||||
{
|
||||
X = 247,
|
||||
Y = 379
|
||||
}
|
||||
X = 286,
|
||||
Y = 235
|
||||
}
|
||||
},
|
||||
Global = new XpTemplateText
|
||||
Guild = new XpBar
|
||||
{
|
||||
Show = true,
|
||||
FontSize = 50,
|
||||
Pos = new XpTemplatePos
|
||||
Direction = XpTemplateDirection.Right,
|
||||
Length = 450,
|
||||
Color = new Rgba32(0, 0, 0, 0.4f),
|
||||
PointA = new XpTemplatePos
|
||||
{
|
||||
X = 430,
|
||||
Y = 142
|
||||
}
|
||||
},
|
||||
Guild = new XpTemplateText
|
||||
{
|
||||
Show = true,
|
||||
FontSize = 50,
|
||||
Pos = new XpTemplatePos
|
||||
X = 282,
|
||||
Y = 248
|
||||
},
|
||||
PointB = new XpTemplatePos
|
||||
{
|
||||
X = 400,
|
||||
Y = 282
|
||||
X = 247,
|
||||
Y = 379
|
||||
}
|
||||
},
|
||||
Awarded = new XpTemplateText
|
||||
{
|
||||
Show = true,
|
||||
FontSize = 25,
|
||||
Pos = new XpTemplatePos
|
||||
{
|
||||
X = 445,
|
||||
Y = 347
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
public XpTemplateClub Club { get; set; } = new XpTemplateClub
|
||||
{
|
||||
Icon = new XpTemplateIcon
|
||||
{
|
||||
Show = true,
|
||||
Pos = new XpTemplatePos
|
||||
{
|
||||
X = 722,
|
||||
Y = 25,
|
||||
},
|
||||
Size = new XpTemplatePos
|
||||
{
|
||||
X = 45,
|
||||
Y = 45,
|
||||
}
|
||||
},
|
||||
Name = new XpTemplateText
|
||||
Global = new XpTemplateText
|
||||
{
|
||||
FontSize = 35,
|
||||
Show = true,
|
||||
FontSize = 50,
|
||||
Pos = new XpTemplatePos
|
||||
{
|
||||
X = 650,
|
||||
Y = 49
|
||||
},
|
||||
X = 430,
|
||||
Y = 142
|
||||
}
|
||||
},
|
||||
Guild = new XpTemplateText
|
||||
{
|
||||
Show = true,
|
||||
FontSize = 50,
|
||||
Pos = new XpTemplatePos
|
||||
{
|
||||
X = 400,
|
||||
Y = 282
|
||||
}
|
||||
},
|
||||
Awarded = new XpTemplateText
|
||||
{
|
||||
Show = true,
|
||||
FontSize = 25,
|
||||
Pos = new XpTemplatePos
|
||||
{
|
||||
X = 445,
|
||||
Y = 347
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public class XpTemplateIcon
|
||||
{
|
||||
public bool Show { get; set; }
|
||||
public XpTemplatePos Pos { get; set; }
|
||||
public XpTemplatePos Size { get; set; }
|
||||
}
|
||||
|
||||
public class XpTemplatePos
|
||||
{
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
}
|
||||
|
||||
public class XpTemplateUser
|
||||
{
|
||||
public XpTemplateText Name { get; set; }
|
||||
public XpTemplateIcon Icon { get; set; }
|
||||
public XpTemplateText GlobalLevel { get; set; }
|
||||
public XpTemplateText GuildLevel { get; set; }
|
||||
public XpTemplateText GlobalRank { get; set; }
|
||||
public XpTemplateText GuildRank { get; set; }
|
||||
public XpTemplateTimeOnLevel TimeOnLevel { get; set; }
|
||||
public XpTemplateXP Xp { get; set; }
|
||||
}
|
||||
|
||||
public class XpTemplateTimeOnLevel
|
||||
{
|
||||
public string Format { get; set; }
|
||||
public XpTemplateText Global { get; set; }
|
||||
public XpTemplateText Guild { get; set; }
|
||||
}
|
||||
|
||||
public class XpTemplateClub
|
||||
{
|
||||
public XpTemplateIcon Icon { get; set; }
|
||||
public XpTemplateText Name { get; set; }
|
||||
}
|
||||
|
||||
public class XpTemplateText
|
||||
{
|
||||
[JsonConverter(typeof(XpRgba32Converter))]
|
||||
public Rgba32 Color { get; set; } = SixLabors.ImageSharp.Color.White;
|
||||
public bool Show { get; set; }
|
||||
public int FontSize { get; set; }
|
||||
public XpTemplatePos Pos { get; set; }
|
||||
}
|
||||
|
||||
public class XpTemplateXP
|
||||
{
|
||||
public XpTemplateXpBar Bar { get; set; }
|
||||
public XpTemplateText Global { get; set; }
|
||||
public XpTemplateText Guild { get; set; }
|
||||
public XpTemplateText Awarded { get; set; }
|
||||
}
|
||||
|
||||
public class XpTemplateXpBar
|
||||
{
|
||||
public bool Show { get; set; }
|
||||
public XpBar Global { get; set; }
|
||||
public XpBar Guild { get; set; }
|
||||
}
|
||||
|
||||
public class XpBar
|
||||
{
|
||||
[JsonConverter(typeof(XpRgba32Converter))]
|
||||
public Rgba32 Color { get; set; }
|
||||
public XpTemplatePos PointA { get; set; }
|
||||
public XpTemplatePos PointB { get; set; }
|
||||
public int Length { get; set; }
|
||||
public XpTemplateDirection Direction { get; set; }
|
||||
}
|
||||
|
||||
public enum XpTemplateDirection
|
||||
{
|
||||
Up,
|
||||
Down,
|
||||
Left,
|
||||
Right
|
||||
}
|
||||
|
||||
public class XpRgba32Converter : JsonConverter<Rgba32>
|
||||
{
|
||||
public override Rgba32 ReadJson(JsonReader reader, Type objectType, Rgba32 existingValue, bool hasExistingValue, JsonSerializer serializer)
|
||||
{
|
||||
return Color.ParseHex(reader.Value.ToString());
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, Rgba32 value, JsonSerializer serializer)
|
||||
};
|
||||
public XpTemplateClub Club { get; set; } = new XpTemplateClub
|
||||
{
|
||||
Icon = new XpTemplateIcon
|
||||
{
|
||||
writer.WriteValue(value.ToHex().ToLowerInvariant());
|
||||
Show = true,
|
||||
Pos = new XpTemplatePos
|
||||
{
|
||||
X = 722,
|
||||
Y = 25,
|
||||
},
|
||||
Size = new XpTemplatePos
|
||||
{
|
||||
X = 45,
|
||||
Y = 45,
|
||||
}
|
||||
},
|
||||
Name = new XpTemplateText
|
||||
{
|
||||
FontSize = 35,
|
||||
Pos = new XpTemplatePos
|
||||
{
|
||||
X = 650,
|
||||
Y = 49
|
||||
},
|
||||
Show = true,
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public class XpTemplateIcon
|
||||
{
|
||||
public bool Show { get; set; }
|
||||
public XpTemplatePos Pos { get; set; }
|
||||
public XpTemplatePos Size { get; set; }
|
||||
}
|
||||
|
||||
public class XpTemplatePos
|
||||
{
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
}
|
||||
|
||||
public class XpTemplateUser
|
||||
{
|
||||
public XpTemplateText Name { get; set; }
|
||||
public XpTemplateIcon Icon { get; set; }
|
||||
public XpTemplateText GlobalLevel { get; set; }
|
||||
public XpTemplateText GuildLevel { get; set; }
|
||||
public XpTemplateText GlobalRank { get; set; }
|
||||
public XpTemplateText GuildRank { get; set; }
|
||||
public XpTemplateTimeOnLevel TimeOnLevel { get; set; }
|
||||
public XpTemplateXP Xp { get; set; }
|
||||
}
|
||||
|
||||
public class XpTemplateTimeOnLevel
|
||||
{
|
||||
public string Format { get; set; }
|
||||
public XpTemplateText Global { get; set; }
|
||||
public XpTemplateText Guild { get; set; }
|
||||
}
|
||||
|
||||
public class XpTemplateClub
|
||||
{
|
||||
public XpTemplateIcon Icon { get; set; }
|
||||
public XpTemplateText Name { get; set; }
|
||||
}
|
||||
|
||||
public class XpTemplateText
|
||||
{
|
||||
[JsonConverter(typeof(XpRgba32Converter))]
|
||||
public Rgba32 Color { get; set; } = SixLabors.ImageSharp.Color.White;
|
||||
public bool Show { get; set; }
|
||||
public int FontSize { get; set; }
|
||||
public XpTemplatePos Pos { get; set; }
|
||||
}
|
||||
|
||||
public class XpTemplateXP
|
||||
{
|
||||
public XpTemplateXpBar Bar { get; set; }
|
||||
public XpTemplateText Global { get; set; }
|
||||
public XpTemplateText Guild { get; set; }
|
||||
public XpTemplateText Awarded { get; set; }
|
||||
}
|
||||
|
||||
public class XpTemplateXpBar
|
||||
{
|
||||
public bool Show { get; set; }
|
||||
public XpBar Global { get; set; }
|
||||
public XpBar Guild { get; set; }
|
||||
}
|
||||
|
||||
public class XpBar
|
||||
{
|
||||
[JsonConverter(typeof(XpRgba32Converter))]
|
||||
public Rgba32 Color { get; set; }
|
||||
public XpTemplatePos PointA { get; set; }
|
||||
public XpTemplatePos PointB { get; set; }
|
||||
public int Length { get; set; }
|
||||
public XpTemplateDirection Direction { get; set; }
|
||||
}
|
||||
|
||||
public enum XpTemplateDirection
|
||||
{
|
||||
Up,
|
||||
Down,
|
||||
Left,
|
||||
Right
|
||||
}
|
||||
|
||||
public class XpRgba32Converter : JsonConverter<Rgba32>
|
||||
{
|
||||
public override Rgba32 ReadJson(JsonReader reader, Type objectType, Rgba32 existingValue, bool hasExistingValue, JsonSerializer serializer)
|
||||
{
|
||||
return Color.ParseHex(reader.Value.ToString());
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, Rgba32 value, JsonSerializer serializer)
|
||||
{
|
||||
writer.WriteValue(value.ToHex().ToLowerInvariant());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user