import { GanHaiRed } from './api_s2c/ganhai/ApiOpen';
import { FriendManage } from './public/friend/manage';
import { GHManage } from './public/gonghui/manage';
import { JJCFun } from './public/jjc';
import { RankClslCross, RankClslCrossInit } from './public/rank/rank_clsl';
//import { RankHbzbJfsCross, RankHbzbJfsLocal, RankHbzbZbsCross } from './public/rank/rank_hbzb_jfs';
import { RankKbzz } from './public/rank/rank_kbzz';
import { RankPower } from './public/rank/rank_power';
import { RankQjzzd } from './public/rank/rank_qjzzd';
import { RankSlzd1, RankSlzd2, RankSlzd3, RankSlzd4, RankSlzd5, RankSlzd6 } from './public/rank/rank_slzd';
import { RankTanXian } from './public/rank/rank_tanxian';
import { RankTujian } from './public/rank/rank_tujian';
import { RankWzryCross } from './public/rank/rank_wzry';
import { RankXszm } from './public/rank/rank_xszm';
import { RankZccg } from './public/rank/rank_zccg';
import { SchedulerClslCrossCtor, SchedulerClslLocalCtor, SchedulerClslPrize } from './public/scheduler/scheduler_clsl';
import {  Scheduler_hbzb_jfs_local_prize, Scheduler_hbzb_local_reset, Scheduler_hbzb_zbs_cross_clear, Scheduler_hbzb_zbs_cross_group, Scheduler_hbzb_zbs_local_prize, Scheduler_hbzb_zbs_local_ready } from './public/scheduler/scheduler_hbzb';
import { SchedulerJJC } from './public/scheduler/scheduler_jjc';
import { SchedulerKbzzAutoApply, SchedulerKbzzGroup } from './public/scheduler/scheduler_kbzz';
import { SchedulerQjzzd } from './public/scheduler/scheduler_qjzzd';
import { SchedulerSlzdClean, SchedulerSlzdPrize } from './public/scheduler/scheduler_slzd';
import { SchedulerWzryAutoBaoMing, SchedulerWzryDlDjinji, SchedulerWzryDlDstart, SchedulerWzryWangZhefour, SchedulerWzryWangZheone, SchedulerWzryWangZhethree, SchedulerWzryWangZhetwo, SchedulerWzryWangzheSendPrize, SchedulerWzryWangzheWZZD, SchedulerWzryZuanshi16to8, SchedulerWzryZuanshiOne, SchedulerWzryZuanshiSendPrize, SchedulerWzryZuanshiThree, SchedulerWzryZuanshiTwo, SchedulerWzryZuanshifour, SchedulerWzryendDel, SchedulerWzryjingcaiSendPrize } from './public/scheduler/scheduler_wzry';
// import { SchedulerWzryAutoBaoMing } from './public/scheduler/scheduler_wzry';
import { SchedulerZhanLing } from './public/scheduler/scheduler_zhanling';
import {SchedulerNewDayLocalCtor} from "./public/scheduler/scheduler_newDay";
import { clusterRunOnce } from './clusterUtils';
import { addListener } from './globalListener';
import { SchedulerManage } from './public/scheduler/scheduler';
import {CrossEmailPull} from "./public/scheduler/scheduler_cross_email_pull";
import {Scheduler_xfjs_Local_Ctor} from "./public/scheduler/scheduler_xiaofeijingsai";
import { RankKfjs_1, RankKfjs_2, RankKfjs_3, RankKfjs_4, RankKfjs_5, RankKfjs_6, RankKfjs_7 } from './public/rank/rank_kfjs';
import { WatchDog } from './public/scheduler/scheduler_watchdog';
export async function startAfter() {
    
    //事件监听和定时器初始化
    addListener();  
    SchedulerManage.start();
    clusterRunOnce(()=>{
        //非pm2启动的，或是pm2下启动的第一个进程
        SchedulerManage.onlyPm2();
    });

    SchedulerManage.allPm2()
    
    if (G.argv.serverType == 'msg') {
        JJCFun.init();
        GHManage.init();
        FriendManage.init();

        new RankXszm();
        new RankPower();
        new RankQjzzd();
        //new RankHbzbJfsLocal();
        new RankTanXian();

        new RankSlzd1();
        new RankSlzd2();
        new RankSlzd3();
        new RankSlzd4();
        new RankSlzd5();
        new RankSlzd6();

        new RankKfjs_1();
        new RankKfjs_2();
        new RankKfjs_3();
        new RankKfjs_4();
        new RankKfjs_5();
        new RankKfjs_6();
        new RankKfjs_7();

        new RankZccg();
        new RankTujian();

        clusterRunOnce(()=>{
            //只执行一次
            new SchedulerJJC().init();
            new SchedulerQjzzd().init();
            new SchedulerZhanLing().init();
            new Scheduler_hbzb_local_reset().init();
            new Scheduler_hbzb_jfs_local_prize().init();
            new Scheduler_hbzb_zbs_local_prize().init();
            new Scheduler_hbzb_zbs_local_ready().init();
            new SchedulerKbzzAutoApply().init();
            new Scheduler_xfjs_Local_Ctor().init();

            new SchedulerSlzdClean().init();
            new SchedulerSlzdPrize().init();

            new SchedulerClslPrize().init();
            new SchedulerClslLocalCtor().init();
            new SchedulerWzryAutoBaoMing().init();
            new SchedulerWzryjingcaiSendPrize().init();
            new SchedulerWzryendDel().init();
            // new SchedulerWzrycrossEmail();

            new CrossEmailPull().init()
            new WatchDog().init();
        });
        new SchedulerNewDayLocalCtor().init();

        GanHaiRed.init();

        G.mongodb.find('user',{},['uid']).then(arr => {
            // 在线用户，循环写入redis
            arr.forEach(async u => G.redis.hSet('player:uids', u.uid, 1))
        });

    } else if (G.argv.serverType == 'cross') {
        RankKbzz.init();
        RankClslCrossInit();
        new RankWzryCross();

        new SchedulerKbzzGroup().init();

        new SchedulerClslPrize().init();
        new SchedulerClslCrossCtor().init();
        new SchedulerClslLocalCtor ().init();

        new Scheduler_hbzb_zbs_cross_clear().init();
        new Scheduler_hbzb_zbs_cross_group().init();
        
        new SchedulerWzryDlDstart().init();
        new SchedulerWzryDlDjinji().init();
        new SchedulerWzryZuanshiOne().init();
        new SchedulerWzryZuanshiTwo().init();
        new SchedulerWzryZuanshiThree().init();
        new SchedulerWzryZuanshifour().init();
        new SchedulerWzryZuanshi16to8().init();
        new SchedulerWzryZuanshiSendPrize().init();
        new SchedulerWzryWangZheone().init();
        new SchedulerWzryWangZhetwo().init();
        new SchedulerWzryWangZhethree().init();
        new SchedulerWzryWangZhefour().init();
        new SchedulerWzryWangzheSendPrize().init();
        new SchedulerWzryWangzheWZZD().init();
    }
}