<?php

namespace loyalsoft;

/**
 * Description of Info_NewMap
 * 玩家地图数据
 * @author gwang
 * @version
 *        2022.3.11 改版 据点 >> 大地图 >> 世界地图模式
 */
class Info_NewMap extends Object_ext {

    /**
     * 当前所在地图的id
     * @var type
     */
    public $curMapId;

    /**
     * 已解锁据点列表
     * @var dic< 据点id, Ins_FootHold >
     */
    public $unlockedFootholds;

    /**
     * 已经解锁的地图上的区域、npc、道具等等信息
     * @var type
     */
    public $unlockMapTypeList;

    /**
     * 回城券使用的传送阵记录
     * @var type
     */
    public $huichengquanRecord = null;

    /**
     * 当前地图所在区里面的传送门目的地的mapid
     * 回城券=>从当前地图回据点
     * 传送门=>从据点回到回城前的地图
     * @var type
     */
    public $lastMapId = 0;

    /**
     * 当前据点id
     * @var type
     */
    public $curFootholdId = 0;

    function __construct($arg = null) {
        if (null === $arg) {
            // 直接初始化8个大陆的基本数据
            $initMapid = 503099;                                                # 新手村的id
            $this->lastMapId = $initMapid;
            $this->curMapId = $initMapid;                                       # 当前位置为新手村
            $this->curFootholdId = $initMapid;                                      # 当前据点id
            $this->unlockedFootholds = ObjectInit();

            $gateZonemo = GameConfig::gate_zone_getItem(501007);
            if ($gateZonemo != null) {
                $list = explode(',', $gateZonemo->contains);
                foreach ($list as $id) {
                    $mo = GameConfig::gate_getItem($id);
                    $footHold = new Ins_FootHold();
                    $footHold->mapId = $mo->gateId;
                    $footHold->curMapType = $mo->mapType;
                    if ($id == $initMapid) {
                        $footHold->unlocked = 1;
                        $footHold->transmissionIsOk = true;
                    }
                    $this->unlockedFootholds->$id = $footHold;
                }
            }



//            $mo = GameConfig::gate_getItem($initMapid);
//            $footHold = new Ins_FootHold();
//            $footHold->mapId = $mo->gateId;
//            $footHold->curMapType = $mo->mapType;
//            $this->unlockedFootholds->$initMapid = $footHold;                   # 初始化解锁新手村据点数据
            #
            // 把2号据点也解锁
//            $initMapid = 503100;                                                  # 新手村的id
//            // $this->curMapId = $initMapid;                                       # 当前位置为新手村
//            // $this->unlockedFootholds = ObjectInit();
//            $mo = GameConfig::gate_getItem($initMapid);
//            $footHold = new Ins_FootHold();
//            $footHold->mapId = $mo->gateId;
//            $footHold->curMapType = $mo->mapType;
//            $this->unlockedFootholds->$initMapid = $footHold;                   # 初始化解锁新手村据点数据
//
//            $dixiachengId = 503001;
//            $mo = GameConfig::gate_getItem($dixiachengId);
//            $footHold = new Ins_FootHold();
//            $footHold->mapId = $mo->gateId;
//            $footHold->curMapType = $mo->mapType;
//            $this->unlockedFootholds->$dixiachengId = $footHold;
//
//            $dixiachengId = 503002;
//            $mo = GameConfig::gate_getItem($dixiachengId);
//            $footHold = new Ins_FootHold();
//            $footHold->mapId = $mo->gateId;
//            $footHold->curMapType = $mo->mapType;
//            $this->unlockedFootholds->$dixiachengId = $footHold;

            $this->unlockMapTypeList = ObjectInit();                            #初始化--已经解锁的地图上的区域、npc、道具等等信息
            $unlockStr = "503099_2_1011_". now();
            $this->unlockMapTypeList->$initMapid[] = $unlockStr;
            
            $this->huichengquanRecord = ObjectInit();                                #
        } else {
            parent::__construct($arg);
        }
    }

}
