import ViewObject from "../../../main/ViewObject";
import GoodItem from "../../common/GoodItem";
import MagicBoxItem from "./MagicBoxItem";

/**
 * 魔盒奖励详细说明
 */
const {ccclass, property} = cc._decorator;

@ccclass
export default class MagicBoxRewardView extends ViewObject {

    @property(cc.Node)
    mContent: cc.Node = null;

    @property(cc.Prefab)
    mRewardItem: cc.Prefab = null;

    public init(boxItem:MagicBoxItem){
        let _magicBox = boxItem._magicBox
        let rewardList = this.main.sManage.getRewardViews(_magicBox.list)

        for (let i = 0; i < rewardList.length; i++) {
            const element = rewardList[i];
            let node = cc.instantiate(this.mRewardItem)
            let goodItem:GoodItem = node.getComponent(GoodItem)
            goodItem.initReward(this.main,element)
            goodItem.mContrast.node.active = true
            goodItem.mContrast.string = element.PR+'%'
            node.parent = this.mContent
        }
    }
}
