local SummonForceCell = class("SummonForceCell", BaseCell)

function SummonForceCell:init()
	local uiMap = self:getUIMap()
	self.qltBg = uiMap['force_cell.bg']
	self.icon = uiMap["force_cell.icon"]
	self.newFlag = uiMap["force_cell.new_flag"]
	self.lvTx = uiMap["force_cell.lv_tx"]
	self.sliderBg = uiMap["force_cell.slider_bg"]
	self.sliderPrefab = uiMap["force_cell.slider_bg.slider"]
	self.sliderComp = self.sliderPrefab:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
	self.sliderTx = uiMap["force_cell.slider_bg.num_tx"]
	self.nameTx = uiMap["force_cell.name_tx"]
	self.countTx = uiMap["force_cell.count_tx"]
end

function SummonForceCell:refresh(info)
	Logger.logError("如果打印这条日子,这个代码就需要修改")
	local id = info.id
	local qlt = DataManager.ForceData:getForceQlt(id)
	local lv = DataManager.ForceData:getForceLevel(id)
	local icon = DataManager.ForceData:getForceFightIcon(id)
	local fragmentId, propId = DataManager.ForceData:getForceItemId(id)
	local fragmentCount = DataManager.BagData.ItemData:getItemNumById(fragmentId)
	local propCount = DataManager.BagData.ItemData:getItemNumById(propId)
	local isMaxLv = lv >= DataManager.ForceData:getForceMaxLv()
	local upCost = DataManager.ForceData:getForceLevelCost(lv + 1, qlt)
	local upNeedFragementCount = 5
	local upNeedPropCount = 5
	if upCost then
	    upNeedFragementCount = upCost[1]
	    upNeedPropCount = upCost[2]
	end
	local forceName = I18N:getConfig("force")[id] and I18N:getConfig("force")[id].name
	
	self.qltBg:setSprite(GConst.ATLAS_PATH.UI_FORCE, DataManager.ForceData:getForceQltBg_S(qlt))
	self.icon:setSprite(GConst.ATLAS_PATH.ICON_HERO, icon)
	self.newFlag:setVisible(DataManager.ForceData:getForceIsNew(id))
	self.lvTx:setVisible(true)
	self.sliderBg:setVisible(true)

	self.lvTx:setText(I18N:getGlobalText(I18N.GlobalConst.LV_POINT) .. lv)
	if isMaxLv then
		self.sliderTx:setText(I18N:getGlobalText(I18N.GlobalConst.MAX_LV))
		self.sliderComp.value = 1
	else
		self.sliderTx:setText(GFunc.num2Str(fragmentCount) .. "/" .. GFunc.num2Str(upNeedFragementCount))
		self.sliderComp.value = fragmentCount / upNeedFragementCount
	end

	-- 品质刷新滑动条与箭头颜色
	self.sliderPrefab:setSprite(GConst.ATLAS_PATH.UI_FORCE, qlt >= 5 and "force_progress_2" or "force_progress_1")
	-- 名字
	self.nameTx:setText(forceName)
	self.countTx:setText("+" .. info.count)

	-- 触发详细弹窗
	self:addClickListener(function()
		ModuleManager.ForceManager:showForceDetailUI(id, GConst.ForceConst.FORCE_DETAIL_TYPE.PRE, {heroId = id, lv = lv})
	end)
end


return SummonForceCell