name: ラヴァルバル・チェイン
card_text: レベル4モンスター×2
  1:1ターンに1度、このカードのX素材を1つ取り除き、以下の効果から1つを選択して発動できる。
  ●デッキからカード1枚を選んで墓地へ送る。
  ●デッキからモンスター1体を選んでデッキの一番上に置く。
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 4, 2)
  	c:EnableReviveLimit()
  	--to grave
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 1))
  	e1:SetCategory(CATEGORY_TOGRAVE)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, EFFECT_COUNT_CODE_SINGLE)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target1)
  	e1:SetOperation(s.operation1)
  	c:RegisterEffect(e1)
  	--to deck top
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 2))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, EFFECT_COUNT_CODE_SINGLE)
  	e2:SetCost(s.cost)
  	e2:SetTarget(s.target2)
  	e2:SetOperation(s.operation2)
  	c:RegisterEffect(e2)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	Duel.Hint(HINT_OPSELECTED, 1 - tp, e:GetDescription())
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  end
  function s.target1(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsAbleToGrave, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_DECK)
  end
  function s.target2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsType, tp, LOCATION_DECK, 0, 1, nil, TYPE_MONSTER) and Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) > 1
  	end
  end
  function s.operation1(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, Card.IsAbleToGrave, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoGrave(g, REASON_EFFECT)
  	end
  end
  function s.operation2(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 3))
  	local g = Duel.SelectMatchingCard(tp, Card.IsType, tp, LOCATION_DECK, 0, 1, 1, nil, TYPE_MONSTER)
  	local tc = g:GetFirst()
  	if tc then
  		Duel.ShuffleDeck(tp)
  		Duel.MoveSequence(tc, SEQ_DECKTOP)
  		Duel.ConfirmDecktop(tp, 1)
  	end
  end
  
  
source_text: ラヴァルバル・チェイン
  レベル4モンスター×2
  1:1ターンに1度、このカードのX素材を1つ取り除き、以下の効果から1つを選択して発動できる。
  ●デッキからカード1枚を選んで墓地へ送る。
  ●デッキからモンスター1体を選んでデッキの一番上に置く。
target_text: -- ラヴァルバル・チェイン
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 4, 2)
  	c:EnableReviveLimit()
  	--to grave
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 1))
  	e1:SetCategory(CATEGORY_TOGRAVE)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, EFFECT_COUNT_CODE_SINGLE)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target1)
  	e1:SetOperation(s.operation1)
  	c:RegisterEffect(e1)
  	--to deck top
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 2))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, EFFECT_COUNT_CODE_SINGLE)
  	e2:SetCost(s.cost)
  	e2:SetTarget(s.target2)
  	e2:SetOperation(s.operation2)
  	c:RegisterEffect(e2)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	Duel.Hint(HINT_OPSELECTED, 1 - tp, e:GetDescription())
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  end
  function s.target1(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsAbleToGrave, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_DECK)
  end
  function s.target2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsType, tp, LOCATION_DECK, 0, 1, nil, TYPE_MONSTER) and Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) > 1
  	end
  end
  function s.operation1(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, Card.IsAbleToGrave, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoGrave(g, REASON_EFFECT)
  	end
  end
  function s.operation2(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 3))
  	local g = Duel.SelectMatchingCard(tp, Card.IsType, tp, LOCATION_DECK, 0, 1, 1, nil, TYPE_MONSTER)
  	local tc = g:GetFirst()
  	if tc then
  		Duel.ShuffleDeck(tp)
  		Duel.MoveSequence(tc, SEQ_DECKTOP)
  		Duel.ConfirmDecktop(tp, 1)
  	end
  end
  
  