name: Dream
card_text: Fusion Summon 1 "Dream Mirror" Fusion Monster from your Extra Deck, using monsters you control as Fusion Material. If "Dream Mirror of Joy" is in a Field Zone, you can also use monsters in your hand as Fusion Material. If "Dream Mirror of Terror" is in a Field Zone, you can also banish monsters from your GY as Fusion Material. You can only activate 1 "Dream Mirror of Chaos" per turn.
external_ids: local CARD_ID_0 = 74665651 --Dream Mirror of Joy
  local CARD_ID_1 = 1050355 --Dream Mirror of Terror
  local SETCARD_ID_0 = 0x131 --Dream
  
lua: local CARD_ID_0 = 74665651 --Dream Mirror of Joy
  local CARD_ID_1 = 1050355 --Dream Mirror of Terror
  local SETCARD_ID_0 = 0x131 --Dream
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0, CARD_ID_1)
  	--fusion summon
  	local e1 = FusionSpell.CreateSummonEffect(c, {
  		fusfilter = s.fusfilter,
  		pre_select_mat_location = s.pre_select_mat_location,
  		extra_target = s.extra_target,
  	})
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_FUSION_SUMMON + CATEGORY_REMOVE)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	c:RegisterEffect(e1)
  end
  
  function s.fusfilter(c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  
  function s.extra_target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, nil, 0, tp, LOCATION_GRAVE)
  end
  
  function s.pre_select_mat_location(tc, tp)
  	local location = LOCATION_MZONE
  	--- if 聖光の夢魔鏡 in FZONE, add hand
  	if Duel.IsExistingMatchingCard(function(c)
  		return c:IsCode(CARD_ID_0) and c:IsFaceup()
  	end, tp, LOCATION_FZONE, LOCATION_FZONE, 1, nil) then
  		location = location | LOCATION_HAND
  	end
  	--- if 闇黒の夢魔鏡 in FZONE, add grave
  	if Duel.IsExistingMatchingCard(function(c)
  		return c:IsCode(CARD_ID_1) and c:IsFaceup()
  	end, tp, LOCATION_FZONE, LOCATION_FZONE, 1, nil) then
  		location = location | LOCATION_GRAVE
  	end
  	return location
  end
  
  
source_text: Dream
  Fusion Summon 1 "Dream Mirror" Fusion Monster from your Extra Deck, using monsters you control as Fusion Material. If "Dream Mirror of Joy" is in a Field Zone, you can also use monsters in your hand as Fusion Material. If "Dream Mirror of Terror" is in a Field Zone, you can also banish monsters from your GY as Fusion Material. You can only activate 1 "Dream Mirror of Chaos" per turn.
target_text: -- Dream
  local CARD_ID_0 = 74665651 --Dream Mirror of Joy
  local CARD_ID_1 = 1050355 --Dream Mirror of Terror
  local SETCARD_ID_0 = 0x131 --Dream
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0, CARD_ID_1)
  	--fusion summon
  	local e1 = FusionSpell.CreateSummonEffect(c, {
  		fusfilter = s.fusfilter,
  		pre_select_mat_location = s.pre_select_mat_location,
  		extra_target = s.extra_target,
  	})
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_FUSION_SUMMON + CATEGORY_REMOVE)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	c:RegisterEffect(e1)
  end
  
  function s.fusfilter(c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  
  function s.extra_target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, nil, 0, tp, LOCATION_GRAVE)
  end
  
  function s.pre_select_mat_location(tc, tp)
  	local location = LOCATION_MZONE
  	--- if 聖光の夢魔鏡 in FZONE, add hand
  	if Duel.IsExistingMatchingCard(function(c)
  		return c:IsCode(CARD_ID_0) and c:IsFaceup()
  	end, tp, LOCATION_FZONE, LOCATION_FZONE, 1, nil) then
  		location = location | LOCATION_HAND
  	end
  	--- if 闇黒の夢魔鏡 in FZONE, add grave
  	if Duel.IsExistingMatchingCard(function(c)
  		return c:IsCode(CARD_ID_1) and c:IsFaceup()
  	end, tp, LOCATION_FZONE, LOCATION_FZONE, 1, nil) then
  		location = location | LOCATION_GRAVE
  	end
  	return location
  end
  
  