<?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_Heros
 *
 * @author c'y'zhao
 */
class Info_Heros extends Object_ext {

    /**
     * 当前的hero
     */
    public $CurrentHeroId = 0;

    /**
     * 所有的hero集合
     * @var type
     */
    public $Dic = null;

    public function initialize() {
        $heroConf = GameConfig::hero();
        foreach ($heroConf as $heroId => $mo) {
            if (!StlUtil::dictHasProperty($this->Dic, $heroId) && $mo->starLv == 1) {
                $insHero = new Ins_Hero();
                $insHero->Id = $heroId;
                $insHero->isUnlock = 0;
                if ($mo->heroDebris_need == null) {                   
                    $insHero->isUnlock = 1;
                    if($this->CurrentHeroId == 0){
                        $this->CurrentHeroId = $heroId;
                    }                   
                }
                $this->Dic->$heroId = $insHero;
            }
        }


//        
//        foreach ($heroConf as $heroId => $mo) {
//            if(!StlUtil::dictHasProperty($this->Dic, $heroId) ){
//                $insHero = new Ins_Hero();
//                $insHero->Id = $heroId;
//                $insHero->isUnlock = 0;
//                if($heroId == 1 || $heroId == 2){
//                    $insHero->isUnlock = 1;
//                }
//                
//                $this->Dic->$heroId = $insHero;
//            }
//            
//        }
//        
//        if($this->CurrentHeroId == 0){
//            $this->CurrentHeroId = 1;
//        }
//        $curHeroId = 1; //临时
//        $this->CurrentHeroId = $curHeroId;
//        $this->Dic = new \stdClass();
//        $insHero = new Ins_Hero();
//        $insHero->Id = $curHeroId;
//        $this->Dic->$curHeroId = $insHero;
//        $id2 = 2;
//        $ins2 = new Ins_Hero();
//        $ins2->Id = 2;
//        $this->Dic->$id2 = $ins2;
    }

    public function __construct($arg = null) {
        if ($arg == null) {
            $this->Dic = new \stdClass();
//            if ($this->CurrentHeroId == 0) {
//                $curHeroId = 1; //临时
//                $this->CurrentHeroId = $curHeroId;
//                $this->Dic = new \stdClass();
//                $insHero = new Ins_Hero();
//                $insHero->Id = $curHeroId;
//                $this->Dic->$curHeroId = $insHero;
//            }
        } else {
            parent::__construct($arg);
        }
    }

}
