name: Chronomaly
card_text: Target 1 "Chronomaly" monster in your Graveyard; banish it, then look at the top 2 cards of your Deck, add 1 of them to your hand, and send the other to the Graveyard. You can only activate 1 "Chronomaly Technology" per turn. You cannot Special Summon any monsters during the turn you activate this card, except "Chronomaly" monsters.
external_ids: local SETCARD_ID_0 = 0x70 --Chronomaly
  
lua: local SETCARD_ID_0 = 0x70 --Chronomaly
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH + CATEGORY_REMOVE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	Duel.AddCustomActivityCounter(id, ACTIVITY_SPSUMMON, s.counterfilter)
  end
  function s.counterfilter(c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetCustomActivityCount(id, tp, ACTIVITY_SPSUMMON) == 0
  	end
  	--oath effects
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_OATH)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	e1:SetTargetRange(1, 0)
  	e1:SetTarget(s.splimit)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return not c:IsSetCard(SETCARD_ID_0)
  end
  function s.filter(c)
  	return c:IsType(TYPE_MONSTER) and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToRemove()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		if not Duel.IsPlayerCanDiscardDeck(tp, 2) or not Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE, 0, 1, nil) then
  			return false
  		end
  		local g = Duel.GetDecktopGroup(tp, 2)
  		return g:FilterCount(Card.IsAbleToHand, nil) > 0
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g, 1, tp, LOCATION_GRAVE)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, 0, LOCATION_DECK)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and Duel.Remove(tc, POS_FACEUP, REASON_EFFECT) ~= 0 and Duel.IsPlayerCanDiscardDeck(tp, 2) then
  		Duel.BreakEffect()
  		local g = Duel.GetDecktopGroup(tp, 2)
  		Duel.ConfirmCards(tp, g)
  		if g:GetCount() > 0 then
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  			local sg = g:FilterSelect(tp, Card.IsAbleToHand, 1, 1, nil)
  			g:Sub(sg)
  			if sg:GetCount() > 0 then
  				Duel.DisableShuffleCheck()
  				Duel.SendtoHand(sg, nil, REASON_EFFECT)
  			end
  			if g:GetCount() > 0 then
  				Duel.DisableShuffleCheck()
  				Duel.SendtoGrave(g, REASON_EFFECT)
  			end
  		end
  	end
  end
  
  
source_text: Chronomaly
  Target 1 "Chronomaly" monster in your Graveyard; banish it, then look at the top 2 cards of your Deck, add 1 of them to your hand, and send the other to the Graveyard. You can only activate 1 "Chronomaly Technology" per turn. You cannot Special Summon any monsters during the turn you activate this card, except "Chronomaly" monsters.
target_text: -- Chronomaly
  local SETCARD_ID_0 = 0x70 --Chronomaly
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH + CATEGORY_REMOVE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	Duel.AddCustomActivityCounter(id, ACTIVITY_SPSUMMON, s.counterfilter)
  end
  function s.counterfilter(c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetCustomActivityCount(id, tp, ACTIVITY_SPSUMMON) == 0
  	end
  	--oath effects
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_OATH)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	e1:SetTargetRange(1, 0)
  	e1:SetTarget(s.splimit)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return not c:IsSetCard(SETCARD_ID_0)
  end
  function s.filter(c)
  	return c:IsType(TYPE_MONSTER) and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToRemove()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		if not Duel.IsPlayerCanDiscardDeck(tp, 2) or not Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE, 0, 1, nil) then
  			return false
  		end
  		local g = Duel.GetDecktopGroup(tp, 2)
  		return g:FilterCount(Card.IsAbleToHand, nil) > 0
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g, 1, tp, LOCATION_GRAVE)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, 0, LOCATION_DECK)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and Duel.Remove(tc, POS_FACEUP, REASON_EFFECT) ~= 0 and Duel.IsPlayerCanDiscardDeck(tp, 2) then
  		Duel.BreakEffect()
  		local g = Duel.GetDecktopGroup(tp, 2)
  		Duel.ConfirmCards(tp, g)
  		if g:GetCount() > 0 then
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  			local sg = g:FilterSelect(tp, Card.IsAbleToHand, 1, 1, nil)
  			g:Sub(sg)
  			if sg:GetCount() > 0 then
  				Duel.DisableShuffleCheck()
  				Duel.SendtoHand(sg, nil, REASON_EFFECT)
  			end
  			if g:GetCount() > 0 then
  				Duel.DisableShuffleCheck()
  				Duel.SendtoGrave(g, REASON_EFFECT)
  			end
  		end
  	end
  end
  
  