Changing XP gain to random of 15-25. also adding LastUpdated to ensure experience gain only once per minute.
This commit is contained in:
parent
1b4f4cc1c0
commit
a40edc8a99
@ -27,18 +27,30 @@ namespace ChaosBot.Discord.Services
|
|||||||
if (usrXp.Any())
|
if (usrXp.Any())
|
||||||
{
|
{
|
||||||
usrNewXp = usrXp.First();
|
usrNewXp = usrXp.First();
|
||||||
usrNewXp.Amount = usrNewXp.Amount + Convert.ToUInt64(ConfigurationRepository.GetValue<string>("Experience:PerMsg", DiscordGuildId, "0"));
|
|
||||||
}
|
if(DateTime.Now >= usrNewXp.LastUpdated.AddMinutes(1))
|
||||||
|
{
|
||||||
|
usrNewXp.Amount = usrNewXp.Amount + Convert.ToUInt64(new Random().Next(15, 26));
|
||||||
|
|
||||||
|
usrNewXp.DiscordGuildId = DiscordGuildId;
|
||||||
|
usrNewXp.DiscordUserId = DiscordUserId;
|
||||||
|
usrNewXp.LastUpdated = DateTime.Now;
|
||||||
|
|
||||||
|
await dbContext.ExperiencePoints.Upsert(usrNewXp)
|
||||||
|
.On(x => new {x.DiscordGuildId, x.DiscordUserId}).RunAsync();
|
||||||
|
} }
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
usrNewXp = new Experience();
|
usrNewXp = new Experience();
|
||||||
usrNewXp.Amount = Convert.ToUInt64(ConfigurationRepository.GetValue<string>("Experience:PerMsg", DiscordGuildId, "0"));
|
usrNewXp.Amount = Convert.ToUInt64(new Random().Next(15, 26));
|
||||||
}
|
|
||||||
usrNewXp.DiscordGuildId = DiscordGuildId;
|
|
||||||
usrNewXp.DiscordUserId = DiscordUserId;
|
|
||||||
|
|
||||||
await dbContext.ExperiencePoints.Upsert(usrNewXp)
|
usrNewXp.DiscordGuildId = DiscordGuildId;
|
||||||
.On(x => new { x.DiscordGuildId, x.DiscordUserId}).RunAsync();
|
usrNewXp.DiscordUserId = DiscordUserId;
|
||||||
|
usrNewXp.LastUpdated = DateTime.Now;
|
||||||
|
|
||||||
|
await dbContext.ExperiencePoints.Upsert(usrNewXp)
|
||||||
|
.On(x => new { x.DiscordGuildId, x.DiscordUserId}).RunAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user