62 lines
2.3 KiB
C#
62 lines
2.3 KiB
C#
using System.Text.Json.Serialization;
|
|
|
|
namespace NeonSprawl.Server.Game.Skills;
|
|
|
|
/// <summary>POST body for applying one skill XP grant (NEO-38).</summary>
|
|
public sealed class SkillProgressionGrantRequest
|
|
{
|
|
public const int CurrentSchemaVersion = 1;
|
|
|
|
[JsonPropertyName("schemaVersion")]
|
|
public int SchemaVersion { get; init; }
|
|
|
|
[JsonPropertyName("skillId")]
|
|
public required string SkillId { get; init; }
|
|
|
|
[JsonPropertyName("amount")]
|
|
public int Amount { get; init; }
|
|
|
|
/// <summary>XP grant source kind (e.g. <c>activity</c>, <c>mission_reward</c>).</summary>
|
|
/// <remarks>Validated against target skill's <c>allowedXpSourceKinds</c> (ordinal ignore-case).</remarks>
|
|
[JsonPropertyName("sourceKind")]
|
|
public required string SourceKind { get; init; }
|
|
}
|
|
|
|
/// <summary>POST responses for progression grants — success (<see cref="Granted"/>) or structured deny (<see cref="ReasonCode"/>).</summary>
|
|
public sealed class SkillProgressionGrantResponse
|
|
{
|
|
public const int CurrentSchemaVersion = 1;
|
|
|
|
[JsonPropertyName("schemaVersion")]
|
|
public int SchemaVersion { get; init; } = CurrentSchemaVersion;
|
|
|
|
[JsonPropertyName("granted")]
|
|
public bool Granted { get; init; }
|
|
|
|
/// <summary>Stable snake_case deny code when <see cref="Granted"/> is <c>false</c>.</summary>
|
|
/// <remarks>Set when <see cref="Granted"/> is <c>false</c>; stable snake_case values (see README).</remarks>
|
|
[JsonPropertyName("reasonCode")]
|
|
public string? ReasonCode { get; init; }
|
|
|
|
[JsonPropertyName("progression")]
|
|
public required SkillProgressionSnapshotResponse Progression { get; init; }
|
|
|
|
/// <summary>Level-up rows for skills that crossed a boundary on this grant.</summary>
|
|
/// <remarks>Present on success only; empty array when XP changed but level did not.</remarks>
|
|
[JsonPropertyName("levelUps")]
|
|
public required IReadOnlyList<SkillLevelUpJson> LevelUps { get; init; }
|
|
}
|
|
|
|
/// <summary>One skill crossed a level boundary on this grant (<c>previousLevel</c> < <c>newLevel</c>).</summary>
|
|
public sealed class SkillLevelUpJson
|
|
{
|
|
[JsonPropertyName("skillId")]
|
|
public required string SkillId { get; init; }
|
|
|
|
[JsonPropertyName("previousLevel")]
|
|
public int PreviousLevel { get; init; }
|
|
|
|
[JsonPropertyName("newLevel")]
|
|
public int NewLevel { get; init; }
|
|
}
|