local StarCell = class("StarCell", BaseCell)

function StarCell:init()
	local uiMap = self:getUIMap()
	self.starBg = uiMap["cell.star_cell"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.STAR_CELL)
	self.descTx = uiMap["cell.desc_tx"]

	-- self:addClickListener(function()
	-- 	EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.SKIN_SELECT, self.skinId)
	-- end)
end

function StarCell:refresh(heroEntity, idx)
	self.heroEntity = heroEntity
	if not self.heroEntity then
		return
	end

	local star = self.heroEntity:getStar()
	self.starBg:refresh(idx)
	if idx <= star then
		self.baseObject:setSprite(GConst.ATLAS_PATH.COMMON, "common_bg_7")
	else
		self.baseObject:setSprite(GConst.ATLAS_PATH.COMMON, "common_bg_8")
	end

	local attr = heroEntity:getStarAttrCfg(idx)
	local descTx = GFunc.getAttrDesc(attr.type, attr.num)
	if not table.containValue(GConst.MATCH_ALL_ATKP_NAME, attr.type) then
		descTx = heroEntity:getName() .. descTx
	end
	self.descTx:setText(descTx)
end

return StarCell