name: Crimson
card_text: When your opponent activates a Spell/Trap Card that would inflict damage to you, while you control a "Red Dragon Archfiend": Your opponent takes twice the effect damage you would have taken, instead.
external_ids: local CARD_ID_0 = 70902743 --Red Dragon Archfiend
  
lua: local CARD_ID_0 = 70902743 --Red Dragon Archfiend
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--reflect
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_CHAINING)
  	e1:SetCondition(s.condition)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsCode(CARD_ID_0)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_ONFIELD, 0, 1, nil) and ep ~= tp and re:IsHasType(EFFECT_TYPE_ACTIVATE) and aux.damcon1(e, tp, eg, ep, ev, re, r, rp)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local cid = Duel.GetChainInfo(ev, CHAININFO_CHAIN_ID)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_REFLECT_DAMAGE)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetTargetRange(1, 0)
  	e1:SetLabel(cid)
  	e1:SetValue(s.refcon)
  	e1:SetReset(RESET_CHAIN)
  	Duel.RegisterEffect(e1, tp)
  	local e2 = Effect.CreateEffect(e:GetHandler())
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CHANGE_DAMAGE)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e2:SetTargetRange(0, 1)
  	e2:SetLabel(cid)
  	e2:SetValue(s.dammul)
  	e2:SetReset(RESET_CHAIN)
  	Duel.RegisterEffect(e2, tp)
  end
  function s.refcon(e, re, val, r, rp, rc)
  	local cc = Duel.GetCurrentChain()
  	if cc == 0 or bit.band(r, REASON_EFFECT) == 0 then
  		return
  	end
  	local cid = Duel.GetChainInfo(0, CHAININFO_CHAIN_ID)
  	return cid == e:GetLabel()
  end
  function s.dammul(e, re, val, r, rp, rc)
  	local cc = Duel.GetCurrentChain()
  	if cc == 0 or bit.band(r, REASON_EFFECT) == 0 then
  		return
  	end
  	local cid = Duel.GetChainInfo(0, CHAININFO_CHAIN_ID)
  	return cid == e:GetLabel() and val * 2 or val
  end
  
  
source_text: Crimson
  When your opponent activates a Spell/Trap Card that would inflict damage to you, while you control a "Red Dragon Archfiend": Your opponent takes twice the effect damage you would have taken, instead.
target_text: -- Crimson
  local CARD_ID_0 = 70902743 --Red Dragon Archfiend
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--reflect
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_CHAINING)
  	e1:SetCondition(s.condition)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsCode(CARD_ID_0)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_ONFIELD, 0, 1, nil) and ep ~= tp and re:IsHasType(EFFECT_TYPE_ACTIVATE) and aux.damcon1(e, tp, eg, ep, ev, re, r, rp)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local cid = Duel.GetChainInfo(ev, CHAININFO_CHAIN_ID)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_REFLECT_DAMAGE)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetTargetRange(1, 0)
  	e1:SetLabel(cid)
  	e1:SetValue(s.refcon)
  	e1:SetReset(RESET_CHAIN)
  	Duel.RegisterEffect(e1, tp)
  	local e2 = Effect.CreateEffect(e:GetHandler())
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CHANGE_DAMAGE)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e2:SetTargetRange(0, 1)
  	e2:SetLabel(cid)
  	e2:SetValue(s.dammul)
  	e2:SetReset(RESET_CHAIN)
  	Duel.RegisterEffect(e2, tp)
  end
  function s.refcon(e, re, val, r, rp, rc)
  	local cc = Duel.GetCurrentChain()
  	if cc == 0 or bit.band(r, REASON_EFFECT) == 0 then
  		return
  	end
  	local cid = Duel.GetChainInfo(0, CHAININFO_CHAIN_ID)
  	return cid == e:GetLabel()
  end
  function s.dammul(e, re, val, r, rp, rc)
  	local cc = Duel.GetCurrentChain()
  	if cc == 0 or bit.band(r, REASON_EFFECT) == 0 then
  		return
  	end
  	local cid = Duel.GetChainInfo(0, CHAININFO_CHAIN_ID)
  	return cid == e:GetLabel() and val * 2 or val
  end
  
  