40 lines
958 B
C#
40 lines
958 B
C#
using NeonSprawl.Server.Game.Skills;
|
|
|
|
namespace NeonSprawl.Server.Game.Mastery;
|
|
|
|
/// <summary>Applies dev-only mastery fixture resets (NEO-48).</summary>
|
|
public static class MasteryFixtureOperations
|
|
{
|
|
public static bool TryApply(
|
|
string playerId,
|
|
MasteryFixtureRequest body,
|
|
IPlayerPerkStateStore perkStore,
|
|
IPlayerSkillProgressionStore xpStore)
|
|
{
|
|
if (body.ResetPerkState && !perkStore.TryResetPerkState(playerId))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (body.SkillXp is null || body.SkillXp.Count == 0)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
foreach (var (skillId, xp) in body.SkillXp)
|
|
{
|
|
if (skillId.Trim().Length == 0 || xp < 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (!xpStore.TrySetSkillXpTotal(playerId, skillId, xp))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|