name: Zohah,
card_text: If this card is sent from the field to the GY, or Special Summoned from the GY: You can activate this effect; your opponent draws 1 card, and if they do, you add 1 "Ogdoadic" monster from your Deck to your hand, except "Zohah, the Ogdoadic Boundless", then, each player sends 1 card from their hand to the GY. If this card is in your GY: You can send 1 card from your hand to the GY; add this card to your hand. You can only use each effect of "Zohah, the Ogdoadic Boundless" once per turn.
external_ids: local SETCARD_ID_0 = 0x161 --Ogdoadic
  
lua: local SETCARD_ID_0 = 0x161 --Ogdoadic
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--draw
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DRAW + CATEGORY_TOHAND + CATEGORY_SEARCH + CATEGORY_HANDES)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_TO_GRAVE)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.drcon)
  	e1:SetTarget(s.drtg)
  	e1:SetOperation(s.drop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetCondition(s.drcon2)
  	c:RegisterEffect(e2)
  	--to hand
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_TOHAND)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_GRAVE)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetCost(s.thcost)
  	e3:SetTarget(s.thtg)
  	e3:SetOperation(s.thop)
  	c:RegisterEffect(e3)
  end
  function s.drcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsPreviousLocation(LOCATION_ONFIELD)
  end
  function s.drcon2(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsPreviousLocation(LOCATION_GRAVE)
  end
  function s.drfilter(c)
  	return not c:IsCode(id) and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand()
  end
  function s.drtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(1 - tp, 1) and Duel.IsExistingMatchingCard(s.drfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, 1 - tp, 1)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.drop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.Draw(1 - tp, 1, REASON_EFFECT) ~= 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local g = Duel.SelectMatchingCard(tp, s.drfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  		if g:GetCount() > 0 then
  			Duel.SendtoHand(g, nil, REASON_EFFECT)
  			Duel.ConfirmCards(1 - tp, g)
  			local turnp = Duel.GetTurnPlayer()
  			local tg1 = Duel.GetFieldGroup(turnp, LOCATION_HAND, 0)
  			local tg2 = Duel.GetFieldGroup(1 - turnp, LOCATION_HAND, 0)
  			if tg1:GetCount() < 1 or tg2:GetCount() < 1 then
  				return
  			end
  			Duel.BreakEffect()
  			Duel.ShuffleHand(turnp)
  			Duel.Hint(HINT_SELECTMSG, turnp, HINTMSG_TOGRAVE)
  			local tc1 = tg1:Select(turnp, 1, 1, nil):GetFirst()
  			Duel.SendtoGrave(tc1, REASON_EFFECT)
  			Duel.ShuffleHand(1 - turnp)
  			Duel.Hint(HINT_SELECTMSG, 1 - turnp, HINTMSG_TOGRAVE)
  			local tc2 = tg2:Select(1 - turnp, 1, 1, nil):GetFirst()
  			Duel.SendtoGrave(tc2, REASON_EFFECT)
  		end
  	end
  end
  function s.thcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsAbleToGraveAsCost, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, Card.IsAbleToGraveAsCost, tp, LOCATION_HAND, 0, 1, 1, nil)
  	Duel.SendtoGrave(g, REASON_COST)
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return c:IsAbleToHand()
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, c, 1, 0, 0)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		Duel.SendtoHand(c, nil, REASON_EFFECT)
  	end
  end
  
  
source_text: Zohah,
  If this card is sent from the field to the GY, or Special Summoned from the GY: You can activate this effect; your opponent draws 1 card, and if they do, you add 1 "Ogdoadic" monster from your Deck to your hand, except "Zohah, the Ogdoadic Boundless", then, each player sends 1 card from their hand to the GY. If this card is in your GY: You can send 1 card from your hand to the GY; add this card to your hand. You can only use each effect of "Zohah, the Ogdoadic Boundless" once per turn.
target_text: -- Zohah,
  local SETCARD_ID_0 = 0x161 --Ogdoadic
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--draw
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DRAW + CATEGORY_TOHAND + CATEGORY_SEARCH + CATEGORY_HANDES)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_TO_GRAVE)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.drcon)
  	e1:SetTarget(s.drtg)
  	e1:SetOperation(s.drop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetCondition(s.drcon2)
  	c:RegisterEffect(e2)
  	--to hand
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_TOHAND)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_GRAVE)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetCost(s.thcost)
  	e3:SetTarget(s.thtg)
  	e3:SetOperation(s.thop)
  	c:RegisterEffect(e3)
  end
  function s.drcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsPreviousLocation(LOCATION_ONFIELD)
  end
  function s.drcon2(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsPreviousLocation(LOCATION_GRAVE)
  end
  function s.drfilter(c)
  	return not c:IsCode(id) and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand()
  end
  function s.drtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(1 - tp, 1) and Duel.IsExistingMatchingCard(s.drfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, 1 - tp, 1)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.drop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.Draw(1 - tp, 1, REASON_EFFECT) ~= 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local g = Duel.SelectMatchingCard(tp, s.drfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  		if g:GetCount() > 0 then
  			Duel.SendtoHand(g, nil, REASON_EFFECT)
  			Duel.ConfirmCards(1 - tp, g)
  			local turnp = Duel.GetTurnPlayer()
  			local tg1 = Duel.GetFieldGroup(turnp, LOCATION_HAND, 0)
  			local tg2 = Duel.GetFieldGroup(1 - turnp, LOCATION_HAND, 0)
  			if tg1:GetCount() < 1 or tg2:GetCount() < 1 then
  				return
  			end
  			Duel.BreakEffect()
  			Duel.ShuffleHand(turnp)
  			Duel.Hint(HINT_SELECTMSG, turnp, HINTMSG_TOGRAVE)
  			local tc1 = tg1:Select(turnp, 1, 1, nil):GetFirst()
  			Duel.SendtoGrave(tc1, REASON_EFFECT)
  			Duel.ShuffleHand(1 - turnp)
  			Duel.Hint(HINT_SELECTMSG, 1 - turnp, HINTMSG_TOGRAVE)
  			local tc2 = tg2:Select(1 - turnp, 1, 1, nil):GetFirst()
  			Duel.SendtoGrave(tc2, REASON_EFFECT)
  		end
  	end
  end
  function s.thcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsAbleToGraveAsCost, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, Card.IsAbleToGraveAsCost, tp, LOCATION_HAND, 0, 1, 1, nil)
  	Duel.SendtoGrave(g, REASON_COST)
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return c:IsAbleToHand()
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, c, 1, 0, 0)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		Duel.SendtoHand(c, nil, REASON_EFFECT)
  	end
  end
  
  