local BattleConst = require "app/module/battle/battle_const"
local BattleBuffEntity = class("BattleBuffEntity", BaseData)

local BUFF_TYPE_DIRECT_HURT = BattleConst.BUFF_TYPE.DIRECT_HURT
local BUFF_TYPE_SHIELD = BattleConst.BUFF_TYPE.SHIELD

function BattleBuffEntity:ctor()
end

function BattleBuffEntity:init(effectParams, owner, hostSkill)
	self.name = effectParams.type
	self.effectNum = effectParams.num
	self.round = effectParams.round
	self.ratio = effectParams.ratio
	self.owner = owner
	self.hostSkill = hostSkill
	self.targetSide = nil
	self.buffInfo = ConfigManager:getConfigWithOtherKey("buff", "name")[self.name]
	self.buffType = self.buffInfo.buff_type
	self.cantRemove = false
	self.notShowIcon = false
	self.showNameStr = nil
	self.showNameRedColor = nil

	self.needSave = self.hostSkill ~= nil
end

function BattleBuffEntity:setOwner(owner)
	self.owner = owner
end

function BattleBuffEntity:getName()
	return self.name
end

function BattleBuffEntity:getHostSkill()
	return self.hostSkill
end

function BattleBuffEntity:getDesc()
	return GFunc.getBuffDesc(self:getName(), self:getEffectNum(), self:isPercent())
end

function BattleBuffEntity:getBuffType()
	return self.buffType
end

function BattleBuffEntity:isShield()
	return self.buffType == BUFF_TYPE_SHIELD
end

function BattleBuffEntity:getIsHurtType()
	return self.buffType == BUFF_TYPE_DIRECT_HURT
end

function BattleBuffEntity:getEffectNum()
	return self.effectNum
end

function BattleBuffEntity:setEffectNum(num)
	self.effectNum = num
end

function BattleBuffEntity:getFormula()
	return self.buffInfo.formula
end

function BattleBuffEntity:getRatio()
	return self.ratio
end

function BattleBuffEntity:setRatio(ratio)
	self.ratio = ratio
end

function BattleBuffEntity:getRound()
	return self.round
end

function BattleBuffEntity:setRound(num)
	self.round = num
end

function BattleBuffEntity:getTargetSide()
	return self.targetSide
end

function BattleBuffEntity:setTargetSide(side)
	self.targetSide = side
end

function BattleBuffEntity:getStack()
	return self.buffInfo.stack
end

function BattleBuffEntity:getDecr()
	return self.buffInfo.decr
end

function BattleBuffEntity:isIncreaseGain()
	return self:getDecr() == BattleConst.BUFF_DECR_TYPE.INCREASE_GAIN
end

function BattleBuffEntity:isDecreaseGain()
	return self:getDecr() == BattleConst.BUFF_DECR_TYPE.REDUCE_GAIN
end

function BattleBuffEntity:getIcon()
	return self.buffInfo.icon
end

function BattleBuffEntity:getFxContinued()
	return self.buffInfo.fx_continued
end

function BattleBuffEntity:getFxGet()
	return self.buffInfo.fx_get
end

function BattleBuffEntity:getFxTake()
	return self.buffInfo.fx_take
end

function BattleBuffEntity:getFxDisappear()
	return self.buffInfo.fx_disappear
end

function BattleBuffEntity:isPercent()
	return self.buffInfo.ispercent == 1
end

function BattleBuffEntity:getShowName(needRedColor)
	if not self.showNameStr then
		self.showNameStr = I18N:getTextWithOtherKey("buff", "name", self:getName(), "show_name")
	end
	if not self.showNameRedColor and self.showNameStr then
		if self:isIncreaseGain() then
			self.showNameRedColor = "<color=#4bff33>" .. self.showNameStr .. "</color>"
		else
			self.showNameRedColor = "<color=#ff5dfd>" .. self.showNameStr .. "</color>"
		end
	end
	if needRedColor then
		return self.showNameRedColor
	end
	return self.showNameStr
end

function BattleBuffEntity:needShowName()
	return self.buffInfo.show_name
end

function BattleBuffEntity:getLimitParameter()
	return self.buffInfo.limit_parameter
end

function BattleBuffEntity:isCantRemove()
	return self.cantRemove
end

function BattleBuffEntity:setIsCantRemove(cantRemove)
	self.cantRemove = cantRemove
end

function BattleBuffEntity:getNotShowIcon()
	return self.notShowIcon
end

function BattleBuffEntity:setNotShowIcon(notShow)
	self.notShowIcon = notShow
end

function BattleBuffEntity:setNeedSave(needSave)
	self.needSave = needSave
end

function BattleBuffEntity:getNeedSave()
	return self.needSave
end

return BattleBuffEntity