<?php

namespace loyalsoft;

/**
 * Description of Info_PrivateState
 * 私有状态标志字
 */
class Info_PrivateState extends Object_ext {
// ------------字段声明-------------

    /**
     * @var int 武器/言灵的uid,递增
     */
    public $currentId = 0;

    /**
     *
     * @var int 物品的背包格子的上限 目前和李宁协商的结果是:抽奖可以超上限,物品合成可以超上限,任务奖励可以超上限,只有战斗时候会有限制超过上限,如果继续战斗的话,战斗的奖励品将不会获取.
     */
    public $maxItemNum = 100;

    /**
     *
     * @var int 物品背包格子的数量.
     */
    public $ItemNum = 0;

    /**
     * 上次获取体力的时间戳
     * @var int
     */
    public $TiliTime;

    /**
     * 登录天数
     * @var array[12345,12347,...]
     */
    #[ArrayType]
    public $LoginDays = array();

    /**
     * @var array[1,2,3,4,5,6,7] 7日签到领取数据
     */
    #[ArrayType]
    public $day7_drawed = array();

    /**
     * @var array 兑换码使用记录
     */
    #[ArrayType]
    public $usedTokens = array();

    /**
     * @var int 在线礼包累计时长
     */
    public $onlineGiftts = 0;

    /**
     * @var [int] 当前在线礼包ID(每天清空)
     */
    #[ArrayType]
    public $onlineGiftIDs = array();

    /**
     * @var array 全服注册礼包领取记录
     */
    #[ArrayType]
    public $drawedRegGift = array();

    /**
     * @var boolean 首付礼包是否领取
     */
    public $firstPayGift = false;

    /**
     * @var array 每日领取的体力奖励记录
     */
    #[ArrayType]
    public $dailyDrawedTiliGift = array();

    /**
     * 排行榜, 战力突破奖领取记录
     * @var array
     */
    #[ArrayType]
    public $RankFpowerRewardRec = array();

    /**
     * 排行榜, 通关记录突破奖励领取记录----改成了玩家等级榜
     * @var type
     */
    #[ArrayType]
    public $RankPassGateRewardRec = array();

    /**
     * @var int 上次检查被挑战记录的时间戳
     */
    public $lastCheckDefLog_ts = 0;

    /**
     * 角标通知缓存
     * @var array[int]
     */
    #[ArrayType]
    public $cornerSignNotifications = array();

    /**
     * 已解锁建筑
     * @var array[int]
     */
    #[ArrayType]
    public $unlockedBuild = array();

    /**
     * 已经解锁得npc
     * @var type
     */
    #[ArrayType]
    public $unlockNpc = array();

    /**
     * @var int 无尽塔的当前进度
     */
    public $endlessTower = 1;

    /**
     * @var int[] 无尽塔的特殊奖励领取记录, 只增不减
     */
    #[ArrayType]
    public $endlessTower_rewarded = array();

    /**
     * @var stdClass 材料副本每日挑战记录
     */
    public $materialDailyChallengeRecord;

    /**
     * @var stdClass 任务卡追踪信息 { "1":2345,"2":0,"3":0,"4":0 }
     */
    public $taskCardTracing;

    /**
     * 背包扩容次数
     * @var type
     */
    public $expandNum = 0;

    /**
     * 每日购买体力次数记录，每日重置
     */
    public $buyTiliNum = 0;

    /**
     * 任务兼容处理索引
     * @var type
     */
    public $taskJianRong_index = 0;

    /**
     * 原地复活次数
     */
    public $battleReviveNum = 0;

    /**
     * 在线礼包领取时间记录
     * @var type
     */
    public $onlineGiftClearTs = 0;

    /**
     * 出生点
     * @var type
     */
    public $bornPlace = 0;

    /**
     * 悬赏任务完成个数记录
     * @var type
     */
    public $shopTaskCompleteNum = 0;
    public $tiliRecord = 0;

    /**
     * 每天累计时间，每日重置
     * @var type
     */
    public $onlineTs = 0;

    /**
     * 删档测试处理字段
     * @var type
     */
    public $deltest = 1;

    /**
     * 已领取的等级奖励礼包id
     * @var array
     */
    #[ArrayType]
    public $gettedLevelGiftIds = array();

// <editor-fold defaultstate="collapsed" desc="    初始化    ">

    /**
     * 玩家注册时初始化, 用于给各个字段赋默认初始值
     */
    public function initialize() {
        $this->maxItemNum = GameConfig::primordial_data()->User_Private_MaxItem_num; # Ps.默认100;
        $this->TiliTime = now();
        my_default_Obj($this->taskCardTracing);
    }

    public function fixArray() {

        $class = new \ReflectionClass(__CLASS__);                               # 建立这个类的反射对象
        $properties = $class->getProperties();                                  # 拉取所有静态属性

        foreach ($properties as $p) {
            isEditor() and $p = new \ReflectionProperty();
            $attrs = $p->getAttributes("loyalsoft\ArrayType");
            if (count($attrs) > 0) {
                $v = self::ConsureArr($p->getValue($this));
                $p->setValue($this, $v);
            }
        }

//        $this->LoginDays = self::ConsureArr($this->LoginDays);
//        $this->day7_drawed = self::ConsureArr($this->day7_drawed);
//        $this->RankFpowerRewardRec = self::ConsureArr($this->RankFpowerRewardRec);
//        $this->RankPassGateRewardRec = self::ConsureArr($this->RankPassGateRewardRec);
//        $this->onlineGiftIDs = self::ConsureArr($this->onlineGiftIDs);
//        $this->unlockedBuild = self::ConsureArr($this->unlockedBuild);
//        $this->unlockNpc = self::ConsureArr($this->unlockNpc);
//        $this->cornerSignNotifications = self::ConsureArr($this->cornerSignNotifications);
//        $this->endlessTower_rewarded = self::ConsureArr($this->endlessTower_rewarded);
    }

    private static function ConsureArr($mix) {
        if (is_array($mix)) {
            return $mix;
        }
        return (array) $mix;
    }

    /**
     * 添加已经解锁得npc
     * @param type $npcId
     */
    public function addUnlockNpc($npcId) {
        if (!in_array($npcId, $this->unlockNpc)) {
            $this->unlockNpc[] = $npcId;
        }
    }

// </editor-fold>
}
