<?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 Ins_Equip
 *
 * @author c'y'zhao
 */
class Ins_Equip extends Object_ext{
    
    /**
     * 实例唯一编号
     */
    public $uid = 0;       
    
    /*
     * 模板数据编号
     */
    public $typeId = 0;    
    
    /*
     * 等级
     */
    public $level = 1;
    
    /**
     * 宝石槽
     * @var type
     */
    public $gemSetSlot;
    
    /**
     * 品质
     * @var type
     */
    public $qual;

    /**
     * 构造函数
     * @param type $args
     */
    public function __construct($args = null) {
        if($args !=null){
            parent::__construct($args);
        } else {
            $this->gemSetSlot = new \stdClass();
        }                
    }
    
    /**
     * 配置
     * @return sm_gem
     */
    public function mo() {
        $mo = GameConfig::equip_getItem($this->typeId);
        my_Assert(null != $mo, ErrCode::err_const_no);
        return $mo;
    }
    
    public function equipLevelMo() {
        $mo = GameConfig::equip_levelupgrade_getItem($this->mo()->rarity, $this->qual,$this->mo()->position,$this->level);
        my_Assert(null != $mo, ErrCode::err_const_no);
        return $mo;
    }
    
    
    /*
     * 装备最大等级
     */
    public function Equip_MaxLevel() {
        $rarity = $this->mo()->rarity;
        $qual = $this->qual;
        $posId = $this->mo()->position;
        $dic = GameConfig::equip_levelupgrade();
        $max = 0;
        foreach ($dic as $str => $mo) {
            if($mo->rarity == $rarity && $mo->qual == $qual && $mo->posId == $posId){
                if($mo->level > $max){
                    $max = $mo->level;
                }
            }
        }
        return $max;
    }
    
}
