--火之迦具土
--Hino-Kagu-Tsuchi (GOAT)
--If the Draw Phase is skipped, the effect is used during the next available phase
local s,id=GetID()
function s.initial_effect(c)
	Spirit.AddProcedure(c,EVENT_SUMMON_SUCCESS,EVENT_FLIP)
	--Cannot be Special Summoned
	local e1=Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_SINGLE)
	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
	c:RegisterEffect(e1)
	--Opponent discards their hand next Draw Phase
	local e2=Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(id,0))
	e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
	e2:SetCode(EVENT_BATTLE_DAMAGE)
	e2:SetCondition(function(_,tp,_,ep) return ep==1-tp end)
	e2:SetOperation(s.hdreg)
	c:RegisterEffect(e2)
end
function s.hdreg(e,tp,eg,ep,ev,re,r,rp)
	local c=e:GetHandler()
	local effs={}
	--Discard hand in the Draw Phase
	local e1=Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
	e1:SetCode(EVENT_PREDRAW)
	e1:SetLabelObject(effs)
	e1:SetOperation(s.hdop)
	e1:SetReset(RESET_PHASE+PHASE_DRAW)
	Duel.RegisterEffect(e1,tp)
	local e2=e1:Clone()
	e2:SetCode(EVENT_PHASE+PHASE_STANDBY)
	e2:SetReset(RESET_PHASE+PHASE_MAIN1)
	Duel.RegisterEffect(e2,tp)
	local e3=e1:Clone()
	e3:SetCode(EVENT_ADJUST)
	e3:SetCondition(function() return Duel.IsMainPhase() and Duel.IsTurnPlayer(1-tp) end)
	Duel.RegisterEffect(e3,tp)
	local hinteff=aux.RegisterClientHint(c,0,tp,0,1,aux.Stringid(id,1))
	hinteff:SetReset(RESET_PHASE+PHASE_MAIN1)
	table.insert(effs,e1)
	table.insert(effs,e2)
	table.insert(effs,e3)
	table.insert(effs,hinteff)
end
function s.hdop(e,tp,eg,ep,ev,re,r,rp)
	local g=Duel.GetFieldGroup(tp,0,LOCATION_HAND)
	if #g>0 then
		Duel.SendtoGrave(g,REASON_DISCARD+REASON_EFFECT)
	end
	for _,eff in pairs(e:GetLabelObject()) do
		eff:Reset()
	end
end