name: Emblem
card_text: Equip only to a "Plunder Patroll" monster. It gains 500 ATK, also your opponent cannot target it with card effects. You can send this equipped card to the GY; Special Summon 1 "Plunder Patroll" monster from your Extra Deck with the same Attribute as a monster on the field or in the GY, then take the monster that was equipped with this card, and equip it to that Special Summoned monster as an Equip Spell with this effect.
  ● The equipped monster gains 500 ATK.
  You can only use this effect of "Emblem of the Plunder Patroll" once per turn.
external_ids: local SETCARD_ID_0 = 0x13f --Plunder
  
lua: local SETCARD_ID_0 = 0x13f --Plunder
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_EQUIP)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_CONTINUOUS_TARGET)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--Equip limit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_EQUIP_LIMIT)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e2:SetValue(s.eqlimit)
  	c:RegisterEffect(e2)
  	--Atk up
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_EQUIP)
  	e3:SetCode(EFFECT_UPDATE_ATTACK)
  	e3:SetValue(500)
  	c:RegisterEffect(e3)
  	local e4 = e3:Clone()
  	e4:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e4:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e4:SetValue(aux.tgoval)
  	c:RegisterEffect(e4)
  	--spsummon
  	local e5 = Effect.CreateEffect(c)
  	e5:SetDescription(aux.Stringid(id, 1))
  	e5:SetType(EFFECT_TYPE_IGNITION)
  	e5:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e5:SetRange(LOCATION_SZONE)
  	e5:SetCountLimit(1, id)
  	e5:SetCost(s.spcost)
  	e5:SetTarget(s.sptg)
  	e5:SetOperation(s.spop)
  	c:RegisterEffect(e5)
  end
  function s.eqfilter1(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and s.eqfilter1(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.eqfilter1, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_EQUIP)
  	Duel.SelectTarget(tp, s.eqfilter1, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_EQUIP, e:GetHandler(), 1, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if c:IsRelateToEffect(e) and tc:IsRelateToEffect(e) and tc:IsFaceup() and c:CheckUniqueOnField(tp) then
  		Duel.Equip(tp, c, tc)
  	end
  end
  function s.eqlimit(e, c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsAbleToGraveAsCost()
  	end
  	e:SetLabelObject(e:GetHandler():GetEquipTarget())
  	Duel.SendtoGrave(e:GetHandler(), REASON_COST)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0)
  		and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  		and Duel.GetLocationCountFromEx(tp, tp, nil, c) > 0
  		and Duel.IsExistingMatchingCard(s.mfilter, tp, LOCATION_MZONE + LOCATION_GRAVE, LOCATION_MZONE + LOCATION_GRAVE, 1, nil, c:GetAttribute())
  end
  function s.mfilter(c, attr)
  	return (c:IsFaceup() or c:IsLocation(LOCATION_GRAVE)) and c:IsAttribute(attr)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_EXTRA, 0, 1, nil, e, tp)
  	end
  	Duel.SetTargetCard(e:GetLabelObject())
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local tc = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil, e, tp):GetFirst()
  	if not tc then
  		return
  	end
  	if Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP) == 0 then
  		return
  	end
  	local ec = e:GetLabelObject()
  	if not ec:IsRelateToEffect(e) then
  		return
  	end
  	Duel.BreakEffect()
  	if not Duel.Equip(tp, ec, tc, false) then
  		return
  	end
  	--Atk up
  	local e1 = Effect.CreateEffect(ec)
  	e1:SetType(EFFECT_TYPE_EQUIP)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	e1:SetValue(500)
  	ec:RegisterEffect(e1)
  	--equip limit
  	local e2 = Effect.CreateEffect(e:GetHandler())
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e2:SetCode(EFFECT_EQUIP_LIMIT)
  	e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  	e2:SetLabelObject(tc)
  	e2:SetValue(s.eqlimit2)
  	ec:RegisterEffect(e2)
  end
  function s.eqlimit2(e, c)
  	return c == e:GetLabelObject()
  end
  
  
source_text: Emblem
  Equip only to a "Plunder Patroll" monster. It gains 500 ATK, also your opponent cannot target it with card effects. You can send this equipped card to the GY; Special Summon 1 "Plunder Patroll" monster from your Extra Deck with the same Attribute as a monster on the field or in the GY, then take the monster that was equipped with this card, and equip it to that Special Summoned monster as an Equip Spell with this effect.
  ● The equipped monster gains 500 ATK.
  You can only use this effect of "Emblem of the Plunder Patroll" once per turn.
target_text: -- Emblem
  local SETCARD_ID_0 = 0x13f --Plunder
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_EQUIP)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_CONTINUOUS_TARGET)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--Equip limit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_EQUIP_LIMIT)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e2:SetValue(s.eqlimit)
  	c:RegisterEffect(e2)
  	--Atk up
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_EQUIP)
  	e3:SetCode(EFFECT_UPDATE_ATTACK)
  	e3:SetValue(500)
  	c:RegisterEffect(e3)
  	local e4 = e3:Clone()
  	e4:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e4:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e4:SetValue(aux.tgoval)
  	c:RegisterEffect(e4)
  	--spsummon
  	local e5 = Effect.CreateEffect(c)
  	e5:SetDescription(aux.Stringid(id, 1))
  	e5:SetType(EFFECT_TYPE_IGNITION)
  	e5:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e5:SetRange(LOCATION_SZONE)
  	e5:SetCountLimit(1, id)
  	e5:SetCost(s.spcost)
  	e5:SetTarget(s.sptg)
  	e5:SetOperation(s.spop)
  	c:RegisterEffect(e5)
  end
  function s.eqfilter1(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and s.eqfilter1(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.eqfilter1, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_EQUIP)
  	Duel.SelectTarget(tp, s.eqfilter1, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_EQUIP, e:GetHandler(), 1, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if c:IsRelateToEffect(e) and tc:IsRelateToEffect(e) and tc:IsFaceup() and c:CheckUniqueOnField(tp) then
  		Duel.Equip(tp, c, tc)
  	end
  end
  function s.eqlimit(e, c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsAbleToGraveAsCost()
  	end
  	e:SetLabelObject(e:GetHandler():GetEquipTarget())
  	Duel.SendtoGrave(e:GetHandler(), REASON_COST)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0)
  		and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  		and Duel.GetLocationCountFromEx(tp, tp, nil, c) > 0
  		and Duel.IsExistingMatchingCard(s.mfilter, tp, LOCATION_MZONE + LOCATION_GRAVE, LOCATION_MZONE + LOCATION_GRAVE, 1, nil, c:GetAttribute())
  end
  function s.mfilter(c, attr)
  	return (c:IsFaceup() or c:IsLocation(LOCATION_GRAVE)) and c:IsAttribute(attr)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_EXTRA, 0, 1, nil, e, tp)
  	end
  	Duel.SetTargetCard(e:GetLabelObject())
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local tc = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil, e, tp):GetFirst()
  	if not tc then
  		return
  	end
  	if Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP) == 0 then
  		return
  	end
  	local ec = e:GetLabelObject()
  	if not ec:IsRelateToEffect(e) then
  		return
  	end
  	Duel.BreakEffect()
  	if not Duel.Equip(tp, ec, tc, false) then
  		return
  	end
  	--Atk up
  	local e1 = Effect.CreateEffect(ec)
  	e1:SetType(EFFECT_TYPE_EQUIP)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	e1:SetValue(500)
  	ec:RegisterEffect(e1)
  	--equip limit
  	local e2 = Effect.CreateEffect(e:GetHandler())
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e2:SetCode(EFFECT_EQUIP_LIMIT)
  	e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  	e2:SetLabelObject(tc)
  	e2:SetValue(s.eqlimit2)
  	ec:RegisterEffect(e2)
  end
  function s.eqlimit2(e, c)
  	return c == e:GetLabelObject()
  end
  
  