package com.caliverse.admin.domain.datacomponent;
import com.caliverse.admin.domain.entity.metadata.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
import java.util.Optional;

@Slf4j
@Service
public class MetaDataHandler {

    @Autowired private MetaDataFileLoader metadataFileLoader;

    @Autowired
    public MetaDataHandler(MetaDataFileLoader metaDataFileLoader){
        this.metadataFileLoader = metaDataFileLoader;
    }

    public String getTextStringData(String text) {
        return metadataFileLoader.getName(text)
                .map(MetaTextStringData::getKor)
                .orElse("");
    }

    public String getMetaItemNameData(int itemId) {
        return metadataFileLoader.getMetaItem(itemId)
                .map(MetaItemData::getName)
                .orElse("");
    }

    public String getMetaItemLargeTypeData(int itemId) {
        return metadataFileLoader.getMetaItem(itemId)
                .map(MetaItemData::getLargeType)
                .orElse("");
    }

    public String getMetaClothSlotTypeData(int metaId) {
        return metadataFileLoader.getMetaClothType(metaId)
                .map(MetaClothTypeData::getEquipSlotType)
                .orElse("");
    }

    public String getMetaClothSmallTypeData(int metaId) {
        return metadataFileLoader.getMetaClothType(metaId)
                .map(MetaClothTypeData::getSmallType)
                .orElse("");
    }

    public List<MetaQuestData> getMetaQuestData(int questId) {
        return metadataFileLoader.getMetaQuests(questId);
    }

    public MetaBuildingData getMetaBuildingData(int buildingId) {
        return metadataFileLoader.getMetaBuildingItem(buildingId)
                .orElse(null);
    }

    public MetaLandData getMetaLandData(int landId) {
        return metadataFileLoader.getMetaLandItem(landId)
                .orElse(null);
    }

    public List<MetaBuildingData> getMetaBuildingListData() {
        return metadataFileLoader.getMetaBuildings();
    }

    public List<MetaLandData> getMetaLandListData() {
        return metadataFileLoader.getMetaLands();
    }

    public List<MetaBattleConfigData> getMetaBattleConfigsListData() {
        return metadataFileLoader.getMetaBattleConfigs();
    }

    public List<MetaBattleRewardData> getMetaBattleRewardsListData() {
        return metadataFileLoader.getMetaBattleRewards();
    }

    public List<MetaSystemMailData> getMetaSystemMailListData() {
        return metadataFileLoader.getMetaSystemMail();
    }
}

