name: Bio-Insect
card_text: If this card is in your hand or GY and you do not control "Bio-Insect Armor": You can target 1 Insect monster you control; equip this card to it, but banish it when it leaves the field, also banish this Equip Card when it leaves the field. You can only use this effect of "Bio-Insect Armor" once per turn. The equipped monster gains 1500 ATK/2000 DEF during the Battle Phase and Main Phase 2, only.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--equip
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_EQUIP)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetRange(LOCATION_HAND + LOCATION_GRAVE)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.sscon)
  	e1:SetTarget(s.eqtg)
  	e1:SetOperation(s.eqop)
  	c:RegisterEffect(e1)
  	--Atk up
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_EQUIP)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetCondition(s.condition)
  	e2:SetValue(1500)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetCode(EFFECT_UPDATE_DEFENSE)
  	e3:SetValue(2000)
  	c:RegisterEffect(e3)
  end
  function s.sfilter(c)
  	return c:IsCode(id) and c:IsFaceup()
  end
  function s.sscon(e, tp, eg, ep, ev, re, r, rp)
  	return not Duel.IsExistingMatchingCard(s.sfilter, tp, LOCATION_ONFIELD, 0, 1, nil)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsRace(RACE_INSECT)
  end
  function s.eqtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local c = e:GetHandler()
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter(chkc) and chkc ~= c
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_SZONE) > 0 and e:GetHandler():CheckUniqueOnField(tp) and Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, c)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_EQUIP)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, c)
  	if c:IsLocation(LOCATION_GRAVE) then
  		Duel.SetOperationInfo(0, CATEGORY_LEAVE_GRAVE, c, 0, 0, 0)
  	end
  end
  function s.eqop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	local tc = Duel.GetFirstTarget()
  	if Duel.GetLocationCount(tp, LOCATION_SZONE) <= 0 or tc:IsFacedown() or not tc:IsRelateToEffect(e) or not c:CheckUniqueOnField(tp) then
  		Duel.SendtoGrave(c, REASON_EFFECT)
  		return
  	end
  	if not Duel.Equip(tp, c, tc) then
  		return
  	end
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_EQUIP_LIMIT)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	e1:SetValue(s.eqlimit)
  	e1:SetLabelObject(tc)
  	c:RegisterEffect(e1)
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e2:SetReset(RESET_EVENT + RESETS_REDIRECT)
  	e2:SetValue(LOCATION_REMOVED)
  	tc:RegisterEffect(e2)
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
  	e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e3:SetReset(RESET_EVENT + RESETS_REDIRECT)
  	e3:SetValue(LOCATION_REMOVED)
  	c:RegisterEffect(e3)
  end
  function s.eqlimit(e, c)
  	return c == e:GetLabelObject()
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	local ph = Duel.GetCurrentPhase()
  	return ph == PHASE_MAIN2 or (ph >= PHASE_BATTLE_START and ph <= PHASE_BATTLE)
  end
  
  
source_text: Bio-Insect
  If this card is in your hand or GY and you do not control "Bio-Insect Armor": You can target 1 Insect monster you control; equip this card to it, but banish it when it leaves the field, also banish this Equip Card when it leaves the field. You can only use this effect of "Bio-Insect Armor" once per turn. The equipped monster gains 1500 ATK/2000 DEF during the Battle Phase and Main Phase 2, only.
target_text: -- Bio-Insect
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--equip
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_EQUIP)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetRange(LOCATION_HAND + LOCATION_GRAVE)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.sscon)
  	e1:SetTarget(s.eqtg)
  	e1:SetOperation(s.eqop)
  	c:RegisterEffect(e1)
  	--Atk up
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_EQUIP)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetCondition(s.condition)
  	e2:SetValue(1500)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetCode(EFFECT_UPDATE_DEFENSE)
  	e3:SetValue(2000)
  	c:RegisterEffect(e3)
  end
  function s.sfilter(c)
  	return c:IsCode(id) and c:IsFaceup()
  end
  function s.sscon(e, tp, eg, ep, ev, re, r, rp)
  	return not Duel.IsExistingMatchingCard(s.sfilter, tp, LOCATION_ONFIELD, 0, 1, nil)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsRace(RACE_INSECT)
  end
  function s.eqtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local c = e:GetHandler()
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter(chkc) and chkc ~= c
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_SZONE) > 0 and e:GetHandler():CheckUniqueOnField(tp) and Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, c)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_EQUIP)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, c)
  	if c:IsLocation(LOCATION_GRAVE) then
  		Duel.SetOperationInfo(0, CATEGORY_LEAVE_GRAVE, c, 0, 0, 0)
  	end
  end
  function s.eqop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	local tc = Duel.GetFirstTarget()
  	if Duel.GetLocationCount(tp, LOCATION_SZONE) <= 0 or tc:IsFacedown() or not tc:IsRelateToEffect(e) or not c:CheckUniqueOnField(tp) then
  		Duel.SendtoGrave(c, REASON_EFFECT)
  		return
  	end
  	if not Duel.Equip(tp, c, tc) then
  		return
  	end
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_EQUIP_LIMIT)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	e1:SetValue(s.eqlimit)
  	e1:SetLabelObject(tc)
  	c:RegisterEffect(e1)
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e2:SetReset(RESET_EVENT + RESETS_REDIRECT)
  	e2:SetValue(LOCATION_REMOVED)
  	tc:RegisterEffect(e2)
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
  	e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e3:SetReset(RESET_EVENT + RESETS_REDIRECT)
  	e3:SetValue(LOCATION_REMOVED)
  	c:RegisterEffect(e3)
  end
  function s.eqlimit(e, c)
  	return c == e:GetLabelObject()
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	local ph = Duel.GetCurrentPhase()
  	return ph == PHASE_MAIN2 or (ph >= PHASE_BATTLE_START and ph <= PHASE_BATTLE)
  end
  
  