Commit 23cc9ecf authored by JoyJ's avatar JoyJ

fix 遗言之札;add 古代妖精龙

parent 61925ff7
No preview for this file type
--エンシェント・フェアリー・ドラゴン
function c18626852.initial_effect(c)
--synchro summon
aux.AddSynchroProcedure(c,nil,aux.NonTuner(nil),1)
c:EnableReviveLimit()
--special summon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(18626852,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetCountLimit(1)
e1:SetRange(LOCATION_MZONE)
e1:SetCondition(c18626852.sumcon)
e1:SetCost(c18626852.cost)
e1:SetTarget(c18626852.sumtg)
e1:SetOperation(c18626852.sumop)
c:RegisterEffect(e1)
--destroy
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(18626852,1))
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetCategory(CATEGORY_DESTROY+CATEGORY_RECOVER+CATEGORY_SEARCH)
e2:SetRange(LOCATION_MZONE)
e2:SetCountLimit(1)
e2:SetCost(c18626852.cost)
e2:SetTarget(c18626852.destg)
e2:SetOperation(c18626852.desop)
c:RegisterEffect(e2)
end
function c18626852.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
end
function c18626852.sumcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetCurrentPhase()==PHASE_MAIN1
end
function c18626852.sumfilter(c,e,tp)
return c:IsLevelBelow(4) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c18626852.sumtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingMatchingCard(c18626852.sumfilter,tp,LOCATION_HAND,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,0,LOCATION_HAND)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_CANNOT_BP)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_OATH)
e1:SetTargetRange(1,0)
e1:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e1,tp)
end
function c18626852.sumop(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,c18626852.sumfilter,tp,LOCATION_HAND,0,1,1,nil,e,tp)
if g:GetCount()>0 then
Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP)
end
end
function c18626852.destg(e,tp,eg,ep,ev,re,r,rp,chk)
local g=Duel.GetFieldGroup(tp,LOCATION_FZONE,LOCATION_FZONE)
if chk==0 then return g:GetCount()>0 end
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0)
Duel.SetOperationInfo(0,CATEGORY_RECOVER,nil,0,tp,1000)
end
function c18626852.ffilter(c)
return c:IsType(TYPE_FIELD) and c:IsAbleToHand()
end
function c18626852.desop(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetFieldGroup(tp,LOCATION_FZONE,LOCATION_FZONE)
if g:GetCount()>0 then
local ct=Duel.Destroy(g,REASON_EFFECT)
if ct>0 then
Duel.Recover(tp,1000,REASON_EFFECT)
local fg=Duel.GetMatchingGroup(c18626852.ffilter,tp,LOCATION_DECK,0,nil)
if fg:GetCount()>0 and Duel.SelectYesNo(tp,aux.Stringid(18626852,2)) then
Duel.BreakEffect()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local sg=fg:Select(tp,1,1,nil)
Duel.SendtoHand(sg,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,sg)
end
end
end
end
\ No newline at end of file
--[决斗编年史]遗言之札
function c20049999.initial_effect(c)
if not c20049999.reg then
c20049999.reg = true
local orig = Card.RegisterEffect
Card.RegisterEffect = function(c,e,...)
if e:GetCode()==EFFECT_UPDATE_ATTACK or e:GetCode()==EFFECT_SET_ATTACK_FINAL then
local v=e:GetValue()
if aux.GetValueType(v)=="function" then
local newv = function(e,c)
local val = v(e,c)
if c:GetAttack()>0 and val == 0 then Duel.RaiseEvent(EVENT_CUSTOM+20049999) end
return val
end
e:SetValue(newv)
orig(c,e,...)
elseif c:GetAttack()>0 and ((e:GetCode()==EFFECT_SET_ATTACK_FINAL and val == 0) or (e:GetCode()==EFFECT_UPDATE_ATTACK and c:GetAttack() + val == 0)) then
Duel.RaiseEvent(EVENT_CUSTOM+20049999)
orig(c,e,...)
end
end
end
c20049999.reg = {}
local ge1=Effect.CreateEffect(c)
ge1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
ge1:SetCode(EVENT_CHAIN_SOLVING)
ge1:SetOperation(c20049999.count)
Duel.RegisterEffect(ge1,0)
local ge2=Effect.CreateEffect(c)
ge2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
ge2:SetCode(EVENT_CHAIN_SOLVED)
ge2:SetOperation(c20049999.reset)
Duel.RegisterEffect(ge2,0)
end
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(20049999,1))
e1:SetCategory(CATEGORY_DRAW)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_CUSTOM+20049999)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_DELAY)
e1:SetCode(EVENT_CUSTOM+20049999)
e1:SetTarget(c20049999.drtg)
e1:SetOperation(c20049999.drop)
c:RegisterEffect(e1)
end
function c20049999.count(e,tp,eg,ep,ev,re,r,rp)
c20049999.reg={}
local g=Duel.GetFieldGroup(tp,LOCATION_MZONE,LOCATION_MZONE)
for tc in aux.Next(g) do
c20049999.reg[tc]=tc:GetAttack()
end
--adjust
local e1=Effect.GlobalEffect()
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e1:SetCode(EVENT_ADJUST)
e1:SetOperation(c20049999.ChainOperation)
Duel.RegisterEffect(e1,0)
c20049999.chain = e1
end
function c20049999.ChainOperation(e,tp,eg,ep,ev,re,r,rp)
Debug.Message("ChainOperation")
local g=Duel.GetFieldGroup(tp,LOCATION_MZONE,LOCATION_MZONE)
for tc in aux.Next(g) do
local atk = tc:GetAttack()
if atk==0 and c20049999.reg[tc] and c20049999.reg[tc]>0 then
Duel.RaiseEvent(tc,EVENT_CUSTOM+20049999,re,REASON_EFFECT,rp,ep,ev)
end
c20049999.reg[tc]=atk
end
end
function c20049999.reset(e,tp,eg,ep,ev,re,r,rp)
Debug.Message("reset")
if Duel.GetCurrentChain()>0 then return end
c20049999.chain:Reset()
end
function c20049999.drtg(e,tp,eg,ep,ev,re,r,rp,chk)
local cnt=Duel.GetCardsInZone(tp,LOCATION_HAND):GetCount()
if chk==0 then return cnt>=5 or not Duel.IsPlayerCanDraw(tp,5-cnt) end
if chk==0 then return cnt<5 and Duel.IsPlayerCanDraw(tp,5-cnt) end
Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,5-cnt)
end
function c20049999.drop(e,tp,eg,ep,ev,re,r,rp)
local cnt=5-Duel.GetCardsInZone(tp,LOCATION_HAND):GetCount()
local _,_,_,p=Duel.GetOperationInfo(0,CATEGORY_DRAW)
local cnt=5-Duel.GetCardsInZone(tp,LOCATION_HAND):GetCount()
Duel.Draw(p,cnt,REASON_EFFECT)
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment