package com.alterdekim.game.component.game;

import com.alterdekim.game.entity.Good;
import com.alterdekim.game.service.GoodsService;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

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

@Slf4j
@RequiredArgsConstructor
@Getter
public enum AvatarInventoryType {
    Clothes_(1),
    Caps(4),
    Glasses(14),
    Boots(32),
    Bangles(36),
    Suits(40),
    Magic(64),
    Backgrounds(41),
    Phones(-4),
    Smile(-5),
    House(34),
    HouseFurniture(20),
    Club(58),
    ClubFacade(63),
    ClubShow(78),
    ClubFurniture(59),
    ClubInstruments(105),
    ClubDigitalStuff(68),
    ClubFloor(61),
    ClubWallpaper(62),
    ClubGames(107),
    ClubFood(67),
    ClubBeverages(66),
    ClubDeserts(65),
    Achievements(-1),
    BodyParts(-2),
    Unknown(-3);

    private final Integer goodType;

    public static AvatarInventoryType fromGoodType(int goodType) {
        for( AvatarInventoryType t : values() ) {
            if( goodType == t.goodType ) return t;
        }
        return Unknown;
    }

    public static AvatarInventoryType fromGoodId(GoodsService goodsService, long goodId) {
        Integer goodType = goodsService.findById(goodId).map(Good::getGoodTypeId).orElse(-3);
        return fromGoodType(goodType);
    }
}
