name: Reign-Beaux,
card_text: If this card is discarded from your hand to your GY by an opponent's card effect: Special Summon this card from the GY. If Summoned this way: Destroy all monsters your opponent controls OR all Spells/Traps they control.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--spsummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_TO_GRAVE)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_DESTROY)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetCondition(s.descon)
  	e2:SetTarget(s.destg)
  	e2:SetOperation(s.desop)
  	c:RegisterEffect(e2)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsPreviousLocation(LOCATION_HAND) and bit.band(r, 0x4040) == 0x4040 and rp == 1 - tp and e:GetHandler():IsPreviousControler(tp)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsRelateToEffect(e) then
  		Duel.SpecialSummon(e:GetHandler(), SUMMON_VALUE_SELF, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetSummonType() == SUMMON_TYPE_SPECIAL + SUMMON_VALUE_SELF
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local c1 = Duel.GetMatchingGroupCount(aux.TRUE, tp, 0, LOCATION_MZONE, nil)
  	local c2 = Duel.GetMatchingGroupCount(aux.TRUE, tp, 0, LOCATION_SZONE, nil)
  	if (c1 > c2 and c2 ~= 0) or c1 == 0 then
  		c1 = c2
  	end
  	if c1 ~= 0 then
  		local g = Duel.GetMatchingGroup(aux.TRUE, tp, 0, LOCATION_ONFIELD, nil)
  		Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, c1, 0, 0)
  	end
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local g1 = Duel.GetMatchingGroup(aux.TRUE, tp, 0, LOCATION_MZONE, nil)
  	local g2 = Duel.GetMatchingGroup(aux.TRUE, tp, 0, LOCATION_SZONE, nil)
  	if g1:GetCount() > 0 or g2:GetCount() > 0 then
  		if g1:GetCount() == 0 then
  			Duel.Destroy(g2, REASON_EFFECT)
  		elseif g2:GetCount() == 0 then
  			Duel.Destroy(g1, REASON_EFFECT)
  		else
  			Duel.Hint(HINT_SELECTMSG, tp, 0)
  			local ac = Duel.SelectOption(tp, aux.Stringid(id, 2), aux.Stringid(id, 3))
  			if ac == 0 then
  				Duel.Destroy(g1, REASON_EFFECT)
  			else
  				Duel.Destroy(g2, REASON_EFFECT)
  			end
  		end
  	end
  end
  
  
source_text: Reign-Beaux,
  If this card is discarded from your hand to your GY by an opponent's card effect: Special Summon this card from the GY. If Summoned this way: Destroy all monsters your opponent controls OR all Spells/Traps they control.
target_text: -- Reign-Beaux,
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--spsummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_TO_GRAVE)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_DESTROY)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetCondition(s.descon)
  	e2:SetTarget(s.destg)
  	e2:SetOperation(s.desop)
  	c:RegisterEffect(e2)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsPreviousLocation(LOCATION_HAND) and bit.band(r, 0x4040) == 0x4040 and rp == 1 - tp and e:GetHandler():IsPreviousControler(tp)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsRelateToEffect(e) then
  		Duel.SpecialSummon(e:GetHandler(), SUMMON_VALUE_SELF, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetSummonType() == SUMMON_TYPE_SPECIAL + SUMMON_VALUE_SELF
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local c1 = Duel.GetMatchingGroupCount(aux.TRUE, tp, 0, LOCATION_MZONE, nil)
  	local c2 = Duel.GetMatchingGroupCount(aux.TRUE, tp, 0, LOCATION_SZONE, nil)
  	if (c1 > c2 and c2 ~= 0) or c1 == 0 then
  		c1 = c2
  	end
  	if c1 ~= 0 then
  		local g = Duel.GetMatchingGroup(aux.TRUE, tp, 0, LOCATION_ONFIELD, nil)
  		Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, c1, 0, 0)
  	end
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local g1 = Duel.GetMatchingGroup(aux.TRUE, tp, 0, LOCATION_MZONE, nil)
  	local g2 = Duel.GetMatchingGroup(aux.TRUE, tp, 0, LOCATION_SZONE, nil)
  	if g1:GetCount() > 0 or g2:GetCount() > 0 then
  		if g1:GetCount() == 0 then
  			Duel.Destroy(g2, REASON_EFFECT)
  		elseif g2:GetCount() == 0 then
  			Duel.Destroy(g1, REASON_EFFECT)
  		else
  			Duel.Hint(HINT_SELECTMSG, tp, 0)
  			local ac = Duel.SelectOption(tp, aux.Stringid(id, 2), aux.Stringid(id, 3))
  			if ac == 0 then
  				Duel.Destroy(g1, REASON_EFFECT)
  			else
  				Duel.Destroy(g2, REASON_EFFECT)
  			end
  		end
  	end
  end
  
  