Ordeal
Once per battle, when an opponent's monster declares an attack: You can activate this effect; Your opponent chooses 1 random card in your hand and calls the card type (Monster, Spell, or Trap), and if they call it wrong, return the attacking monster to the hand.
local s, id, o = GetID()
function s.initial_effect(c)
	--Activate
	local e1 = Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	c:RegisterEffect(e1)
	--tohand
	local e2 = Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(id, 0))
	e2:SetCategory(CATEGORY_TOHAND)
	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
	e2:SetCode(EVENT_ATTACK_ANNOUNCE)
	e2:SetRange(LOCATION_SZONE)
	e2:SetCountLimit(1, EFFECT_COUNT_CODE_CHAIN)
	e2:SetCondition(s.condition)
	e2:SetTarget(s.target)
	e2:SetOperation(s.activate)
	c:RegisterEffect(e2)
end
function s.condition(e, tp, eg, ep, ev, re, r, rp)
	return Duel.GetAttacker():IsControler(1 - tp)
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0) > 0
	end
	Duel.SetTargetCard(Duel.GetAttacker())
end
function s.activate(e, tp, eg, ep, ev, re, r, rp)
	if Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0) == 0 or not Duel.GetAttacker():IsRelateToEffect(e) then
		return
	end
	local g = Duel.GetFieldGroup(tp, LOCATION_HAND, 0):RandomSelect(1 - tp, 1)
	local tc = g:GetFirst()
	Duel.Hint(HINT_SELECTMSG, 1 - tp, HINTMSG_CARDTYPE)
	local op = Duel.AnnounceType(1 - tp)
	Duel.ConfirmCards(1 - tp, tc)
	Duel.ShuffleHand(tp)
	if (op ~= 0 and tc:IsType(TYPE_MONSTER)) or (op ~= 1 and tc:IsType(TYPE_SPELL)) or (op ~= 2 and tc:IsType(TYPE_TRAP)) then
		Duel.SendtoHand(Duel.GetAttacker(), nil, REASON_EFFECT)
	end
end


Ordeal
Once per battle, when an opponent's monster declares an attack: You can activate this effect; Your opponent chooses 1 random card in your hand and calls the card type (Monster, Spell, or Trap), and if they call it wrong, return the attacking monster to the hand.
-- Ordeal
local s, id, o = GetID()
function s.initial_effect(c)
	--Activate
	local e1 = Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	c:RegisterEffect(e1)
	--tohand
	local e2 = Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(id, 0))
	e2:SetCategory(CATEGORY_TOHAND)
	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
	e2:SetCode(EVENT_ATTACK_ANNOUNCE)
	e2:SetRange(LOCATION_SZONE)
	e2:SetCountLimit(1, EFFECT_COUNT_CODE_CHAIN)
	e2:SetCondition(s.condition)
	e2:SetTarget(s.target)
	e2:SetOperation(s.activate)
	c:RegisterEffect(e2)
end
function s.condition(e, tp, eg, ep, ev, re, r, rp)
	return Duel.GetAttacker():IsControler(1 - tp)
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0) > 0
	end
	Duel.SetTargetCard(Duel.GetAttacker())
end
function s.activate(e, tp, eg, ep, ev, re, r, rp)
	if Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0) == 0 or not Duel.GetAttacker():IsRelateToEffect(e) then
		return
	end
	local g = Duel.GetFieldGroup(tp, LOCATION_HAND, 0):RandomSelect(1 - tp, 1)
	local tc = g:GetFirst()
	Duel.Hint(HINT_SELECTMSG, 1 - tp, HINTMSG_CARDTYPE)
	local op = Duel.AnnounceType(1 - tp)
	Duel.ConfirmCards(1 - tp, tc)
	Duel.ShuffleHand(tp)
	if (op ~= 0 and tc:IsType(TYPE_MONSTER)) or (op ~= 1 and tc:IsType(TYPE_SPELL)) or (op ~= 2 and tc:IsType(TYPE_TRAP)) then
		Duel.SendtoHand(Duel.GetAttacker(), nil, REASON_EFFECT)
	end
end

