require("ai.JINB.JINB")
--平原石盘
function c87592210.initial_effect(c)
	--Activate
	local e1=Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	c:RegisterEffect(e1)

	local e2=Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(87592210,0))
	e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
	e2:SetRange(LOCATION_FZONE)
	e2:SetCountLimit(1,EFFECT_COUNT_CODE_SINGLE)
	e2:SetCondition(c87592210.con)
	e2:SetOperation(c87592210.op)
	c:RegisterEffect(e2)
	local e3=e2:Clone()
	e3:SetCode(EVENT_SUMMON_SUCCESS)
	c:RegisterEffect(e3)
end

function c87592210.con(e,tp,eg,ep,ev,re,r,rp)
	local g=eg:Filter(c87592210.filter,nil)
	return g:GetCount()==1
	and not Duel.IsExistingMatchingCard(Card.IsSetCard,g:GetFirst():GetSummonPlayer(),LOCATION_HAND,0,1,nil,0x871)
end
function c87592210.filter(c)
	return c:GetAttack()>=2000 and c:IsRace(RACE_FAIRY)
end
function c87592210.op(e,tp,eg,ep,ev,re,r,rp)
	local p=eg:GetFirst():GetSummonPlayer()
	c=Duel.CreateToken(p,ac1[math.random(#ac1)])
	Duel.SendtoHand(c,p,REASON_RULE)
	--action
	local e1=Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_SINGLE)
	e1:SetCode(EFFECT_CANNOT_SSET)
	c:RegisterEffect(e1)
	local e2=Effect.CreateEffect(c)
	e2:SetType(EFFECT_TYPE_SINGLE)
	e2:SetCode(EFFECT_QP_ACT_IN_NTPHAND)
	c:RegisterEffect(e2)
end
