package com.fshark.overseas.advert.modle;

import com.fshark.overseas.advert.util.Constants;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author zhouml [zhouml@kingnet.com]
 * @date 2019-03-01
 */
public enum EventTypeEnum {

    /*
        第一次创角作为注册
    */
//    REGISTER("createrole"),
    CREATE_ROLE("createrole"),
    SDK_ACTIVATION("activation"),
    SDK_REGISTER("register"),
    FAST_LOGIN("fast login"),
    GAME_LOGIN("gamelogin"),
    ROLE_LOGIN("rolelogin"),
    LOGIN("login"),
    ACTIVATION("install"),
    PURCHASE("af_purchase"),
    RE_ENGAGEMENT("re-engagement"),
    RE_ATTRIBUTION("re-attribution"),
    HEARTBEAT("heartbeat"),
    LV_2("lv 2");

    private String name;

    EventTypeEnum(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public static List<String> getEvents() {
        return Arrays.stream(values()).map(EventTypeEnum::getName).distinct().collect(Collectors.toList());
    }

    public static boolean sdkEvent(AppsFlyerEvent event){
        return (SDK_REGISTER.getName().equals(event.getEvent())) && !event.getUid().equals(Constants.DEFAULT_FIELD_VALUE);
    }

    public static boolean roleLoginEvent(AppsFlyerEvent event) {
        return (ROLE_LOGIN.getName().equals(event.getEvent())
                || CREATE_ROLE.getName().equals(event.getEvent())) && !event.getUid().equals(Constants.DEFAULT_FIELD_VALUE);
    }

    public static boolean createRoleEvent(AppsFlyerEvent event) {
        return CREATE_ROLE.getName().equals(event.getEvent()) && !event.getUid().equals(Constants.DEFAULT_FIELD_VALUE);
    }


    public static boolean roleEvent(AppsFlyerEvent event) {
        return (CREATE_ROLE.getName().equals(event.getEvent()) || ROLE_LOGIN.getName().equals(event.getEvent())) && !event.getUid().equals(Constants.DEFAULT_FIELD_VALUE);
    }


    public static boolean installEvent(AppsFlyerEvent event) {
        return (ACTIVATION.getName().equals(event.getEvent()) || RE_ENGAGEMENT.getName().equals(event.getEvent()) || RE_ATTRIBUTION.getName().equals(event.getEvent()))&& !event.getUid().equals(Constants.DEFAULT_FIELD_VALUE);
    }

    public static boolean orderEvent(AppsFlyerEvent event) {
        return PURCHASE.getName().equals(event.getEvent()) && !event.getUid().equals(Constants.DEFAULT_FIELD_VALUE);
    }

    public static boolean loginEvent(AppsFlyerEvent event) {
        return LOGIN.getName().equals(event.getEvent());
    }

    public static boolean notHeartBeatEvent(AppsFlyerEvent event) {
        return !HEARTBEAT.getName().equals(event.getEvent()) && !event.getUid().equals(Constants.DEFAULT_FIELD_VALUE);
    }

}
