using System.Collections.Generic;

namespace RolemasterDb.App.Features;

public sealed record LookupOption(string Key, string Label);

public sealed record AttackTableReference(
    string Key,
    string Label,
    string AttackKind,
    int? FumbleMinRoll,
    int? FumbleMaxRoll);

public sealed record CriticalColumnReference(
    string Key,
    string Label,
    string Role,
    int SortOrder);

public sealed record CriticalGroupReference(
    string Key,
    string Label,
    int SortOrder);

public sealed record CriticalRollBandReference(
    string Label,
    int MinRoll,
    int? MaxRoll,
    int SortOrder);

public sealed record CriticalTableReference(
    string Key,
    string Label,
    string Family,
    string SourceDocument,
    string? Notes,
    int CuratedResultCount,
    int TotalResultCount,
    int CurationPercentage,
    IReadOnlyList<CriticalColumnReference> Columns,
    IReadOnlyList<CriticalGroupReference> Groups,
    IReadOnlyList<CriticalRollBandReference> RollBands);

public sealed record LookupReferenceData(
    IReadOnlyList<AttackTableReference> AttackTables,
    IReadOnlyList<LookupOption> ArmorTypes,
    IReadOnlyList<CriticalTableReference> CriticalTables);

public sealed record AttackLookupRequest(
    string AttackTable,
    string ArmorType,
    int Roll,
    int? CriticalRoll);

public sealed record CriticalLookupRequest(
    string CriticalType,
    string Column,
    int Roll,
    string? Group);

public sealed record CriticalBranchLookupResponse(
    string BranchKind,
    string? ConditionKey,
    string ConditionText,
    string Description,
    string? AffixText,
    IReadOnlyList<CriticalEffectLookupResponse> Effects,
    string RawText,
    int SortOrder);

public sealed record CriticalLookupResponse(
    string CriticalType,
    string CriticalTableName,
    string CriticalFamily,
    string SourceDocument,
    string? TableNotes,
    string? Group,
    string? GroupLabel,
    string Column,
    string ColumnLabel,
    string ColumnRole,
    int Roll,
    string RollBand,
    int RollBandMinRoll,
    int? RollBandMaxRoll,
    string RawCellText,
    string Description,
    string? AffixText,
    IReadOnlyList<CriticalEffectLookupResponse> Effects,
    IReadOnlyList<CriticalBranchLookupResponse> Branches,
    string ParseStatus,
    string ParsedJson);

public sealed record AttackLookupResponse(
    string AttackTable,
    string AttackTableName,
    string ArmorType,
    string ArmorTypeLabel,
    int Roll,
    string RollBand,
    int Hits,
    string? CriticalType,
    string? CriticalSeverity,
    string RawNotation,
    string? Notes,
    CriticalLookupResponse? AutoCritical);

public sealed record CriticalTableCellDetail(
    int ResultId,
    string RollBand,
    string ColumnKey,
    string ColumnLabel,
    string ColumnRole,
    string? GroupKey,
    string? GroupLabel,
    bool IsCurated,
    string? Description,
    IReadOnlyList<CriticalEffectLookupResponse> Effects,
    IReadOnlyList<CriticalBranchLookupResponse> Branches);

public sealed record CriticalTableLegendEntry(
    string EffectCode,
    string Symbol,
    string Label,
    string Description,
    string Tooltip);

public sealed record CriticalTableDetail(
    string Slug,
    string DisplayName,
    string Family,
    string SourceDocument,
    string? Notes,
    IReadOnlyList<CriticalColumnReference> Columns,
    IReadOnlyList<CriticalGroupReference> Groups,
    IReadOnlyList<CriticalRollBandReference> RollBands,
    IReadOnlyList<CriticalTableCellDetail> Cells,
    IReadOnlyList<CriticalTableLegendEntry> Legend);
