name: Latinum,
card_text: If this card is discarded to the GY by card effect: If it was discarded from your hand to your GY by an opponent's card effect, target 1 Fiend monster on the field; Special Summon this card, then that target (if any) gains 500 ATK.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--spsummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_TO_GRAVE)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	e:SetLabel(e:GetHandler():GetPreviousControler())
  	return e:GetHandler():IsPreviousLocation(LOCATION_HAND) and bit.band(r, 0x4040) == 0x4040
  end
  function s.atfilter(c)
  	return c:IsFaceup() and c:IsRace(RACE_FIEND)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and s.atfilter(chkc)
  	end
  	if chk == 0 then
  		return true
  	end
  	if rp == 1 - tp and tp == e:GetLabel() then
  		e:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_ATKCHANGE)
  		e:SetProperty(EFFECT_FLAG_CARD_TARGET)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  		Duel.SelectTarget(tp, s.atfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, nil)
  	else
  		e:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsRelateToEffect(e) and Duel.SpecialSummon(e:GetHandler(), 0, tp, tp, false, false, POS_FACEUP) > 0 then
  		local tc = Duel.GetFirstTarget()
  		if tc and s.atfilter(tc) and tc:IsRelateToEffect(e) then
  			Duel.BreakEffect()
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_UPDATE_ATTACK)
  			e1:SetValue(500)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  			tc:RegisterEffect(e1)
  		end
  	end
  end
  
  
source_text: Latinum,
  If this card is discarded to the GY by card effect: If it was discarded from your hand to your GY by an opponent's card effect, target 1 Fiend monster on the field; Special Summon this card, then that target (if any) gains 500 ATK.
target_text: -- Latinum,
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--spsummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_TO_GRAVE)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	e:SetLabel(e:GetHandler():GetPreviousControler())
  	return e:GetHandler():IsPreviousLocation(LOCATION_HAND) and bit.band(r, 0x4040) == 0x4040
  end
  function s.atfilter(c)
  	return c:IsFaceup() and c:IsRace(RACE_FIEND)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and s.atfilter(chkc)
  	end
  	if chk == 0 then
  		return true
  	end
  	if rp == 1 - tp and tp == e:GetLabel() then
  		e:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_ATKCHANGE)
  		e:SetProperty(EFFECT_FLAG_CARD_TARGET)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  		Duel.SelectTarget(tp, s.atfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, nil)
  	else
  		e:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsRelateToEffect(e) and Duel.SpecialSummon(e:GetHandler(), 0, tp, tp, false, false, POS_FACEUP) > 0 then
  		local tc = Duel.GetFirstTarget()
  		if tc and s.atfilter(tc) and tc:IsRelateToEffect(e) then
  			Duel.BreakEffect()
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_UPDATE_ATTACK)
  			e1:SetValue(500)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  			tc:RegisterEffect(e1)
  		end
  	end
  end
  
  