import 'package:laba1/domain/models/card.dart';

import '../../domain/models/home.dart';
import '../dtos/spells_dto.dart';

const _imagePlaceHolder ='https://cdn-icons-png.flaticon.com/512/1277/1277244.png';

extension SpellsDtoToModel on SpellsDto {
  HomeData toDomain() => HomeData(
    data: data?.map((e) => e.toDomain()).toList(),
    nextPage: meta?.pagination?.next,
  );
}

extension SpellsDataDtoToModel on SpellDataDto {
  CardData toDomain() => CardData(
        id,
        attributes?.name ?? 'UNKNOWN',
        imageUrl: attributes?.image ?? _imagePlaceHolder,
        description: _makeDescription(attributes),
      );
}

String _makeDescription(SpellAttributesDataDto? attributes){
  return 'incantation: ${attributes?.incantation ?? 'UNKNOWN'},\n'
      'category: ${attributes?.category ?? 'UNKNOWN'},\n'
      'creator: ${attributes?.creator ?? 'UNKNOWN'},\n'
      'effect: ${attributes?.effect ?? 'UNKNOWN'},\n'
      'hand: ${attributes?.hand ?? 'UNKNOWN'},\n'
      'light: ${attributes?.light ?? 'UNKNOWN'},\n'
      'slug: ${attributes?.slug ?? 'UNKNOWN'}'
  ;
}

/*
  final String? slug; // хз
  final String? category; // категория
  final String? creator; // создатель
  final String? effect; // воздействие
  final String? hand; // взмах
  final String? image; // картинка
  final String? incantation; // произношение
  final String? light; // цвет
  final String? name; // название
  final String? wiki; // ссылка на вики
 */