name: Fog
card_text: You can Tribute 1 monster, or no monsters, to Normal Summon (but not Set) this card. The ATK of this card becomes the combined original ATK of the Tributed monsters. Neither player can Tribute cards.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--summon with 1 tribute
  	local e0 = Effect.CreateEffect(c)
  	e0:SetDescription(aux.Stringid(id, 0))
  	e0:SetType(EFFECT_TYPE_SINGLE)
  	e0:SetCode(EFFECT_SUMMON_PROC)
  	e0:SetCondition(s.ttcon)
  	e0:SetOperation(s.ttop)
  	e0:SetValue(SUMMON_TYPE_ADVANCE)
  	c:RegisterEffect(e0)
  	--summon with no tribute
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 1))
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_SUMMON_PROC)
  	e1:SetCondition(s.ntcon)
  	c:RegisterEffect(e1)
  	--tribute check
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_MATERIAL_CHECK)
  	e2:SetValue(s.valcheck)
  	c:RegisterEffect(e2)
  	--give atk effect only when summon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetCode(EFFECT_SUMMON_COST)
  	e3:SetOperation(s.facechk)
  	e3:SetLabelObject(e2)
  	c:RegisterEffect(e3)
  	--cannot release
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_FIELD)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetCode(EFFECT_CANNOT_RELEASE)
  	e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e4:SetTargetRange(1, 1)
  	c:RegisterEffect(e4)
  end
  function s.ntcon(e, c, minc)
  	if c == nil then
  		return true
  	end
  	return minc == 0 and c:IsLevelAbove(5) and Duel.GetLocationCount(c:GetControler(), LOCATION_MZONE) > 0
  end
  function s.ttcon(e, c, minc)
  	if c == nil then
  		return true
  	end
  	return minc <= 1 and Duel.CheckTribute(c, 1)
  end
  function s.ttop(e, tp, eg, ep, ev, re, r, rp, c)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RELEASE)
  	local g = Duel.SelectTribute(tp, c, 1, 1)
  	c:SetMaterial(g)
  	Duel.Release(g, REASON_SUMMON + REASON_MATERIAL)
  end
  function s.valcheck(e, c)
  	local g = c:GetMaterial()
  	local tc = g:GetFirst()
  	local atk = 0
  	while tc do
  		local catk = tc:GetTextAttack()
  		atk = atk + (catk >= 0 and catk or 0)
  		tc = g:GetNext()
  	end
  	if e:GetLabel() == 1 then
  		e:SetLabel(0)
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SET_ATTACK)
  		e1:SetValue(atk)
  		e1:SetReset(RESET_EVENT + 0xff0000)
  		c:RegisterEffect(e1)
  	end
  end
  function s.facechk(e, tp, eg, ep, ev, re, r, rp)
  	e:GetLabelObject():SetLabel(1)
  end
  
  
source_text: Fog
  You can Tribute 1 monster, or no monsters, to Normal Summon (but not Set) this card. The ATK of this card becomes the combined original ATK of the Tributed monsters. Neither player can Tribute cards.
target_text: -- Fog
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--summon with 1 tribute
  	local e0 = Effect.CreateEffect(c)
  	e0:SetDescription(aux.Stringid(id, 0))
  	e0:SetType(EFFECT_TYPE_SINGLE)
  	e0:SetCode(EFFECT_SUMMON_PROC)
  	e0:SetCondition(s.ttcon)
  	e0:SetOperation(s.ttop)
  	e0:SetValue(SUMMON_TYPE_ADVANCE)
  	c:RegisterEffect(e0)
  	--summon with no tribute
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 1))
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_SUMMON_PROC)
  	e1:SetCondition(s.ntcon)
  	c:RegisterEffect(e1)
  	--tribute check
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_MATERIAL_CHECK)
  	e2:SetValue(s.valcheck)
  	c:RegisterEffect(e2)
  	--give atk effect only when summon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetCode(EFFECT_SUMMON_COST)
  	e3:SetOperation(s.facechk)
  	e3:SetLabelObject(e2)
  	c:RegisterEffect(e3)
  	--cannot release
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_FIELD)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetCode(EFFECT_CANNOT_RELEASE)
  	e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e4:SetTargetRange(1, 1)
  	c:RegisterEffect(e4)
  end
  function s.ntcon(e, c, minc)
  	if c == nil then
  		return true
  	end
  	return minc == 0 and c:IsLevelAbove(5) and Duel.GetLocationCount(c:GetControler(), LOCATION_MZONE) > 0
  end
  function s.ttcon(e, c, minc)
  	if c == nil then
  		return true
  	end
  	return minc <= 1 and Duel.CheckTribute(c, 1)
  end
  function s.ttop(e, tp, eg, ep, ev, re, r, rp, c)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RELEASE)
  	local g = Duel.SelectTribute(tp, c, 1, 1)
  	c:SetMaterial(g)
  	Duel.Release(g, REASON_SUMMON + REASON_MATERIAL)
  end
  function s.valcheck(e, c)
  	local g = c:GetMaterial()
  	local tc = g:GetFirst()
  	local atk = 0
  	while tc do
  		local catk = tc:GetTextAttack()
  		atk = atk + (catk >= 0 and catk or 0)
  		tc = g:GetNext()
  	end
  	if e:GetLabel() == 1 then
  		e:SetLabel(0)
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SET_ATTACK)
  		e1:SetValue(atk)
  		e1:SetReset(RESET_EVENT + 0xff0000)
  		c:RegisterEffect(e1)
  	end
  end
  function s.facechk(e, tp, eg, ep, ev, re, r, rp)
  	e:GetLabelObject():SetLabel(1)
  end
  
  