name: Parasite
card_text: FLIP: Shuffle this card face-up into your opponent's Deck.
  If you draw this card after it was added to your Deck by its effect: Special Summon it in Defense Position, and if you do, take 1000 damage. All monsters controlled by the player that Summoned this card by its effect become Insect monsters.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	Duel.EnableGlobalFlag(GLOBALFLAG_DECK_REVERSE_CHECK)
  	--to deck
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TODECK)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_FLIP)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, e:GetHandler(), 1, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) or c:IsStatus(STATUS_BATTLE_DESTROYED) then
  		return
  	end
  	Duel.SendtoDeck(c, 1 - tp, SEQ_DECKSHUFFLE, REASON_EFFECT)
  	if not c:IsLocation(LOCATION_DECK) then
  		return
  	end
  	Duel.ShuffleDeck(1 - tp)
  	c:ReverseInDeck()
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 1))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_DRAW)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	e1:SetReset(RESET_EVENT + 0x1de0000)
  	c:RegisterEffect(e1)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsRelateToEffect(e)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		if Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP_DEFENSE) > 0 then
  			Duel.Damage(tp, 1000, REASON_EFFECT)
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_FIELD)
  			e1:SetCode(EFFECT_CHANGE_RACE)
  			e1:SetRange(LOCATION_MZONE)
  			e1:SetAbsoluteRange(tp, LOCATION_MZONE, 0)
  			e1:SetValue(RACE_INSECT)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  			c:RegisterEffect(e1)
  		end
  	end
  end
  
  
source_text: Parasite
  FLIP: Shuffle this card face-up into your opponent's Deck.
  If you draw this card after it was added to your Deck by its effect: Special Summon it in Defense Position, and if you do, take 1000 damage. All monsters controlled by the player that Summoned this card by its effect become Insect monsters.
target_text: -- Parasite
  local s, id, o = GetID()
  function s.initial_effect(c)
  	Duel.EnableGlobalFlag(GLOBALFLAG_DECK_REVERSE_CHECK)
  	--to deck
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TODECK)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_FLIP)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, e:GetHandler(), 1, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) or c:IsStatus(STATUS_BATTLE_DESTROYED) then
  		return
  	end
  	Duel.SendtoDeck(c, 1 - tp, SEQ_DECKSHUFFLE, REASON_EFFECT)
  	if not c:IsLocation(LOCATION_DECK) then
  		return
  	end
  	Duel.ShuffleDeck(1 - tp)
  	c:ReverseInDeck()
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 1))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_DRAW)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	e1:SetReset(RESET_EVENT + 0x1de0000)
  	c:RegisterEffect(e1)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsRelateToEffect(e)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		if Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP_DEFENSE) > 0 then
  			Duel.Damage(tp, 1000, REASON_EFFECT)
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_FIELD)
  			e1:SetCode(EFFECT_CHANGE_RACE)
  			e1:SetRange(LOCATION_MZONE)
  			e1:SetAbsoluteRange(tp, LOCATION_MZONE, 0)
  			e1:SetValue(RACE_INSECT)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  			c:RegisterEffect(e1)
  		end
  	end
  end
  
  