<?php

namespace loyalsoft;

require_once __DIR__ . '/FightProc/SweepGatesProc.php';
require_once __DIR__ . '/FightProc/PVPProc.php';

/**
 * 战斗业务逻辑分发
 * @author gwang
 */
class FightProc {

    /**
     * 战斗逻辑分发
     * 所有的Proc中必须有这样一个方法
     */
    static function procMain() {
        switch (req()->cmd) {
            # 关卡-征战
            case CmdCode::cmd_fight_arenas_preFight:                            # 6800 关卡挑战 - 预先计算掉落
                return SweepGatesProc::Arenas_preFight();
            case CmdCode::cmd_fight_arenasfight:                                # 6801 挑战关卡
                return SweepGatesProc::Arenas_Fight();
            case CmdCode::cmd_fight_arenassweep:                                # [6802] 扫荡
                Err(ErrCode::function_notopen_msg);                             # 暂未开放扫荡功能. -gwang 2020.4.20
                return SweepGatesProc::Arenas_NewSweepFight();

            case CmdCode::cmd_fight_GetArenasActiveReward:                      # 6806 领取章节星级奖励
                return SweepGatesProc::DrawChapterStarsReward();

            // <editor-fold defaultstate="collapsed" desc="    玩家挑战    "> 
            case CmdCode::cmd_fight_GetChallengeAdversaryInfo:                  # 6803 获取挑战对手的信息
                return PVPProc::GetChallengeAdversaryInfo();
            case CmdCode::cmd_fight_LogChallengeResult:                         # 6804 记录挑战结果
                return PVPProc::LogChallengeInfo();
            case CmdCode::cmd_fight_GetChallengeLog:                            # 6805 拉取挑战记录
                return PVPProc::GetChagllengeLog();

// </editor-fold>
            //  <editor-fold defaultstate="collapsed" desc="   PVP 模块 681x ">
            case CmdCode::cmd_fight_pvp_maininfo:                               # [6810] 竞技场 主界面拉取信息
                return PVPProc::pvpMainInfo();
            case CmdCode::cmd_fight_pvp_refresh:                                # [6811] 竞技场 刷新对手列表
                return PVPProc::pvp_Refresh();
            case CmdCode::cmd_fight_pvp_pk:                                     # [6812] 竞技场 挑战对手
                return PVPProc::pvp_PK();
            case CmdCode::cmd_fight_pvp_setTeam:                                # [6813] 竞技场 设定防守队伍
                return PVPProc::pvp_setTeam();
            case CmdCode::cmd_fight_pvp_buyTicket:                              # [6814] 竞技场 购买挑战票
                return PVPProc::pvp_buyticket();
            case CmdCode::cmd_fight_pvp_getrank:                                # [6815] 竞技场 查看排行榜
                return PVPProc::pvp_getRank();
            case CmdCode::cmd_fight_pvp_getLog:                                 # [6816] 竞技场 查看挑战记录
                return PVPProc::pvp_getFightLogs();
// </editor-fold>
            // <editor-fold defaultstate="collapsed" desc="   竞技商店 682x  ">
            case CmdCode::cmd_fight_pvpShop_getMainInfo:                        # [6820] 竞技场 竞技商店主界面
                return PVPProc::pvpShopMain();
            case CmdCode::cmd_fight_pvpShop_buy:                                # [6821] 竞技场 竞技商店购买道具
                return PVPProc::pvpShopBuy();
            case CmdCode::cmd_fight_pvpShop_refresh:                            # [6822] 竞技场 竞技商店刷新道具(扣钻)
                return PVPProc::pvpShopRefresh();
            // </editor-fold>
            default:
                return Resp::err(ErrCode::cmd_err);
        }
    }

    /**
     * 清理每日字段
     */
    static function ClearByDay() {
        SweepGatesProc::ClearGateTimes();                                        # 清理每个难度副本的每日战斗次数 
        $pvp = new Info_UserPVP(req()->userInfo->game->pvp);
        $pvp->refreshDailyData();
        $pvp->sendRewardEmail(req()->zoneid, req()->uid, PVPProc::GetCurSeasonID());
        req()->userInfo->game->pvp = $pvp;
    }

}
