--極星冥神ヘル
function c114514909.initial_effect(c)
    --special summon rule(on oppent field)
	local e1=Effect.CreateEffect(c)
	e1:SetDescription(aux.Stringid(114514909,0))
	e1:SetType(EFFECT_TYPE_FIELD)
	e1:SetCode(EFFECT_SPSUMMON_PROC)
	e1:SetRange(LOCATION_HAND)
	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_SPSUM_PARAM)
	e1:SetTargetRange(POS_FACEUP,1)
	e1:SetCountLimit(1,114514909+EFFECT_COUNT_CODE_OATH)
	e1:SetCondition(c114514909.spcon)
	e1:SetOperation(c114514909.spop)
	c:RegisterEffect(e1)
    --draw
	local e2=Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(114514909,1))
	e2:SetType(EFFECT_TYPE_QUICK_O)
	e2:SetCode(EVENT_FREE_CHAIN)
	e2:SetHintTiming(0,TIMINGS_CHECK_MONSTER)
	e2:SetRange(LOCATION_HAND)
	e2:SetCountLimit(1)
	e2:SetCost(c114514909.cost)
    e2:SetCondition(c114514909.cond)
	e2:SetOperation(c114514909.operation)
	c:RegisterEffect(e2)
end
function c114514909.checkfilter(c)
    return c:IsSetCard(0x4b,0x42) and c:IsFaceup() and not c:IsAttribute(ATTRIBUTE_DARK)
end
function c114514909.sprfilter(c,tp,sp)
    return c:IsReleasable()
end
function c114514909.spcon(e,c)
    if c==nil then return true end
    local tp=c:GetControler()
    return Duel.IsExistingMatchingCard(c114514909.checkfilter,tp,LOCATION_MZONE,0,1,nil)
        and Duel.IsExistingMatchingCard(c114514909.sprfilter,tp,0,LOCATION_MZONE,2,nil,1-tp,tp)
end
function c114514909.spop(e,tp,eg,ep,ev,re,r,rp,c)
    Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE)
    local g=Duel.SelectMatchingCard(tp,c114514909.sprfilter,tp,0,LOCATION_MZONE,2,2,nil,1-tp,tp)
    Duel.Release(g,REASON_COST)
end
function c114514909.cost(e,tp,eg,ep,ev,re,r,rp,chk)
	if chk==0 then return e:GetHandler():IsAbleToGraveAsCost() end
	Duel.SendtoGrave(e:GetHandler(),REASON_COST)
end
function c114514909.acfilter(c)
    return c:IsSetCard(0x4b) and c:IsFaceup() and c:IsAttribute(ATTRIBUTE_DARK)
end
function c114514909.cond(e,tp,eg,ep,ev,re,r,rp)
    return Duel.IsExistingMatchingCard(c114514909.acfilter,tp,LOCATION_MZONE,0,1,nil)
end
function c114514909.operation(e,tp,eg,ep,ev,re,r,rp)
	local c=e:GetHandler()
	local e1=Effect.CreateEffect(c)
    e1:SetType(EFFECT_TYPE_FIELD)
	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_CLIENT_HINT)
	e1:SetTargetRange(1,1)
    e1:SetCode(EFFECT_CANNOT_ACTIVATE)
    e1:SetValue(c114514909.actlimit)
    e1:SetReset(1,RESET_PHASE+PHASE_END)
	Duel.RegisterEffect(e1,tp)
    local e2=e1:Clone()
    e2:SetCode(EFFECT_CANNOT_REMOVE)
    e2:SetTarget(c114514909.rmlimit)
    Duel.RegisterEffect(e2,tp)
    local e3=e1:Clone()
    e3:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
    e3:SetTarget(c114514909.splimit)
    Duel.RegisterEffect(e3,tp)
end
function c114514909.actlimit(e,re,tp)
	return re:GetActivateLocation()==LOCATION_GRAVE
end
function c114514909.rmlimit(e,c)
	return c:IsLocation(LOCATION_GRAVE)
end
function c114514909.splimit(e,c)
	return c:IsLocation(LOCATION_GRAVE) and c:IsType(TYPE_MONSTER)
end