name: Tenyi
card_text: 1 Tuner + 1+ non-Tuner monsters
  If this card is Synchro Summoned and 2 or more Wyrm monsters are in your GY and/or banishment: You can add 1 Field Spell from your Deck to your hand. You can only use this effect of "Tenyi Spirit - Mula Adhara" once per turn. While a non-Effect Monster is face-up on the field, this card gains these effects.
  ● Cannot be destroyed by an opponent's card effects.
  ● Your opponent cannot target this card with card effects.
  ● Can make a second attack during each Battle Phase.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Synchro summon
  	aux.AddSynchroProcedure(c, nil, aux.NonTuner(nil), 1)
  	c:EnableReviveLimit()
  	--search
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.thcon)
  	e1:SetTarget(s.thtg)
  	e1:SetOperation(s.thop)
  	c:RegisterEffect(e1)
  	--indestructable
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCondition(s.intcon)
  	e2:SetValue(aux.indoval)
  	c:RegisterEffect(e2)
  	--cannot target
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e3:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCondition(s.intcon)
  	e3:SetValue(aux.tgoval)
  	c:RegisterEffect(e3)
  	--extra attack
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE)
  	e4:SetCode(EFFECT_EXTRA_ATTACK)
  	e4:SetCondition(s.intcon)
  	e4:SetValue(1)
  	c:RegisterEffect(e4)
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_SYNCHRO)
  end
  function s.thfilter(c)
  	return c:IsType(TYPE_FIELD) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  			and Duel.IsExistingMatchingCard(aux.AND(Card.IsFaceupEx, Card.IsRace), tp, LOCATION_GRAVE + LOCATION_REMOVED, 0, 2, nil, RACE_WYRM)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  function s.intcon(e)
  	return Duel.IsExistingMatchingCard(aux.AND(aux.NOT(Card.IsType), Card.IsFaceup), e:GetHandlerPlayer(), LOCATION_MZONE, LOCATION_MZONE, 1, nil, TYPE_EFFECT)
  end
  
  
source_text: Tenyi
  1 Tuner + 1+ non-Tuner monsters
  If this card is Synchro Summoned and 2 or more Wyrm monsters are in your GY and/or banishment: You can add 1 Field Spell from your Deck to your hand. You can only use this effect of "Tenyi Spirit - Mula Adhara" once per turn. While a non-Effect Monster is face-up on the field, this card gains these effects.
  ● Cannot be destroyed by an opponent's card effects.
  ● Your opponent cannot target this card with card effects.
  ● Can make a second attack during each Battle Phase.
target_text: -- Tenyi
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Synchro summon
  	aux.AddSynchroProcedure(c, nil, aux.NonTuner(nil), 1)
  	c:EnableReviveLimit()
  	--search
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.thcon)
  	e1:SetTarget(s.thtg)
  	e1:SetOperation(s.thop)
  	c:RegisterEffect(e1)
  	--indestructable
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCondition(s.intcon)
  	e2:SetValue(aux.indoval)
  	c:RegisterEffect(e2)
  	--cannot target
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e3:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCondition(s.intcon)
  	e3:SetValue(aux.tgoval)
  	c:RegisterEffect(e3)
  	--extra attack
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE)
  	e4:SetCode(EFFECT_EXTRA_ATTACK)
  	e4:SetCondition(s.intcon)
  	e4:SetValue(1)
  	c:RegisterEffect(e4)
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_SYNCHRO)
  end
  function s.thfilter(c)
  	return c:IsType(TYPE_FIELD) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  			and Duel.IsExistingMatchingCard(aux.AND(Card.IsFaceupEx, Card.IsRace), tp, LOCATION_GRAVE + LOCATION_REMOVED, 0, 2, nil, RACE_WYRM)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  function s.intcon(e)
  	return Duel.IsExistingMatchingCard(aux.AND(aux.NOT(Card.IsType), Card.IsFaceup), e:GetHandlerPlayer(), LOCATION_MZONE, LOCATION_MZONE, 1, nil, TYPE_EFFECT)
  end
  
  