name: Branded
card_text: When a monster effect activated by your opponent resolves, if that opponent's monster has 0 ATK or DEF, and you control a Level 8 or higher Fiend Fusion Monster, you can negate that activated effect. At the end of the Damage Step, if monsters with 0 ATK battled each other: You can destroy your opponent's battling monster. You can only use each effect of "Branded Disciple" once per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--negate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_CHAIN_SOLVING)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetOperation(s.disop)
  	c:RegisterEffect(e2)
  	--destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetCategory(CATEGORY_DESTROY)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_DAMAGE_STEP_END)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCountLimit(1, id)
  	e3:SetCondition(s.descon)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  end
  function s.disfilter(c)
  	return c:IsType(TYPE_FUSION) and c:IsRace(RACE_FIEND) and c:IsLevelAbove(8) and c:IsFaceup()
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local rc = re:GetHandler()
  	if
  		rp == 1 - tp
  		and Duel.IsChainDisablable(ev)
  		and c:GetFlagEffect(id) == 0
  		and re:IsActiveType(TYPE_MONSTER)
  		and (rc:IsFaceup() and rc:IsLocation(LOCATION_MZONE) and (rc:IsAttack(0) or rc:IsDefense(0)) or not (rc:IsFaceup() and rc:IsLocation(LOCATION_MZONE)) and (rc:GetTextAttack() == 0 or not rc:IsType(
  			TYPE_LINK
  		) and rc:GetTextDefense() == 0))
  		and Duel.IsExistingMatchingCard(s.disfilter, tp, LOCATION_MZONE, 0, 1, nil)
  		and Duel.SelectEffectYesNo(tp, c, aux.Stringid(id, 0))
  	then
  		Duel.Hint(HINT_CARD, 0, id)
  		Duel.NegateEffect(ev)
  		c:RegisterFlagEffect(id, RESET_PHASE + PHASE_END, 0, 0)
  	end
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	local a, d = Duel.GetBattleMonster(tp)
  	return a and d and a:IsAttack(0) and d:IsAttack(0) and d:IsRelateToBattle()
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local a, d = Duel.GetBattleMonster(tp)
  	if d and d:IsRelateToBattle() then
  		Duel.Destroy(d, REASON_EFFECT)
  	end
  end
  
  
source_text: Branded
  When a monster effect activated by your opponent resolves, if that opponent's monster has 0 ATK or DEF, and you control a Level 8 or higher Fiend Fusion Monster, you can negate that activated effect. At the end of the Damage Step, if monsters with 0 ATK battled each other: You can destroy your opponent's battling monster. You can only use each effect of "Branded Disciple" once per turn.
target_text: -- Branded
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--negate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_CHAIN_SOLVING)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetOperation(s.disop)
  	c:RegisterEffect(e2)
  	--destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetCategory(CATEGORY_DESTROY)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_DAMAGE_STEP_END)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCountLimit(1, id)
  	e3:SetCondition(s.descon)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  end
  function s.disfilter(c)
  	return c:IsType(TYPE_FUSION) and c:IsRace(RACE_FIEND) and c:IsLevelAbove(8) and c:IsFaceup()
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local rc = re:GetHandler()
  	if
  		rp == 1 - tp
  		and Duel.IsChainDisablable(ev)
  		and c:GetFlagEffect(id) == 0
  		and re:IsActiveType(TYPE_MONSTER)
  		and (rc:IsFaceup() and rc:IsLocation(LOCATION_MZONE) and (rc:IsAttack(0) or rc:IsDefense(0)) or not (rc:IsFaceup() and rc:IsLocation(LOCATION_MZONE)) and (rc:GetTextAttack() == 0 or not rc:IsType(
  			TYPE_LINK
  		) and rc:GetTextDefense() == 0))
  		and Duel.IsExistingMatchingCard(s.disfilter, tp, LOCATION_MZONE, 0, 1, nil)
  		and Duel.SelectEffectYesNo(tp, c, aux.Stringid(id, 0))
  	then
  		Duel.Hint(HINT_CARD, 0, id)
  		Duel.NegateEffect(ev)
  		c:RegisterFlagEffect(id, RESET_PHASE + PHASE_END, 0, 0)
  	end
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	local a, d = Duel.GetBattleMonster(tp)
  	return a and d and a:IsAttack(0) and d:IsAttack(0) and d:IsRelateToBattle()
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local a, d = Duel.GetBattleMonster(tp)
  	if d and d:IsRelateToBattle() then
  		Duel.Destroy(d, REASON_EFFECT)
  	end
  end
  
  