name: Cassimolar
card_text: When this card is Normal Summoned: You can target 1 face-up monster your opponent controls; it gains ATK equal to its original ATK, also during the End Phase of the next turn, destroy that face-up monster, and if you do, your opponent takes damage equal to half its original ATK. At the start of your opponent's Battle Phase: You can Tribute this Normal Summoned/Set card; your opponent's monsters cannot attack directly for the rest of this turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--atk change
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_ATKCHANGE)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetTarget(s.atktg)
  	e1:SetOperation(s.atkop)
  	c:RegisterEffect(e1)
  	--atk limit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_PHASE + PHASE_BATTLE_START)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCondition(s.limcon)
  	e2:SetCost(s.limcost)
  	e2:SetOperation(s.limop)
  	c:RegisterEffect(e2)
  end
  function s.atktg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1 - tp) and chkc:IsFaceup()
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(Card.IsFaceup, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	local g = Duel.SelectTarget(tp, Card.IsFaceup, tp, 0, LOCATION_MZONE, 1, 1, nil)
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	local c = e:GetHandler()
  	if tc:IsFaceup() and tc:IsRelateToEffect(e) and not tc:IsImmuneToEffect(e) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(tc:GetBaseAttack())
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e1)
  		local fid = c:GetFieldID()
  		tc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD, 0, 1, fid)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  		e2:SetCode(EVENT_PHASE + PHASE_END)
  		e2:SetReset(RESET_PHASE + PHASE_END, 2)
  		e2:SetCountLimit(1)
  		e2:SetLabel(fid, Duel.GetTurnCount())
  		e2:SetLabelObject(tc)
  		e2:SetCondition(s.descon)
  		e2:SetOperation(s.desop)
  		Duel.RegisterEffect(e2, tp)
  	end
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	local fid, ct = e:GetLabel()
  	local tc = e:GetLabelObject()
  	return Duel.GetTurnCount() ~= ct and tc:GetFlagEffectLabel(id) == fid
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetLabelObject()
  	if Duel.Destroy(tc, REASON_EFFECT) > 0 then
  		Duel.Damage(1 - tp, math.floor(tc:GetBaseAttack() / 2), REASON_EFFECT)
  	end
  end
  function s.limcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() ~= tp and e:GetHandler():IsSummonType(SUMMON_TYPE_NORMAL)
  end
  function s.limcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsReleasable()
  	end
  	Duel.Release(e:GetHandler(), REASON_COST)
  end
  function s.limop(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_DIRECT_ATTACK)
  	e1:SetTargetRange(0, LOCATION_MZONE)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  
  
source_text: Cassimolar
  When this card is Normal Summoned: You can target 1 face-up monster your opponent controls; it gains ATK equal to its original ATK, also during the End Phase of the next turn, destroy that face-up monster, and if you do, your opponent takes damage equal to half its original ATK. At the start of your opponent's Battle Phase: You can Tribute this Normal Summoned/Set card; your opponent's monsters cannot attack directly for the rest of this turn.
target_text: -- Cassimolar
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--atk change
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_ATKCHANGE)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetTarget(s.atktg)
  	e1:SetOperation(s.atkop)
  	c:RegisterEffect(e1)
  	--atk limit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_PHASE + PHASE_BATTLE_START)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCondition(s.limcon)
  	e2:SetCost(s.limcost)
  	e2:SetOperation(s.limop)
  	c:RegisterEffect(e2)
  end
  function s.atktg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1 - tp) and chkc:IsFaceup()
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(Card.IsFaceup, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	local g = Duel.SelectTarget(tp, Card.IsFaceup, tp, 0, LOCATION_MZONE, 1, 1, nil)
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	local c = e:GetHandler()
  	if tc:IsFaceup() and tc:IsRelateToEffect(e) and not tc:IsImmuneToEffect(e) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(tc:GetBaseAttack())
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e1)
  		local fid = c:GetFieldID()
  		tc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD, 0, 1, fid)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  		e2:SetCode(EVENT_PHASE + PHASE_END)
  		e2:SetReset(RESET_PHASE + PHASE_END, 2)
  		e2:SetCountLimit(1)
  		e2:SetLabel(fid, Duel.GetTurnCount())
  		e2:SetLabelObject(tc)
  		e2:SetCondition(s.descon)
  		e2:SetOperation(s.desop)
  		Duel.RegisterEffect(e2, tp)
  	end
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	local fid, ct = e:GetLabel()
  	local tc = e:GetLabelObject()
  	return Duel.GetTurnCount() ~= ct and tc:GetFlagEffectLabel(id) == fid
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetLabelObject()
  	if Duel.Destroy(tc, REASON_EFFECT) > 0 then
  		Duel.Damage(1 - tp, math.floor(tc:GetBaseAttack() / 2), REASON_EFFECT)
  	end
  end
  function s.limcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() ~= tp and e:GetHandler():IsSummonType(SUMMON_TYPE_NORMAL)
  end
  function s.limcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsReleasable()
  	end
  	Duel.Release(e:GetHandler(), REASON_COST)
  end
  function s.limop(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_DIRECT_ATTACK)
  	e1:SetTargetRange(0, LOCATION_MZONE)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  
  