namespace RpgRoller.Components.Pages;

public sealed class FormState<TModel> where TModel : new()
{
    public void ResetValidation()
    {
        Errors.Clear();
        ErrorMessage = null;
    }

    public TModel Model { get; } = new();
    public Dictionary<string, string> Errors { get; } = [];
    public string? ErrorMessage { get; set; }
}

public sealed class RegisterFormModel
{
    public string Username { get; set; } = string.Empty;
    public string DisplayName { get; set; } = string.Empty;
    public string Password { get; set; } = string.Empty;
}

public sealed class LoginFormModel
{
    public string Username { get; set; } = string.Empty;
    public string Password { get; set; } = string.Empty;
}

public sealed class CampaignFormModel
{
    public string Name { get; set; } = string.Empty;
    public string RulesetId { get; set; } = string.Empty;
}

public sealed class CharacterFormModel
{
    public string Name { get; set; } = string.Empty;
    public string CampaignId { get; set; } = string.Empty;
    public string OwnerUsername { get; set; } = string.Empty;
}

public sealed class SkillFormModel
{
    public string Name { get; set; } = string.Empty;
    public string RulesetId { get; set; } = string.Empty;
    public string DiceRollDefinition { get; set; } = string.Empty;
    public string SkillGroupId { get; set; } = string.Empty;
    public int WildDice { get; set; }
    public bool AllowFumble { get; set; }
    public int? FumbleRange { get; set; }
    public bool RolemasterAutoRetry { get; set; }
}

public sealed class SkillGroupFormModel
{
    public string Name { get; set; } = string.Empty;
    public string RulesetId { get; set; } = string.Empty;
    public string DiceRollDefinition { get; set; } = string.Empty;
    public int WildDice { get; set; }
    public bool AllowFumble { get; set; }
    public int? FumbleRange { get; set; }
}

public sealed class CustomRollFormModel
{
    public string Expression { get; set; } = string.Empty;
}

public enum HomeViewMode
{
    Loading,
    Anonymous,
    Workspace
}