name: Strength
card_text: If you Ritual or Fusion Summon using "Blue-Eyes White Dragon" or "Dark Magician": You can target 1 card your opponent controls or in their GY; banish it. You can send this face-up card from the field to the GY, then target 1 Level 7 or higher Normal Monster in your GY; add it to your hand or shuffle it into the Deck. You can only use each effect of "Strength in Unity" once per turn.
external_ids: local CARD_ID_0 = 46986414 --Dark Magician
  local CARD_ID_2 = 89631139 --Blue-Eyes White Dragon
  
lua: local CARD_ID_0 = 46986414 --Dark Magician
  local CARD_ID_2 = 89631139 --Blue-Eyes White Dragon
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_2, CARD_ID_0)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--remove
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_REMOVE)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DELAY)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.rmcon)
  	e2:SetTarget(s.rmtg)
  	e2:SetOperation(s.rmop)
  	c:RegisterEffect(e2)
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_FIELD)
  	e4:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_SET_AVAILABLE + EFFECT_FLAG_IGNORE_RANGE)
  	e4:SetRange(LOCATION_SZONE)
  	e4:SetCode(EFFECT_MATERIAL_CHECK)
  	e4:SetValue(s.valcheck)
  	c:RegisterEffect(e4)
  	--Recover
  	local e5 = Effect.CreateEffect(c)
  	e5:SetDescription(aux.Stringid(id, 1))
  	e5:SetCategory(CATEGORY_TOHAND + CATEGORY_TODECK)
  	e5:SetType(EFFECT_TYPE_IGNITION)
  	e5:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e5:SetRange(LOCATION_SZONE)
  	e5:SetCountLimit(1, id + 1)
  	e5:SetCost(s.thcost)
  	e5:SetTarget(s.thtg)
  	e5:SetOperation(s.thop)
  	c:RegisterEffect(e5)
  end
  function s.mtfilter1(c)
  	return c:IsCode(CARD_ID_2, CARD_ID_0)
  end
  function s.mtfilter2(c)
  	return c:IsFusionCode(CARD_ID_2, CARD_ID_0)
  end
  function s.valcheck(e, c)
  	local g = c:GetMaterial()
  	if g:IsExists(s.mtfilter1, 1, nil) then
  		c:RegisterFlagEffect(id, RESET_EVENT + 0x4fe0000 + RESET_PHASE + PHASE_END, 0, 1)
  	end
  	if g:IsExists(s.mtfilter2, 1, nil) then
  		c:RegisterFlagEffect(96239879, RESET_EVENT + 0x4fe0000 + RESET_PHASE + PHASE_END, 0, 1)
  	end
  end
  function s.rmcon(e, tp, eg, ep, ev, re, r, rp)
  	local tc = eg:GetFirst()
  	return tc:IsSummonPlayer(tp) and (tc:IsSummonType(SUMMON_TYPE_RITUAL) and tc:GetFlagEffect(id) ~= 0 or tc:IsSummonType(SUMMON_TYPE_FUSION) and tc:GetFlagEffect(96239879) ~= 0)
  end
  function s.rmtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return (chkc:IsOnField() or chkc:IsLocation(LOCATION_GRAVE)) and chkc:IsControler(1 - tp) and chkc:IsAbleToRemove()
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(Card.IsAbleToRemove, tp, 0, LOCATION_ONFIELD + LOCATION_GRAVE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = aux.SelectTargetFromFieldFirst(tp, Card.IsAbleToRemove, tp, 0, LOCATION_ONFIELD + LOCATION_GRAVE, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g, 1, 0, 0)
  end
  function s.rmop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.Remove(tc, POS_FACEUP, REASON_EFFECT)
  	end
  end
  function s.thcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsAbleToGraveAsCost()
  	end
  	Duel.SendtoGrave(e:GetHandler(), REASON_COST)
  end
  function s.thfilter(c)
  	return c:IsType(TYPE_NORMAL) and c:IsLevelAbove(7) and (c:IsAbleToHand() or c:IsAbleToDeck())
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and s.thfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.thfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	local g = Duel.SelectTarget(tp, s.thfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, g, 1, 0, 0)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		if tc:IsAbleToDeck() and (not tc:IsAbleToHand() or Duel.SelectOption(tp, 1190, aux.Stringid(id, 2)) == 1) then
  			Duel.SendtoDeck(tc, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  		else
  			Duel.SendtoHand(tc, nil, REASON_EFFECT)
  		end
  	end
  end
  
  
source_text: Strength
  If you Ritual or Fusion Summon using "Blue-Eyes White Dragon" or "Dark Magician": You can target 1 card your opponent controls or in their GY; banish it. You can send this face-up card from the field to the GY, then target 1 Level 7 or higher Normal Monster in your GY; add it to your hand or shuffle it into the Deck. You can only use each effect of "Strength in Unity" once per turn.
target_text: -- Strength
  local CARD_ID_0 = 46986414 --Dark Magician
  local CARD_ID_2 = 89631139 --Blue-Eyes White Dragon
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_2, CARD_ID_0)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--remove
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_REMOVE)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DELAY)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.rmcon)
  	e2:SetTarget(s.rmtg)
  	e2:SetOperation(s.rmop)
  	c:RegisterEffect(e2)
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_FIELD)
  	e4:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_SET_AVAILABLE + EFFECT_FLAG_IGNORE_RANGE)
  	e4:SetRange(LOCATION_SZONE)
  	e4:SetCode(EFFECT_MATERIAL_CHECK)
  	e4:SetValue(s.valcheck)
  	c:RegisterEffect(e4)
  	--Recover
  	local e5 = Effect.CreateEffect(c)
  	e5:SetDescription(aux.Stringid(id, 1))
  	e5:SetCategory(CATEGORY_TOHAND + CATEGORY_TODECK)
  	e5:SetType(EFFECT_TYPE_IGNITION)
  	e5:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e5:SetRange(LOCATION_SZONE)
  	e5:SetCountLimit(1, id + 1)
  	e5:SetCost(s.thcost)
  	e5:SetTarget(s.thtg)
  	e5:SetOperation(s.thop)
  	c:RegisterEffect(e5)
  end
  function s.mtfilter1(c)
  	return c:IsCode(CARD_ID_2, CARD_ID_0)
  end
  function s.mtfilter2(c)
  	return c:IsFusionCode(CARD_ID_2, CARD_ID_0)
  end
  function s.valcheck(e, c)
  	local g = c:GetMaterial()
  	if g:IsExists(s.mtfilter1, 1, nil) then
  		c:RegisterFlagEffect(id, RESET_EVENT + 0x4fe0000 + RESET_PHASE + PHASE_END, 0, 1)
  	end
  	if g:IsExists(s.mtfilter2, 1, nil) then
  		c:RegisterFlagEffect(96239879, RESET_EVENT + 0x4fe0000 + RESET_PHASE + PHASE_END, 0, 1)
  	end
  end
  function s.rmcon(e, tp, eg, ep, ev, re, r, rp)
  	local tc = eg:GetFirst()
  	return tc:IsSummonPlayer(tp) and (tc:IsSummonType(SUMMON_TYPE_RITUAL) and tc:GetFlagEffect(id) ~= 0 or tc:IsSummonType(SUMMON_TYPE_FUSION) and tc:GetFlagEffect(96239879) ~= 0)
  end
  function s.rmtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return (chkc:IsOnField() or chkc:IsLocation(LOCATION_GRAVE)) and chkc:IsControler(1 - tp) and chkc:IsAbleToRemove()
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(Card.IsAbleToRemove, tp, 0, LOCATION_ONFIELD + LOCATION_GRAVE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = aux.SelectTargetFromFieldFirst(tp, Card.IsAbleToRemove, tp, 0, LOCATION_ONFIELD + LOCATION_GRAVE, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g, 1, 0, 0)
  end
  function s.rmop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.Remove(tc, POS_FACEUP, REASON_EFFECT)
  	end
  end
  function s.thcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsAbleToGraveAsCost()
  	end
  	Duel.SendtoGrave(e:GetHandler(), REASON_COST)
  end
  function s.thfilter(c)
  	return c:IsType(TYPE_NORMAL) and c:IsLevelAbove(7) and (c:IsAbleToHand() or c:IsAbleToDeck())
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and s.thfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.thfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	local g = Duel.SelectTarget(tp, s.thfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, g, 1, 0, 0)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		if tc:IsAbleToDeck() and (not tc:IsAbleToHand() or Duel.SelectOption(tp, 1190, aux.Stringid(id, 2)) == 1) then
  			Duel.SendtoDeck(tc, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  		else
  			Duel.SendtoHand(tc, nil, REASON_EFFECT)
  		end
  	end
  end
  
  