<?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;

/**
 * Description of Info_ShenMiao
 *
 * @author cyzhao
 */
class Info_ShenMiao extends Object_ext {
    
    /**
     * 玩家新手阶段，抽奖次数
     * @var type
     */
    //public $num = 0;

    /**
     * 活动信息
     * @var type
     */
    public $activeDic = null;

    /**
     * 构造函数
     * @param type $args
     */
    public function __construct($args = null) {    
        if($args == null){
            $this->activeDic = new stdClass();
        } else {
            parent::__construct($args);   
        }                    
    }
    
    public function initialize() {
        //$this->initActiveItem();//创建账号 初始化活动信息
    }
    
    /**
     * 初始化活动信息
     */
    public function initActiveItem() { 
        $nowTs = time();
        
        $enum = new Enum_Active();
        $list = array_values($enum->getConstList());
        foreach ($list as $type) {
            if(StlUtil::dictHasProperty($this->activeDic, $type)){
                if($type == Enum_Active::NewWish){
                    if($this->activeDic->$type->totalNum >= glc()->UserWishNumLimit){
                        StlUtil::dictRemove($this->activeDic, $type);
                        StlUtil::dictPropertyRandom($dict);
                    }
                } else if($type > Enum_Active::HuanlingshiActive){//检测时间是否过期
                    $shenmiaoMo = \GameConfig::shenmiao_getItem($this->activeDic->$type->id);
                    if($shenmiaoMo->startTs >= $nowTs || $nowTs > $shenmiaoMo->endTs){
                        $list = \GameConfig::shenmiaoTypeList_getItemArray($type);
                        foreach ($list as $val) {                 
                            if($val->startTs <=$nowTs && $nowTs<= $val->endTs){
                                $item = new Ins_active();
                                $item->id = $item->id;         
                                $aDic->$type = $item;
                            }                
                        }
                    }                                     
                }
            } else {
                if($type == Enum_Active::NewWish || $type == Enum_Active::OpenWish){                            
                    $dic = \GameConfig::shenmiaoTypeList_getItemArray($type)[0];      
                    $item = new Ins_active();
                    $item->id = $dic->id;         
                    $aDic->$type = $item;
                }else {
                    $list = \GameConfig::shenmiaoTypeList_getItemArray($type);
                    foreach ($list as $val) {                 
                        if($val->startTs <=$nowTs && $nowTs<= $val->endTs){
                            $item = new Ins_active();
                            $item->id = $item->id;         
                            $aDic->$type = $item;
                        }                
                    }
                }
            }                                 
        }
    }
    
    /**
     * 新手 常驻
     * @param type $type
     */
    public function createRegularActiveData($type) {
        
    }
    /**
     * 不定期
     * @param type $type
     */
    public function createLrregularActiveData($type) {
        
    }
    
}
