name: Land
card_text: Target 1 face-up card in a Field Zone; banish it, then place it face-up in the other Field Zone, then, you can choose 1 Field Spell with a different original name in the current controller's GY, and place it face-up in the Field Zone of the player whose card was banished. You can only activate 1 "Land Flipping" per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_REMOVE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsAbleToRemove()
  end
  function s.filter2(c, code)
  	return c:IsType(TYPE_FIELD) and not c:IsCode(code)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_FZONE) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_FZONE, LOCATION_FZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_FZONE, LOCATION_FZONE, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g, 1, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		local ttp = tc:GetControler()
  		if Duel.Remove(tc, POS_FACEUP, REASON_EFFECT) ~= 0 then
  			local g = Duel.GetOperatedGroup()
  			local tc2 = g:GetFirst()
  			local code = tc2:GetOriginalCode()
  			if
  				Duel.MoveToField(tc2, 1 - ttp, 1 - ttp, LOCATION_FZONE, POS_FACEUP, true) ~= 0
  				and Duel.IsExistingMatchingCard(aux.NecroValleyFilter(s.filter2), 1 - ttp, LOCATION_GRAVE, 0, 1, nil, code)
  				and Duel.SelectYesNo(tp, aux.Stringid(id, 0))
  			then
  				Duel.BreakEffect()
  				local rg = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.filter2), 1 - ttp, LOCATION_GRAVE, 0, 1, 1, nil, code)
  				if #rg > 0 then
  					Duel.MoveToField(rg:GetFirst(), tp, ttp, LOCATION_FZONE, POS_FACEUP, true)
  				end
  			end
  		end
  	end
  end
  
  
source_text: Land
  Target 1 face-up card in a Field Zone; banish it, then place it face-up in the other Field Zone, then, you can choose 1 Field Spell with a different original name in the current controller's GY, and place it face-up in the Field Zone of the player whose card was banished. You can only activate 1 "Land Flipping" per turn.
target_text: -- Land
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_REMOVE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsAbleToRemove()
  end
  function s.filter2(c, code)
  	return c:IsType(TYPE_FIELD) and not c:IsCode(code)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_FZONE) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_FZONE, LOCATION_FZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_FZONE, LOCATION_FZONE, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g, 1, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		local ttp = tc:GetControler()
  		if Duel.Remove(tc, POS_FACEUP, REASON_EFFECT) ~= 0 then
  			local g = Duel.GetOperatedGroup()
  			local tc2 = g:GetFirst()
  			local code = tc2:GetOriginalCode()
  			if
  				Duel.MoveToField(tc2, 1 - ttp, 1 - ttp, LOCATION_FZONE, POS_FACEUP, true) ~= 0
  				and Duel.IsExistingMatchingCard(aux.NecroValleyFilter(s.filter2), 1 - ttp, LOCATION_GRAVE, 0, 1, nil, code)
  				and Duel.SelectYesNo(tp, aux.Stringid(id, 0))
  			then
  				Duel.BreakEffect()
  				local rg = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.filter2), 1 - ttp, LOCATION_GRAVE, 0, 1, 1, nil, code)
  				if #rg > 0 then
  					Duel.MoveToField(rg:GetFirst(), tp, ttp, LOCATION_FZONE, POS_FACEUP, true)
  				end
  			end
  		end
  	end
  end
  
  