name: Valkyrie
card_text: If this card is Special Summoned from your hand by a Spell effect: You can target 1 "Mischief of the Time Goddess" in your GY; add it to your hand. If you control a "Valkyrie" monster other than "Valkyrie Erste" (Quick Effect): You can banish 1 monster from your opponent's GY, then this card's ATK becomes equal to the banished monster's original ATK until the end of this turn. You can only use each effect of "Valkyrie Erste" once per turn.
external_ids: local CARD_ID_1 = 92182447 --Mischief of the Time Goddess
  local SETCARD_ID_0 = 0x122 --Valkyrie
  
lua: local CARD_ID_1 = 92182447 --Mischief of the Time Goddess
  local SETCARD_ID_0 = 0x122 --Valkyrie
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--damage
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_LEAVE_GRAVE)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_CARD_TARGET)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.thcon)
  	e1:SetTarget(s.thtg)
  	e1:SetOperation(s.thop)
  	c:RegisterEffect(e1)
  	--remove
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_REMOVE + CATEGORY_LEAVE_GRAVE)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(s.rmcon)
  	e2:SetTarget(s.rmtg)
  	e2:SetOperation(s.rmop)
  	c:RegisterEffect(e2)
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:GetSpecialSummonInfo(SUMMON_INFO_TYPE) & TYPE_SPELL ~= 0 and c:IsPreviousLocation(LOCATION_HAND)
  end
  function s.thfilter(c)
  	return c:IsCode(CARD_ID_1) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.thfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.thfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectTarget(tp, s.thfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, 1, 0, 0)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.SendtoHand(tc, nil, REASON_EFFECT)
  	end
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and not c:IsCode(id)
  end
  function s.rmcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
  end
  function s.rmfilter(c)
  	return c:IsType(TYPE_MONSTER) and c:IsAbleToRemove()
  end
  function s.rmtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.rmfilter, tp, 0, LOCATION_GRAVE, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, nil, 1, 1 - tp, LOCATION_GRAVE)
  end
  function s.rmop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local rc = Duel.SelectMatchingCard(tp, s.rmfilter, tp, 0, LOCATION_GRAVE, 1, 1, nil):GetFirst()
  	if rc then
  		if Duel.Remove(rc, POS_FACEUP, REASON_EFFECT) ~= 0 and c:IsRelateToEffect(e) and c:IsFaceup() then
  			Duel.BreakEffect()
  			local atk = rc:GetBaseAttack()
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_SET_ATTACK_FINAL)
  			e1:SetValue(atk)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  			c:RegisterEffect(e1)
  		end
  	end
  end
  
  
source_text: Valkyrie
  If this card is Special Summoned from your hand by a Spell effect: You can target 1 "Mischief of the Time Goddess" in your GY; add it to your hand. If you control a "Valkyrie" monster other than "Valkyrie Erste" (Quick Effect): You can banish 1 monster from your opponent's GY, then this card's ATK becomes equal to the banished monster's original ATK until the end of this turn. You can only use each effect of "Valkyrie Erste" once per turn.
target_text: -- Valkyrie
  local CARD_ID_1 = 92182447 --Mischief of the Time Goddess
  local SETCARD_ID_0 = 0x122 --Valkyrie
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--damage
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_LEAVE_GRAVE)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_CARD_TARGET)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.thcon)
  	e1:SetTarget(s.thtg)
  	e1:SetOperation(s.thop)
  	c:RegisterEffect(e1)
  	--remove
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_REMOVE + CATEGORY_LEAVE_GRAVE)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(s.rmcon)
  	e2:SetTarget(s.rmtg)
  	e2:SetOperation(s.rmop)
  	c:RegisterEffect(e2)
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:GetSpecialSummonInfo(SUMMON_INFO_TYPE) & TYPE_SPELL ~= 0 and c:IsPreviousLocation(LOCATION_HAND)
  end
  function s.thfilter(c)
  	return c:IsCode(CARD_ID_1) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.thfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.thfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectTarget(tp, s.thfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, 1, 0, 0)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.SendtoHand(tc, nil, REASON_EFFECT)
  	end
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and not c:IsCode(id)
  end
  function s.rmcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
  end
  function s.rmfilter(c)
  	return c:IsType(TYPE_MONSTER) and c:IsAbleToRemove()
  end
  function s.rmtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.rmfilter, tp, 0, LOCATION_GRAVE, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, nil, 1, 1 - tp, LOCATION_GRAVE)
  end
  function s.rmop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local rc = Duel.SelectMatchingCard(tp, s.rmfilter, tp, 0, LOCATION_GRAVE, 1, 1, nil):GetFirst()
  	if rc then
  		if Duel.Remove(rc, POS_FACEUP, REASON_EFFECT) ~= 0 and c:IsRelateToEffect(e) and c:IsFaceup() then
  			Duel.BreakEffect()
  			local atk = rc:GetBaseAttack()
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_SET_ATTACK_FINAL)
  			e1:SetValue(atk)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  			c:RegisterEffect(e1)
  		end
  	end
  end
  
  