name: World
card_text: Excavate the top 5 cards of your Deck, and if you do, add 1 excavated "Krawler" monster or "World Legacy" card to your hand, also send the remaining cards to the GY. Otherwise, shuffle all excavated cards into the Deck. For the rest of this turn after this card resolves, you cannot Special Summon monsters from the Extra Deck, except Link Monsters. You can only activate 1 "World Legacy Survivor" per turn.
external_ids: local SETCARD_ID_0 = 0x104 --Krawler
  
lua: local SETCARD_ID_0 = 0x104 --Krawler
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH + CATEGORY_DECKDES)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDiscardDeck(tp, 5) and Duel.GetDecktopGroup(tp, 5):FilterCount(Card.IsAbleToHand, nil) > 0
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, 0, LOCATION_DECK)
  end
  function s.filter(c)
  	return (c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER)) or c:IsSetCard(0xfe) and c:IsAbleToHand()
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.IsPlayerCanDiscardDeck(tp, 5) then
  		Duel.ConfirmDecktop(tp, 5)
  		local g = Duel.GetDecktopGroup(tp, 5)
  		if g:GetCount() > 0 then
  			if g:IsExists(s.filter, 1, nil) then
  				Duel.DisableShuffleCheck()
  				Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  				local sg = g:FilterSelect(tp, s.filter, 1, 1, nil)
  				Duel.SendtoHand(sg, nil, REASON_EFFECT)
  				Duel.ConfirmCards(1 - tp, sg)
  				Duel.ShuffleHand(tp)
  				g:Sub(sg)
  				Duel.SendtoGrave(g, REASON_EFFECT + REASON_REVEAL)
  			else
  				Duel.ShuffleDeck(tp)
  			end
  		end
  	end
  	if not e:IsHasType(EFFECT_TYPE_ACTIVATE) then
  		return
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetTargetRange(1, 0)
  	e1:SetTarget(s.splimit)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.splimit(e, c)
  	return not c:IsType(TYPE_LINK) and c:IsLocation(LOCATION_EXTRA)
  end
  
  
source_text: World
  Excavate the top 5 cards of your Deck, and if you do, add 1 excavated "Krawler" monster or "World Legacy" card to your hand, also send the remaining cards to the GY. Otherwise, shuffle all excavated cards into the Deck. For the rest of this turn after this card resolves, you cannot Special Summon monsters from the Extra Deck, except Link Monsters. You can only activate 1 "World Legacy Survivor" per turn.
target_text: -- World
  local SETCARD_ID_0 = 0x104 --Krawler
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH + CATEGORY_DECKDES)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDiscardDeck(tp, 5) and Duel.GetDecktopGroup(tp, 5):FilterCount(Card.IsAbleToHand, nil) > 0
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, 0, LOCATION_DECK)
  end
  function s.filter(c)
  	return (c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER)) or c:IsSetCard(0xfe) and c:IsAbleToHand()
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.IsPlayerCanDiscardDeck(tp, 5) then
  		Duel.ConfirmDecktop(tp, 5)
  		local g = Duel.GetDecktopGroup(tp, 5)
  		if g:GetCount() > 0 then
  			if g:IsExists(s.filter, 1, nil) then
  				Duel.DisableShuffleCheck()
  				Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  				local sg = g:FilterSelect(tp, s.filter, 1, 1, nil)
  				Duel.SendtoHand(sg, nil, REASON_EFFECT)
  				Duel.ConfirmCards(1 - tp, sg)
  				Duel.ShuffleHand(tp)
  				g:Sub(sg)
  				Duel.SendtoGrave(g, REASON_EFFECT + REASON_REVEAL)
  			else
  				Duel.ShuffleDeck(tp)
  			end
  		end
  	end
  	if not e:IsHasType(EFFECT_TYPE_ACTIVATE) then
  		return
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetTargetRange(1, 0)
  	e1:SetTarget(s.splimit)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.splimit(e, c)
  	return not c:IsType(TYPE_LINK) and c:IsLocation(LOCATION_EXTRA)
  end
  
  