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

    /**
     * 道具
     * @var \stdClass()
     */
    public $items;
    
    /**
     * 宝石在背包库的唯一id
     * @var type
     */
    public $gemLength = 0; 


    /**
     * 宝石背包
     * \stdClass() 
     */
    public $gemStore;
    
    /**
     * 装备界面默认页
     * @var int
     */
    public $equipPag =1;

    /**
     * 装备
     * @var \stdClass()
     */
    public $equip;
    
    /**
     * 宝石装备的信息
     * @var \stdClass()
     */
    public $gemEquip;

    /**
     * 装备信息 装备不跟hero走--废弃
     * @var type
     */
    //public $equipPosition = null;
    
    
    
    public function initialize() {
        
    }

    public function __construct($arg = null) {
        if ($arg == null) {
            $this->items = new \stdClass();
            $this->gemStore = new \stdClass();
            $this->equip = new \stdClass();
            for ($i = 1; $i <=6; $i++) {
                $equip =  new Ins_Equip();
                $equip->typeId = $i;
                $this->equip->$i = $equip;
            }
            
            $this->gemEquip = new \stdClass();
            for ($k = 1; $k <=3; $k++) {                             
                $item = new \stdClass();
                for ($j = 1; $j <= 6; $j++) {
                    $item->$j = new \stdClass();
                }
                $this->gemEquip->$k =$item;
            }
            
            
        } else {
            parent::__construct($arg);
        }
    }

    public function removeItem($itemId, $num) {
        if (StlUtil::dictHasProperty($this->items, $itemId)) {
            $this->items->$itemId -= $num;
            if ($this->items->$itemId <= 0) {
                unset($this->items->$itemId);
            }
        }
    }
}
