<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace loyalsoft;

class GuideProc {

    /**
     * 2.启灵硬引导  隐藏关战斗结算后【启灵功能解锁然后 触发引导】	
     * @param type $arg1
     * @param type $arg2
     */
    public static function Qingling_EquipWear_Guide_Trigger($funId) {
//        $mo = GameConfig::guide_getItem(E_GuideTypeState::HeroChange_Guide, 0);
//        $paras0Str = explode(',',$mo->paras0);

        if ($funId == 16 && !in_array(E_GuideTypeState::Qingling_Guide, ctx()->privateData(true)->funUnlockRecord_3)) {
            ctx()->privateData(true)->funUnlockRecord_3[] = E_GuideTypeState::Qingling_Guide;
        }

        if ($funId == 14 && !in_array(E_GuideTypeState::EquipWear_Guide, ctx()->privateData(true)->funUnlockRecord_3)) {
            ctx()->privateData(true)->funUnlockRecord_3[] = E_GuideTypeState::EquipWear_Guide;
        }
    }

    /**
     * 3.坊市硬引导   触发条件为 启灵第一个解锁
     * @param type $arg1
     * @param type $arg2
     */
    public static function Shop_Guide_Trigger($evolveMaxId_left) {
        if ($evolveMaxId_left == 1 && !in_array(E_GuideTypeState::Shop_Guide, ctx()->privateData(true)->funUnlockRecord_3)) {
            ctx()->privateData(true)->funUnlockRecord_3[] = E_GuideTypeState::Shop_Guide;
        }
    }  

    /**
     * 5.强制进入第一关硬引导 触发条件为“玩家穿戴了首件装备” 实际触发的位置是 穿戴的硬引导一完成就出发 这里写死了
     * @param type $arg1
     * @param type $arg2
     */
    public static function GateFight_Guide_Trigger() {
        $arr = StlUtil::dictToArray(ctx()->store->equipLocation); 
        if(ctx()->baseInfo->guide_type == E_GuideTypeState::Shop_Guide && count($arr) == 1 && !in_array(E_GuideTypeState::GateFight_Guide, ctx()->privateData(true)->funUnlockRecord_3)){
            ctx()->privateData(true)->funUnlockRecord_3[] = E_GuideTypeState::GateFight_Guide;
            
        }
        
//        if ($guideType == E_GuideTypeState::EquipWear_Guide && $guide_type_forceSave == true && !in_array(E_GuideTypeState::GateFight_Guide, ctx()->privateData(true)->funUnlockRecord_3)) {
//            ctx()->privateData(true)->funUnlockRecord_3[] = E_GuideTypeState::GateFight_Guide;
//        }
    }

    /**
     * 6. 领取新手任务奖励硬引导  触发条件为“玩家进入1次第一关”
     * @param type $arg1
     * @param type $arg2
     */
    public static function MainTaskRewardReceived_Guide_Trigger($gateId, $fightNum) {
        $mo = GameConfig::guide_getItem(E_GuideTypeState::MainTaskRewardReceived_Guide, 0);
        $paras0 = $mo->paras0;
        if ($paras0 == $gateId && $fightNum == 1) {
            ctx()->privateData(true)->funUnlockRecord_3[] = E_GuideTypeState::MainTaskRewardReceived_Guide;
        }
    }

    /**
     * 7.装备升级硬引导 [触发条件 首次获得图纸] 实际的触发校验是 直接判定的那个新手任务的id
     * @param type $arg1
     * @param type $arg2
     */
    public static function EquipLvUp_Guide_Trigger($taskId) {
        $mo = GameConfig::guide_getItem(E_GuideTypeState::EquipLvUp_Guide, 0);
        $paras0 = $mo->paras0;
        if ($paras0 == $taskId) {
            ctx()->privateData(true)->funUnlockRecord_3[] = E_GuideTypeState::EquipLvUp_Guide;
        }
    }

    /**
     * 8 领取第二关第3个章节宝箱硬引导[触发条件为“玩家初次通关第二关”]
     * @param type $arg1
     * @param type $arg2
     */
    public static function GateBoxReceived_Guide_Trigger($gateId, $pass) {
        $mo = GameConfig::guide_getItem(E_GuideTypeState::GateBoxReceived_Guide, 0);
        $paras0 = $mo->paras0;
        if ($paras0 == $gateId && ctx()->gates->GateList->$gateId->pass == 0 && $pass == 1) {
            ctx()->privateData(true)->funUnlockRecord_3[] = E_GuideTypeState::GateBoxReceived_Guide;
        }
    }

    /**
     * 9 角色更换与升星硬引导   触发条件为“玩家领取了第二关第3个章节宝箱”
     * @param type $arg1
     * @param type $arg2
     */
    public static function HeroChange_Guide_Trigger($gateId, $boxIndex) {
        $mo = GameConfig::guide_getItem(E_GuideTypeState::HeroChange_Guide, 0);
        $paras0Str = explode(',', $mo->paras0);

        if ($paras0Str[0] == $gateId && $paras0Str[1] == $boxIndex) {
            ctx()->privateData(true)->funUnlockRecord_3[] = E_GuideTypeState::HeroChange_Guide;
        }
    }

}
