package com.zanxiang.game.data.serve.pojo.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * @author : tianhua
 * @time : 2022-09-07
 * @description : 游戏应用类型
 */
@Getter
@AllArgsConstructor
public enum GameCategoryEnum {

    /**
     * 微信小游戏
     */
    CATEGORY_WX_APPLET(6L, "wx_applet", "微信小游戏"),

    /**
     * h5游戏
     */
    CATEGORY_H5(5L, "h5", "h5游戏"),

    /**
     * IOSApp游戏
     */
    CATEGORY_IOS_APP(4L, "ios_app", "IOS APP"),

    /**
     * AndroidApp游戏
     */
    CATEGORY_ANDROID_APP(3L, "android_app", "Android APP"),

    /**
     * 抖音小游戏
     */
    CATEGORY_DY_APPLET(2L, "byte_applet", "抖音小游戏"),

    /**
     * APP
     */
    CATEGORY_APP(1L, "app", "APP");

    /**
     * 应用id
     */
    private Long id;

    /**
     * 游戏分类key
     */
    private String categoryKey;

    /**
     * 描述
     */
    private String name;

    /**
     * 被分类名字
     *
     * @param category 类别
     * @return {@link String}
     */
    public static String getNameByCategory(Long category) {
        GameCategoryEnum gameCategory = GameCategoryEnum.getGameCategory(category);
        return gameCategory == null ? null : gameCategory.getName();
    }

    /**
     * 获取游戏分类
     *
     * @param category 类别
     * @return {@link String}
     */
    public static GameCategoryEnum getGameCategory(Long category) {
        for (GameCategoryEnum gameCategoryEnum : GameCategoryEnum.values()) {
            if (Objects.equals(gameCategoryEnum.getId(), category)) {
                return gameCategoryEnum;
            }
        }
        return null;
    }
}
