package com.ff.base.enums;


import java.util.Optional;
import java.util.stream.Stream;


/**
 * xkgame类型
 *
 * @author shi
 * @date 2024/11/13
 */
public enum XKGameType {

    ELECTRON(1, 1L,"电子"),
    CHESS(2, 2L,"棋牌"),
    GAME_HALL(3, 3L,"游戏大厅"),
    CATCH_FISH(5, 4L,"捕鱼"),
    MACHINE(8, 5L,"押分机 (含宾果)")

    ;

    private final Integer code;
    private final Long systemCode;
    private final String info;
    XKGameType(Integer code, Long systemCode, String info)
    {
        this.code = code;
        this.systemCode = systemCode;
        this.info = info;
    }

    public Integer getCode()
    {
        return code;
    }

    public Long getSystemCode()
    {
        return systemCode;
    }
    public String getInfo()
    {
        return info;
    }
    /**
     * 按代码查找系统
     *
     * @param code 代码
     * @return {@link String }
     */
    public static Long findSystemByCode(Integer code) {
        Optional<Long> system = Stream.of(XKGameType.values())
                .filter(gameType -> gameType.getCode().equals(code))
                .map(XKGameType::getSystemCode)
                .findFirst();
        return system.orElse(null);
    }

    /**
     * 按代码查找信息
     *
     * @param code 代码
     * @return {@link String }
     */
    public static String findInfoByCode(Integer code) {
        Optional<String> system = Stream.of(XKGameType.values())
                .filter(gameType -> gameType.getCode().equals(code))
                .map(XKGameType::getInfo)
                .findFirst();
        return system.orElse(null);
    }
}
