using MediatR;

namespace MissionService.API.Application.Queries;

/// <summary>
/// EN: Query to get all available missions for a user
/// VI: Query lấy tất cả missions khả dụng cho user
/// </summary>
public record GetAvailableMissionsQuery(Guid UserId) : IRequest<MissionsListResult>;

/// <summary>
/// EN: Query to get mission details
/// VI: Query lấy chi tiết mission
/// </summary>
public record GetMissionDetailsQuery(Guid MissionId, Guid? UserId = null) : IRequest<MissionDetailsResult?>;

/// <summary>
/// EN: Query to get missions by category
/// VI: Query lấy missions theo danh mục
/// </summary>
public record GetMissionsByCategoryQuery(string Category) : IRequest<MissionsListResult>;

/// <summary>
/// EN: Query to get user's mission progress
/// VI: Query lấy tiến độ mission của user
/// </summary>
public record GetUserMissionProgressQuery(Guid UserId) : IRequest<UserMissionProgressResult>;

/// <summary>
/// EN: Missions list result DTO
/// VI: DTO kết quả danh sách missions
/// </summary>
public record MissionsListResult(IReadOnlyList<MissionSummaryDto> Missions);

/// <summary>
/// EN: Mission summary DTO
/// VI: DTO tóm tắt mission
/// </summary>
public record MissionSummaryDto(
    Guid Id,
    string Code,
    string Title,
    string? Description,
    string Type,
    string Category,
    decimal RewardPoints,
    string Frequency,
    int MaxCompletions,
    bool IsAvailable,
    UserTaskProgressDto? UserProgress);

/// <summary>
/// EN: Mission details result DTO
/// VI: DTO kết quả chi tiết mission
/// </summary>
public record MissionDetailsResult(
    Guid Id,
    string Code,
    string TitleEn,
    string TitleVi,
    string? DescriptionEn,
    string? DescriptionVi,
    string Type,
    string Category,
    MissionRewardDto Reward,
    string Frequency,
    int MaxCompletions,
    DateTime StartDate,
    DateTime? EndDate,
    string Status,
    IReadOnlyList<MissionRuleDto> Rules,
    UserTaskProgressDto? UserProgress);

/// <summary>
/// EN: Mission reward DTO
/// VI: DTO phần thưởng mission
/// </summary>
public record MissionRewardDto(
    decimal Points,
    decimal MiningBoostPercent,
    int ExperiencePoints,
    string? BadgeId);

/// <summary>
/// EN: Mission rule DTO
/// VI: DTO quy tắc mission
/// </summary>
public record MissionRuleDto(
    string RuleType,
    string Operator,
    string Value);

/// <summary>
/// EN: User task progress DTO
/// VI: DTO tiến độ task của user
/// </summary>
public record UserTaskProgressDto(
    Guid TaskId,
    int CurrentValue,
    int TargetValue,
    decimal PercentComplete,
    string Status,
    DateTime StartedAt,
    DateTime? CompletedAt,
    bool RewardClaimed);

/// <summary>
/// EN: User mission progress result
/// VI: Kết quả tiến độ mission của user
/// </summary>
public record UserMissionProgressResult(
    int TotalMissions,
    int CompletedMissionsCount,
    int InProgressMissions,
    decimal TotalPointsEarned,
    IReadOnlyList<MissionSummaryDto> ActiveMissions,
    IReadOnlyList<MissionSummaryDto> CompletedMissions);
